C Programming Board Solve PDF
C Programming Board Solve PDF
9. Find the number of and sum of all integers greater than 50 and less than 300 that are
divisible by 9. (11. 08, 07)
10. Prints the largest among three numbers using nested if…else. (15)
13. Test whether a given string is Palindrome or not. (14, 12, 11)
14. Calculate and print first m Fibonacci numbers. (18, 16, 13, 12, 09)
17. Display Real, Imaginary and Equal Root of a Quadratic Equation. (15, 10, 09, 06)
19. Calculate the Factorial of a number using Recursion function. (16, 13, 10, 09, 06)
20. Compute the sum of all elements stored in an integer array using pointer. (17, 08)
21. Calculate the sum and average of a set of n number by using array. (15)
22. Compute the sum of the digits of a given integer number. (09, 08)
23. Set all the diagonal elements of a two-dimensional array to 1 and others to 0. (07,06)
THEOVE46MANIA 1
Programming Board Solves
1. Area& Circumference of a Circle: (17, 12, 11, 09, 07)
#include <stdio.h>
#include<math.h>
int main()
{
float r, area, crcm;
printf(“Enter the Radius: “);
scanf("%f", &r);
area = 3.14 * r * r;
crcm = 2 * 3.14 * r;
printf("Area of the Circle is: %.2f", area);
printf("Circumference of the Circle is: %.2f", crcm);
return 0;
}
THEOVE46MANIA 2
4. Convert Fahrenheit to Celsius: (17, 15, 10, 07)
#include <stdio.h>
int main()
{
float F, C;
printf("Enter the Temperature in Fahrenheit: ");
scanf("%f", &F);
C = (F-32) * 5/9;
printf("%2f F=%2f C", F,C);
return 0;
}
***C/5=(F-32)/9;
***F=(C*9/5)+32;
6. Even-Odd: (13)
#include <stdio.h>
int main()
{
int n;
printf("Enter a number: ");
scanf("%d", &n);
if(n%2==0)
printf("Even number", n);
else
printf("Odd number", n);
return 0;
}
THEOVE46MANIA 3
7. Leap Year: (14)
#include <stdio.h>
int main()
{
int year;
printf(“Enter the Year: “);
scanf("%d", &year);
if((year%400)==0)
printf("Leap Year", year);
else if((year%100)!=0 && year%4==0)
printf("Leap Year", year);
else
printf("Not Leap Year", year);
return 0;
}
9. Find the number & sum of all integers 50<i<800 & divisible by 9:
#include <stdio.h> (11, 08, 07)
int main()
{
int s=0, i;
for(i=51; i<800; i++)
{
if(i%9==0)
printf("\n%d", i);
}
s = s + i;
printf("\n sum is: %d", s);
return 0;
}
THEOVE46MANIA 4
10. Largest among three numbers (using Nested if…else): (15)
#include <stdio.h>
int main()
{
int a, b, c;
printf("Enter three numbers: \n");
scanf("%d %d %d", &a, &b, &c);
if(a>b)
{
if(a>c)
{
printf("%d is largest", a);
}
else
{
printf("%d is largest", c);
}
}
else
{
if(b>c)
{
printf("%d is largest", b);
}
else
{
printf("%d is largest", c);
}
}
return 0;
}
THEOVE46MANIA 5
int marks;
printf("Enter marks: ");
scanf("%d", &marks);
if(marks>=80)
{
printf("A+");
}
else if(marks>=70)
{
printf("A");
}
else if(marks>=60)
{
printf("A-");
}
else if(marks>=50)
{
printf("B");
}
else if(marks>=40)
{
printf("C");
}
else
{
printf("F");
}
return 0;
}
THEOVE46MANIA 6
}
14. Fibonacci Series: (18, 16, 13, 12, 09)
#include <stdio.h>
int main()
{
int x=0, y=1, z, n, i;
printf("How many numbers you want: ");
scanf("%d", &n);
printf("The Fibonacci Numbers: \n");
printf("0 1 ");
for (i=1; i<n-1; i++)
{
printf("%d ", x+y);
z = y;
y = x + y;
x = z;
}
return 0;
}
THEOVE46MANIA 7
}
}
if(p==1)
printf("prime");
else
printf("not prime");
return 0;
}
17. Root of a Quardic Equation: (15, 10, 09, 06)
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c;
float d, x1, x2;
printf("Enter the Value of a, b, c: ");
scanf("%d %d %d", &a, &b, &c);
d=(b*b) - (4*a*c);
if(a == 0)
{
x1 = x2 = -c / b;
printf("Roots are equal\n");
printf("Real roots are: %.2f and %.2f", x1, x2);
}
else if(d > 0)
{
x1 = (-b + sqrt(d)) / (2*a);
x2 = (-b - sqrt(d)) / (2*a);
printf("Roots are equal\n");
printf("Real roots are: %.2f and %.2f", x1, x2);
}
else
{
printf("No Real Roots");
}
return 0;
}
18. Swap/Interchange the value using Bitwise operator: (12)
#include <stdio.h>
int main()
{
int a, b;
printf("Enter two integers: \n");
scanf("%d %d", &a, &b);
printf("Before swapping \n a=%d \n b=%d \n\n", a, b);
a = a^b;
b = b^a;
a = a^b; //using 3 times//
THEOVE46MANIA 8
printf("After swapping \n a=%d \n b=%d", a, b);
return 0;
}
19. Calculate the Factorial of a number using Recursion Function:
#include <stdio.h> (16, 13, 10, 09, 06)
int factor(int n)
{
if(n<=1)
return 1;
else
return(n*factor(n-1));
}
int main()
{
int n, factorial;
printf("Enter a number to find a factorial: ");
scanf("%d", &n);
factorial = factor(n);
printf("Factorial is: %d", factorial);
return 0;
}
20. Using Pointer to compute the sum of all elements stored in an Array
#include <stdio.h>
int main()
{
int *p, a[20], n, i, sum=0;
p=a;
printf("How many data you enter: ");
scanf("%d", &n);
i = 0;
while(i<n)
{
scanf("%d", &*(p+i));
i++;
}
for(i=0; i<=n; i++)
{
sum = sum + *(p+i);
}
printf("%d", sum);
return 0;
}
THEOVE46MANIA 9
printf("Enter the number of elements: ");
scanf("%d", &n);
int a[10][10], i, j;
for(i=0; i<=6; i++)
{
for(j=0; j<=6; j++)
{
if(i==j || i+j==6)
printf("1 ");
else
printf("0 ");
}
printf("\n\n");
}
return 0;
}
THEOVE46MANIA 10
1. Record Student information according to their merit position. (17, 11, 08)
2. Write integer from 1 to 10 and store data into the file name “razu.dat” (17, 08)
3. Find out the GCD (Greatest Common Divisor) of two given integer a, b where
1<a, b<108. (16)
4. Read data from keyboard, write data to file named INPUT. Again, read data
from the file named INPUT and display it on screen. (16, 15, 12)
5. Evaluate the function sinx as defined by the infinite series of expansion. (15)
6. A Recursive function in C to compute value of xn where n is a positive integer
and x has a real value. (15)
7. Using pointer to read in an Array of integer and print it in reverse order. (14)
8. A file named DATA contains some integers number. Write a file C program
which will produce all odd numbers in a file named ODD and all even numbers in
a file named EVEN. (11, 10, 07)
9. Set all the diagonal elements of a two-dimensional array 1 and others to 0. (7,6)
10. Extract a portion of a character string and print the extracted string. Assume
that in characters are extracted, started with nth character. (11)
THEOVE46MANIA 11
Assalamu Alaikum.
THEOVE46MANIA 12