C Programming Practical
C Programming Practical
PROGRAM 1
#include <stdio.h>
int main() {
int number;
scanf("%d", &number);
if (number % 2 == 0) {
} else {
return 0;
}
Program 2
Develop a C Program that defines two integer variables (num1, and num 2), assign values to them ,
and perform the following operations
Coding
#include <stdio.h>
int main() {
int num2 = 5;
return 0;
}
OUTPUT
PROGRAM 3
Create a program that checks weather a given year is a leap year. Take the year as input and print
a message indicating weather it is a leap year or not .
#include <stdio.h>
int main() {
int year;
// Input
scanf("%d", &year);
} else {
return 0;
}
OUTPUT
PROGRAM 4
Write a C program that takes two numbers as input and prints the maximum of the two.
#include <stdio.h>
int main() {
// Input
} else {
return 0;
}
OUTPUT
PROGAM 5
Develop a program that takes a person's age as input and prints their age category:
• 0-12: Child
• 13-17: Teenager
• 18-59: Adult
• 60 and above: Senior Citizen
CODING
#include <stdio.h>
int main() {
int age;
// Input
scanf("%d", &age);
printf("Category: Child\n");
printf("Category: Teenager\n");
printf("Category: Adult\n");
} else {
printf("Category: Senior Citizen\n");
return 0;
OUTPUT
PROGRAM 6
Write a C program that takes a number (1 to 5) as input and prints the corresponding day of
the week.
#include <stdio.h>
int main() {
int day;
scanf("%d", &day);
switch (day) {
case 1:
printf("Sunday\n");
break;
case 2:
printf("Monday\n");
break;
case 3:
printf("Tuesday\n");
break;
case 4:
printf("Wednesday\n");
break;
case 5:
printf("Thursday\n");
break;
case 6:
printf("Friday\n");
break;
case 7:
printf("Saturday\n");
break;
default:
return 0;
OUTPUT
PROGRAM 7
Create a C program that takes a non-negative integer as input and calculates its factorial
using a do-while loop.
#include <stdio.h>
int main() {
int n, factorial = 1, i = 1;
// Input
scanf("%d", &n);
do {
factorial *= i;
i++;
return 0;
}
OUTPUT
PROGRAM 8
#include <stdio.h>
int main() {
scanf("%d", &rows);
scanf("%d", &cols);
// Declare matrices
scanf("%d", &matrix1[i][j]);
}
scanf("%d", &matrix2[i][j]);
printf("%d\t", sum[i][j]);
printf("\n");
return
};
OUTPUT