0% found this document useful (0 votes)
8 views2 pages

C Language Practical Solutions

The document contains solutions to five practical programming problems in C language. These include calculating the sum of two numbers, the area of a circle, determining if a number is even or odd, finding the greatest of three numbers, and displaying the multiplication table of a number. Each solution is provided with code snippets and basic input/output instructions.
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)
8 views2 pages

C Language Practical Solutions

The document contains solutions to five practical programming problems in C language. These include calculating the sum of two numbers, the area of a circle, determining if a number is even or odd, finding the greatest of three numbers, and displaying the multiplication table of a number. Each solution is provided with code snippets and basic input/output instructions.
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

Solved Computer Science Practical Paper (C Language)

Q1: Write a program to calculate the 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 = %d\n", sum);
return 0;
}

Q2: Write a program to calculate the area of a circle.


#include <stdio.h>
#define PI 3.1416
int main() {
float radius, area;
printf("Enter radius: ");
scanf("%f", &radius);
area = PI * radius * radius;
printf("Area of circle = %.2f\n", area);
return 0;
}

Q3: Write a program to find whether a number is even or odd.


#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0)
printf("Even number\n");
else
printf("Odd number\n");
return 0;
}

Q4: Write a program to find the greatest of three numbers.


#include <stdio.h>
int main() {
int a, b, c;
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);

if (a >= b && a >= c)


printf("Greatest number = %d\n", a);
else if (b >= a && b >= c)
printf("Greatest number = %d\n", b);
else
printf("Greatest number = %d\n", c);

return 0;
}

Q5: Write a program to display the multiplication table of any number.


#include <stdio.h>
int main() {
int num, i;
printf("Enter a number: ");
scanf("%d", &num);

for (i = 1; i <= 10; i++) {


printf("%d x %d = %d\n", num, i, num * i);
}
return 0;
}

You might also like