Answer to Question #243866 in C++ for xtian

Question #243866

 LOOP: (TURBOc++)


PRG14. Write a program that will accept 10 numbers, identify if the number is odd or even, then finds the sum of all odd numbers, all even numbers, and total of all the numbers entered.

 


PLEASE USE:

#include<stdio.h>

#include<conio.h>


scanf

printf

 


example:

#include<stdio.h>

#include<conio.h>

main()

{

int n=1, x=20;

clrscr();

printf("While Loop Example");


while (n<=5)

{

gotoxy(x, 3);printf(" %d", n);

n++;x=x+5;

}

getch();

}


1
Expert's answer
2021-09-30T00:57:22-0400
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()
{
    int i, x; 
    int oddSum=0,evenSum=0;
    printf("Enter the ten numbers:\n");
    for(i=0; i<10; i++){
    scanf("%d",&x);
        if(x%2==0)
            evenSum=evenSum+x;
        else
            oddSum=oddSum+x;


    }
    printf("Sum of all odd numbers are: %d",oddSum);
    printf("\nSum of all even numbers are: %d",evenSum);
    int total=
    printf("\nSum of all entered numbers are:%d",oddSum+evenSum);
    getch();
    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