Answers for "3) write a c program that reads 10 integer numbers from the user, and then the program should calculate the sum of the odd numbers, and the sum of the even numbers. pointer"

C
0

C program to calculate the sum of odd and even numbers

#include <stdio.h>void main(){int i, number, odd_sum = 0, even_sum = 0;printf("Enter the value of number\n");scanf("%d", &number);for (i = 1; i <= number; i++){if (i % 2 == 0)even_sum = even_sum + i;elseodd_sum = odd_sum + i;}printf("Sum of all odd numbers = %d\n", odd_sum);printf("Sum of all even numbers = %d\n", even_sum);}
Posted by: Guest on July-08-2021

Code answers related to "3) write a c program that reads 10 integer numbers from the user, and then the program should calculate the sum of the odd numbers, and the sum of the even numbers. pointer"

Code answers related to "C"

Browse Popular Code Answers by Language