C program : Take 5 numbes input and sum of all between number between them
#include <stdio.h>
int main() {
int total=0;
int i, numbers[5];
printf("input the first number\n: ");
scanf("%d", &numbers[0]);
printf("input the second number\n: ");
scanf("%d", &numbers[1]);
printf("input the third number\n: ");
scanf("%d", &numbers[2]);
printf("input the fourth number\n: ");
scanf("%d", &numbers[3]);
printf("input the fifth number\n: ");
scanf("%d", &numbers[4]);
for(i = 0; i < 5; i++) {
if((numbers[i]%2) != 1)
{
total += numbers[i];
}
}
printf("Sum of all even values: %d", total);
return 0;
}
0 Comments:
Post a Comment