C program to find sum of odd integers and even integers within 100
Answers
Answered by
0
Answer:
#include <stdio.h>
#include <conio.h>
void main()
{
int i, N=100, oddSum = 0, evenSum = 0;
clrscr();
for (i=1; i <=N; i++)
{
if (i % 2 == 0)
evenSum = evenSum + i;
else
oddSum = oddSum + i;
}
printf ("Sum of all odd numbers = %d\n", oddSum);
printf ("Sum of all even numbers = %d\n", evenSum);
}
Similar questions
English,
6 months ago
Social Sciences,
6 months ago
English,
6 months ago
Psychology,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago