Docsity

C Program to Perform Basic Arithmetic Operations and Check Number Properties, Lecture notes of Programming for Engineers

Toggle sidebar
bg1
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main()
5 {
6 int a,b,c;
7 printf("enter first number\n");
8 scanf("%d",&a);
9
10 printf("\n enter second number\n");
11 scanf("%d",&b);
12
13 printf("\n sum of your numbers is =%d \n",a+b);
14 printf("\n difference of your numbers is =%d \n",a-b);
15 printf("\n product of your numbers is =%d \n",a*b);
16 printf("\n division of your numbers is =%d \n",a/b);
17
18
19 if(a>100)
20 printf("\n your firts number is greater than 100 \n");
21 else if(a<100)
22 printf("\n your first number is smaller than 100 \n");
23 else
24 printf("\n your first number is equal to 100 \n");
25
26
27 if(a%2==0)
28 printf("\n your first number is even \n");
29 else
30 printf("\n your first number is odd \n");
31
32 if(b>100)
33 printf("\n your second number is greater than 100 \n");
34 else if(b<100)
35 printf("\n your second number is less than 100 \n");
36 else
37 printf("\n your second number is equal to 100 \n");
38
39 if(b%2==0)
40 printf("\n your second number is even \n");
41 else
42 printf("\n your second number is odd \n");
43
44 printf("\n thanks for your time \n");
45 printf("\n Please! give us rating \n");
46 scanf("%d",&c);
47 printf("\n thanks for your rating =%d \n",c);
48
49
50
51 return 0;
52 }

Partial preview of the text

Download C Program to Perform Basic Arithmetic Operations and Check Number Properties and more Lecture notes Programming for Engineers in PDF only on Docsity!

1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 int a,b,c; 7 printf("enter first number\n"); 8 scanf("%d",&a); 9 10 printf("\n enter second number\n"); 11 scanf("%d",&b); 12 13 printf("\n sum of your numbers is =%d \n",a+b); 14 printf("\n difference of your numbers is =%d \n",a-b); 15 printf("\n product of your numbers is =%d \n",a*b); 16 printf("\n division of your numbers is =%d \n",a/b); 17 18 19 if (a>100) 20 printf("\n your firts number is greater than 100 \n"); 21 else if (a<100) 22 printf("\n your first number is smaller than 100 \n"); 23 else 24 printf("\n your first number is equal to 100 \n"); 25 26 27 if (a%2==0) 28 printf("\n your first number is even \n"); 29 else 30 printf("\n your first number is odd \n"); 31 32 if (b>100) 33 printf("\n your second number is greater than 100 \n"); 34 else if (b<100) 35 printf("\n your second number is less than 100 \n"); 36 else 37 printf("\n your second number is equal to 100 \n"); 38 39 if (b%2==0) 40 printf("\n your second number is even \n"); 41 else 42 printf("\n your second number is odd \n"); 43 44 printf("\n thanks for your time \n"); 45 printf("\n Please! give us rating \n"); 46 scanf("%d",&c); 47 printf("\n thanks for your rating =%d \n",c); 48 49 50 51 return 0; 52 }