Answer to Question #7771 in C++ for asim

Question #7771
write a program which take five integers from user and print the sum of all odd integers
1
Expert's answer
2012-03-30T07:02:16-0400
#include<iostream.h>

int main(int argc, char * argv[]){

int sum=0, num, i;
for (i=1;i<=5;i++){
& printf("Enter some integer please: ");
& scanf("%d", &num);
& if (num%2 != 0) sum += num;
}

printf("The sum of odd numbers is %d \n", sum);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS