- Get link
- X
- Other Apps
1. C Program to Print Hello World
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
2. C Program to Add Two Numbers
#include <stdio.h>
int main() {
int a, b, sum;
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
3. C Program to Subtract, Multiply, and Divide Two Numbers
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("Subtraction = %d\n", a - b);
printf("Multiplication = %d\n", a * b);
printf("Division = %d", a / b);
return 0;
}
4. C Program to Check Even or Odd
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 2 == 0)
printf("Even Number");
else
printf("Odd Number");
return 0;
}
5. C Program to Check Positive, Negative, or Zero
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n > 0)
printf("Positive Number");
else if (n < 0)
printf("Negative Number");
else
printf("Zero");
return 0;
}
6. C Program to Calculate Total Marks and Percentage
#include <stdio.h>
int main() {
int m1, m2, m3, total;
float percentage;
scanf("%d %d %d", &m1, &m2, &m3);
total = m1 + m2 + m3;
percentage = total / 3.0;
printf("Total = %d\n", total);
printf("Percentage = %.2f", percentage);
return 0;
}
7. C Program to Calculate Area of Rectangle or Circle
#include <stdio.h>
int main() {
float l, b, r;
scanf("%f %f", &l, &b);
printf("Area of Rectangle = %.2f\n", l * b);
scanf("%f", &r);
printf("Area of Circle = %.2f", 3.14 * r * r);
return 0;
}
8. C Program to Calculate Simple Interest
#include <stdio.h>
int main() {
float p, t, r, si;
scanf("%f %f %f", &p, &t, &r);
si = (p * t * r) / 100;
printf("Simple Interest = %.2f", si);
return 0;
}
9. C Program to Find the Largest Number Between Two Numbers
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
if (a > b)
printf("Largest = %d", a);
else
printf("Largest = %d", b);
return 0;
}
10. C Program to Find the Largest Number Among Three Numbers
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c)
printf("Largest = %d", a);
else if (b > c)
printf("Largest = %d", b);
else
printf("Largest = %d", c);
return 0;
}
11. C Program to Display ASCII Value of a Character
#include <stdio.h>
int main() {
char ch;
scanf("%c", &ch);
printf("ASCII value = %d", ch);
return 0;
}
12. C Program to Convert Celsius to Fahrenheit
#include <stdio.h>
int main() {
float c, f;
scanf("%f", &c);
f = (c * 9 / 5) + 32;
printf("Fahrenheit = %.2f", f);
return 0;
}
13. C Program to Swap Two Numbers Using Third Variable
#include <stdio.h>
int main() {
int a, b, temp;
scanf("%d %d", &a, &b);
temp = a;
a = b;
b = temp;
printf("a = %d, b = %d", a, b);
return 0;
}
14. C Program to Swap Two Numbers Without Using Third Variable
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("a = %d, b = %d", a, b);
return 0;
}
✅ Exam Tip
-
Always write
#include <stdio.h> -
Don’t forget
return 0; -
Keep syntax clean → full marks guaranteed
- Get link
- X
- Other Apps
Comments
Post a Comment