Full width home advertisement

HTML

Tech News

Ad

 Write a cprogram to find the sum of first 100 odd numbers and even numbers



#include<stdio.h>
#include<conio.h>

void main()
{
	int i=0,odd=0,even=0;
	clrscr();

	while(i<=100){
	if(i%2==0){even=even+i;}
	else{odd=odd+i;}
	i++;
	}
	printf("Sum of odd numbers: %d",odd);
	printf("\nSum of even numbers: %d",even);
	getch();
}

thank you for visiting seeya again

No comments:

Post a Comment

Bottom Ad [Post Page]