+ 1
//code coach problem! "That's odd" task: We want to take a list of numbers and find the sum of all of the only even numbers.
Please tell where I am going wrong?? #include <stdio.h> int main() { int num, num2, sum1 = 0,sum =0; scanf("%d",&num); for(int i = 0; i < num; i++){ scanf("%d",&num2); if(num2 % 2 ==0){ sum1= sum1+num2; printf("%d",sum1); } else{ printf("%d",sum); } } return 0; }
7 ответов
+ 2
#include <stdio.h>
int main() {
    int num, num2, sum1 = 0;
    scanf("%d",&num);
    for(int i = 0; i < num; i++){
   
    scanf("%d",&num2);
    
       if(num2 % 2 ==0){
           sum1= sum1+num2;
           }
       else{
            continue ;
           }
           }
           printf("%d",sum1);
    return 0;
        }
Now try this code
+ 2
Thank you Jayakrishna sir , thank you pon Balaji sir, I've got it!!!
😇
+ 1
rupali You may not read question properly...
Read again.. It need to find total sum of all even numbers in list. But you are printing as a sequence..
It need only one output total even's sum..
+ 1
rupali thank you
0
rupali , post in your question the whole description of the task, so someone can help you.
0
You're welcome.. rupali






