1.
Print Hello World
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Explanation: Prints Hello, World! to the screen.
Sample Output:
Hello, World!
2. Find Sum of Two Numbers
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum is %d\n", sum);
return 0;
}
Explanation: Takes two integers from user and prints their sum.
Sample Output:
Enter two numbers: 5 7
Sum is 12
3. Check Even or Odd
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0) {
printf("%d is even\n", num);
} else {
printf("%d is odd\n", num);
}
return 0;
}
Explanation: Checks if a number is divisible by 2, then prints even or odd.
Sample Output:
Enter a number: 10
10 is even