-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
1HM8.CPP
49 lines (49 loc) · 859 Bytes
/
1HM8.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Program to calculate sum of even and odd numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n,a,y=0,p,u,t;
char e,o,s;
clrscr();
printf("First 100 Natural Numbers Are As Follows:\n");
for (i=1;i<=100;i++)
{
printf("\t%d",i);
}
printf("\n\nPress (E) To Seperate Even Numbers");
printf("\nPress (O) To Seperate Odd Numbers");
printf("\n\nEnter Your Choise: ");
scanf("%c",&e);
if (e==e)
{
for (j=2;j<=100;j=j+2)
printf("\t%d",j);
{
printf("\n\nTo Calculate Sum Of Above Numbers, Press (S): ");
scanf("%s",&s);
if (s==s)
{
for (j=2;j<=100;j=j+2)
y=y+j;
printf("\nThe Sum Of Above Even Numbers Is: %d",y);
}
}
}
else
{
for (j=1;j<=100;j=j+2)
printf("\t%d",j);
{
printf("\n\nTo Calculate Sum Of Above Numbers, Press (S): ");
scanf("%s",&s);
if (s==s)
{
for (j=1;j<=100;j=j+2)
y=y+j;
}
printf("\nThe Sum Of Above Odd Numbers Is: %d",y);
}
}
getch();
}