Computer Science, asked by srijana6565, 1 year ago

C program to find sum of odd integers and even integers within 100

Answers

Answered by gurukulamdivya
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