0% found this document useful (0 votes)
13 views10 pages

CSE Merged

The document contains several C programs demonstrating basic programming concepts like calculating the area and circumference of a circle, finding the average of three numbers, determining if a number is even or odd, calculating the sum of numbers in a series, and finding the largest of four numbers. The programs use logic like if/else statements and for/while loops and cover input/output operations.

Uploaded by

paponk908
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views10 pages

CSE Merged

The document contains several C programs demonstrating basic programming concepts like calculating the area and circumference of a circle, finding the average of three numbers, determining if a number is even or odd, calculating the sum of numbers in a series, and finding the largest of four numbers. The programs use logic like if/else statements and for/while loops and cover input/output operations.

Uploaded by

paponk908
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1 // This is a C program to find the area and circumference of a circle.

2 // Program is executed by 6B-2.


3 #include<stdio.h>
4 int main()
5 {
6 int r;
7 float area, crmf;
8 // Input section.
9 printf("Enter the value of Radius of the circle: ");
10 scanf("%d",&r);
11
12 // Area Calculation.
13 area= 3.1416*r*r;
14
15 /* Circumference Calculation.*/
16 crmf= 2*3.1416*r;
17
18 // Output section.
19 printf("The area is: %.2f", area);
20 printf("The circumference is: %.3f", crmf);
21 return 0;
22 }
23
1 #include <stdio.h>
2
3 int main()
4 {
5 float num1, num2, num3;
6 average;
7
8 printf("Enter the value of num1-");
9 scanf("%f", &num1);
10
11 printf("Enter the value of num2-");
12 scanf("%f", &num2);
13
14 printf("Enter the value of num3-");
15 scanf("%f", &num3);
16
17 average= (num1+num2+num3)%3;
18
19 printf("Average is: % ", average);
20 }
21
1 // Largest number among three numbers.
2
3 #include <stdio.h>
4
5 int main()
6 {
7
8 float a, b, c;
9
10 printf("Please enter 3 numbers:");
11
12 scanf("%f %f %f", &a, &b, &c);
13
14 if(a>=b && a>=c)
15
16 printf("The largest number is %f", a);
17
18 if(b>=a && b>=c)
19
20 printf("The largest number is %f", b);
21
22 if(c>=a && c>=b)
23
24 printf("The largest number is %f", c);
25
26 return 0;
27
28 }
1 // Odd-Even program.
2
3 #include<stdio.h>
4
5
6 int main()
7 {
8 int numb;
9
10 printf("Enter the number: ");
11 scanf("%d", & numb);
12
13 if (numb%2== 0)
14 printf("The number is even.");
15 else
16 printf("The number is odd.");
17
18 getch();
19 return 0;
20 }
21
1 // 1+2+3+........+N=?
2
3 int main()
4 {
5 int i=1, N, sum=0;
6
7 printf("Enter the last number of the series: ");
8 scanf("%d", &N);
9
10 printf("1+2+3+........+ %d= ", N);
11
12 while (i<=N)
13 {
14 sum=sum+i;
15 i=i+1;
16 }
17 printf("%d", sum);
18
19 return 0;
20 }
21
1 // 1+2+3+..........+100=?
2 // Example of for loop.
3
4 #include<stdio.h>
5
6 int main()
7 {
8 int i, sum=0;
9
10 printf("1+2+3+..........+100= ");
11
12 for (i=1; i<=100; i=i+1)
13 {
14 sum= sum+i;
15 }
16 printf("%d", sum);
17 return 0;
18 }
19
1 // This is a program to find the largest number using "Nested if"
statement.
2
3 #include<stdio.h>
4 #include<conio.h>
5 #include<math.h>
6
7 int main()
8 {
9 float m, g, d,f;
10
11 printf("Enter the value of the four numbers: \n");
12 scanf("%f%f%f%f", &m,&g,&d,&f);
13
14 if (m>=g && m>=d && m>=f)
15 printf("The largest number is: %.3f", m);
16
17 if (g>=m && g>=d && m>=f)
18 printf("The largest number is: %.3f", g);
19
20 if (d>=g && d>=m && m>=f)
21 printf("The largest number is: %.3f", d);
22
23 if (f>=g && f>=m && f>=d)
24 printf("The largest number is: %.3f", f);
25
26 return 0;
27 }
28
1 // grade Calculation
2
3 #include<stdio.h>
4 #include <conio.h>
5
6 int main()
7 {
8 int eng, ban, com, phy, chem;
9 float total, percent;
10
11 printf("Enter the marks sequentially: \n");
12 scanf("%d%d%d%d%d", &eng, &ban, &com, &phy, &chem);
13
14 total= eng+ban+com+phy+chem;
15 percent=(total/500)*100;
16
17 printf("Total marks= %.2f\n", total);
18 printf("Percentage= %.2f\n", percent);
19
20 if (percent>=90)
21 {
22 printf("Grade A+");
23 }
24 else if (percent>=80)
25 {
26 printf("Grade A");
27 }
28 else if (percent>=70)
29 {
30 printf("Grade B");
31 }
32 else if (percent>= 60)
33 {
34 printf("Grade C");
35 }
36 else if (percent>= 50)
37 {
38 printf("Grade D");
39 }
40 else if (percent>=40)
41 {
42 printf("Grade E");
43 }
44 else
45 {
46 printf("Grade F");
47 }
48 return 0;
49 }
50
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main()
5 {
6 int array[5], sum=0, i;
7 float avg;
8
9 printf("Enter the value of 5 numbers: \n");
10
11 for(i=0; i<5; i++)
12 {
13 scanf("%d", &array[i]);
14 }
15
16 for (i=0; i<5; i++)
17 {
18 sum= sum + array[i];
19 }
20 avg= sum/5;
21
22 printf("The summation is: %d\n", sum);
23 printf("The average is: %.2f\n", avg);
24 }
25
1 // Sum of array element using pointer.
2
3 #include <stdio.h>
4
5 int main()
6 {
7 int array[5];
8 int i, sum=0;
9 int *ptr;
10
11 printf("Enter array elements(5 integer value):\n");
12
13 for (i=0;i<5; i++)
14 scanf("%d", &array[i]);
15
16 ptr=array;
17
18 for (i=0; i<5; i++)
19 {
20 sum=sum+*ptr;
21 ptr++;
22 }
23 printf("The sum is: %d\n", sum);
24
25 return 0;
26 }
27

You might also like