Skip to content

Commit

Permalink
Create ex3_15.c
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMCerdeira authored Nov 7, 2019
1 parent 87fdc3a commit f35299f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions ex3_15.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*3.15) Escrever um algoritmo que lê 5 pares de valores a, b,
todos inteiros e positivos, um par de cada vez,
e com a < b, escreve os inteiros pares de a até b,
incluindo o a e o b se forem pares.
*/

void print_within(int a, int b)
{
for(int i = a; i < b; i++){
if(i % 2 == 0)
printf("%d ", i);
}
}

void ex3_15()
{
/* 5 linhas, 2 colunas */
int pairs[5][2];
int a, b;

int i = 0;
while(i < 5)
{
int a;
int b;
scanf("%i %i", &a, &b);
pairs[j][0] = a;
pairs[j][1] = b;
i++;
}

for(int j = 0; j < i; j++){
if(pairs[j][0] < pairs[j][1]){
print_within(pairs[j][0], pairs[j][1]);
}
}
}

0 comments on commit f35299f

Please sign in to comment.