You are on page 1of 15

End Exam Question bank

1. operators
2. algorithm and flowchart
3. Variables
4. loops
5. control structures
6. functions
7. recursion pointers and structures and unions
8 . strings
9. arrays

operators
1. Write a c program to Develop a calculator to convert temperature from Fahrenheit
to Celcius and vise versa { }

2. Write a c program to Calculate simple interest for various parameters specified by


the user { }

3. Write a c program to Calculate compound interest for various parameters


specified by the user { }

4. Write a c program To enter marks of five subjects and calculate total, average and
percentage. { }

5. Write a c program to Calculate the net salary of the employee given basic,da,hra,pf
and lic { }

6. Write a c program to Retrieve the remainder after the division of two numbers
without using mod operator { }

7. Write a c program to Convert an upper-case character to a lower-case character. {


}

8. Write a c program to Enter two angles of a triangle and find the third angle. { }

9. Write a c program to check a number's Least Significant Bit (LSB). { }

10. Write a c program to Input any number from the user and check whether the nth
bit of the given number is set (1) or not (0)(hint: Use bitwise operators) { }
11. Write a c program to add two numbers without using the addition operator.{ }

12. Write a c program to subtract two numbers without using the subtraction
operator.{ }

13. Write a c program to find the largest among three numbers using conditional
operator{ }

Algorithm and flowchart

loops
1. Find the factorial of a number { }

2. Check whether the number is a palindrome or not { }

3. Convert a decimal number to a binary number { }

4. Calculate the greatest common divisor of two numbers { }

5. Generate the first n numbers in the Fibonacci series { }

6. Generate n prime numbers { }

7. Write a c program to check given number is a perfect number or not. { }

8. Write a c program to check given number is Armstrong's number or not. { }

9. Write a c program to check given number is a prime number or not. { }

10. Write a c program to check given number is a strong number or not. { }


Programs on Variables

1.Declare a variable 'C' of integer type . Assign the value 12 to it, with the help of scanf at
the run time and store the integer value of C variable in floating type variable 'B' . Display
the output of the variable B
Testcase 1:
Input:12
Output:12.000000

Testcase 2:
Input:14
Output:14.000000

2.Declare a variable A and store any number in between 97 to 105 in that variable at the
run time using scanf . You need to get the related character of that ASCII number
Testcase 1:
Input :97
Output:a
Testcase 2:
Input:98
Output:b

3.Declare a variable A and store any integer value in it by using scanf.


perform pre increment of variable A and store the result of it, in a new variable B
Print the outputs of A and B respectively
Testcase 1:
Input : 6
Output: 7
7
Testcase 2:
Input: 7
Output: 8
8
4.Declare a variable X and assign any Integer value by using the assignment operator
with the help of scanf to Variable X.
Declare one more variable Y and store the result X+2 in it. Display the output of X and Y

Testcase:
Input : 3
Output: 3
5
5.Declare a variable S , take the value at the run time for the variable S.
if S value is greater than 18, print "C is very easy" otherwise print " C is beautiful
subject.
Testcase 1:
Input:10
Output: C is beautiful subject
Testcase 2:
Input: 20
Output: C is very easy

6.Print "GITAM" upto N times using for loop


Testcase 1:
Input:1
Output: GITAM
Testcase 2:
Input:2
Output: GITAM
GITAM
7. C program to Check whether a given number is even or odd
Input:20
Output: even
Testcase 2:
Input:15
Output: odd

8.Declare a variable A and store any integer value in it by using scanf.


perform post decrement of variable A and store the result of it, in a new variable B
Print the outputs of A and B respectively
Testcase 1:
Input: 5
Ouput: 4
5
Testcase 2:
Input:6
Output: 5
6
9. Declare one Integer variable X , assign the value at the run time for X.
Take one more integer variable Y . Assign the value of X to Y. Compare if the value of the
variable Y is equal to 10 , then print the statement “ We study Daily “ or if it is not equal ,
print the statement “We love India”

Testcase 1:
Input: 10
Output:We study Daily
Testcase 2:
Input:9
Output:We love India

10.C program to convert upper-case character to a lower-case character


Testcase
Input: A
Output: a
2.Declare three variables A,length,breadth (of all integer type) . Take the values of length
and breadth at the run time using scanf.
Store the area of Rectangle in A and display the output of three variables
Testcase 1:
Input: 2
3
Output:2
3
6

Testcase 2:
Input : 3
4
Output: 3
4
12
11.C Program to print the factorial of a number( Declare one variable N in the program,
calculate the factorial and display the factorial of that number)

Testcase 1:
Input : 5
Output: 120

Testcase 2:
Input: 6
Output : 720

12.C Program to print even numbers from 10 to N( N is the variable , which specifies the
limit)

Testcase 1:
Input: 16
Output : 10
12
14
16
20

13.Declare a variable N , assign the value at the run time using scanf. Check whether the
value of that variable is divisible by 2 and 4
Testcase 1:
Input :8
Output : Yes, it is divisible by both 2 and 4

Testcase 2:
Input : 5
Output: No

14.Declare two integer variables x and y . Assign the values at the run time . Take one
temporary variable " temp" . By using that temp variable, swap the values of both a and
b.
Testcase 1:
Input : 3
5
Output:5
3
Testcase 2:
Input: 4
6
Output: 6
4
15.Declare two variables A and b of integer data type and assign the values to it at the
runtime. Swap the values of A to b and b to A without using temporary Variable
Testcase 1:
Input : 3
5
Output:5
3
Testcase 2:
Input: 4
6
16.Declare two variables a and b of integer datatype, Accept those values from the user
at the run time. store addition of two variable values in another variable c . if the value of
c is greater than or equal to 18 .print" eligible for voting" otherwise "Not eligible"

Testcase 1:
Input: 10
9
Output: eligible for voting
Testcase 2:
Input :3
4
Output: Not eligible

17.Declare a variable A of integer type and store the value in it by using scanf.find the
factorial of that value stored in the variable A , store the value of factorial in another
variable Y and display the value of Y

Testcase 1:
Input: 5
Output:Y=120
Testcase 2:
Input:6
Output:Y=720

18.Declare a integer variable "number" , if that number is equal to 10 , print" number is


equals to 10"
if the number is equals to 50 print " number is equals to 50" if the number is equals to
100 print "number is equals to 100"
otherwise print "number is not equal to 10, 50 or 100"
Testcase 1:
Input:10
Output: number equals to 10
Testcase 2:
Input: 50
Output: number equal to 50

19.Declare a variable 'a' of integer value , assign the value using scanf.
1. check whether the value of variable is divisible by 5 and 8 , if yes print "divisible by
both 5 and 8"
2. if the variable value is divisible by 5 only , then print "divisible by 5"
3.if the variable value is divisible by 8 only , then print "divisible by 8"
4. If it is not divisible by both 5 and 8 , then print "divisible by none"
Testcase 1:
Input : 40
Output: Divisible by both 5 and 8

Testcase 2:
Input:8
Output: Divisible by 8

20.Write a C Program to print sum of n numbers( declare n variable of integer datatype)


Testcase 1:
Input: 3
Output:6
Testcase 2:
Input:5
Output:15

21.C program to check entered character is a vowel or a consonant . (Declare a character


datatype c and check that value whether it is the vowel or not)

Testcase 1:
Input: a
Output:Vowel
Testcase 2:
Input: b
Output:consonant

22.Declare 4 variables a,b,c,d of integer datatype. Accept the values of c and d at the
runtime .calculate a=c+d and b=c-d.
if a is greater than 18 ,print GITAM or else print INDIA and print the value of b
Testcase 1:
Input: 10
9
Output: GITAM
1
Testcase 2:
Input: 11
12
Output: GITAM
-1

23.Declare one variable A and perform pre increment of that variable and store it in
another variable b. check whether b is a palindrome number or not
Testcase 1:
Input:120
Output: Palindrome Number
Testcase 2:
Input :238
Output: Not a Palindrome number

24.Declare three variables a,,b,c . take the values of b and c at the run time . calculate
a=b+c . Consider the first angle of the triangle as a and second angle of the traingle as c
and calculate the third angle
Testcase 1:
Input: 10
20
Output :140
Testcase 2:
Input :20
50
Output: 90

control structures
1. Check whether the triangle is an equilateral, isosceles, or scalene triangle? { }

2. Check whether the entered year is a leap year or not? { }

3. Find the minimum among three numbers? { }

4. Check whether a number is divisible by 5 and 11 or not? { }

5. Check whether a number is positive, negative, or zero using a switch case? { }

6. Design a calculator that performs arithmetic operations on two numbers using a


switch case? { }

7. Find Roots of a Quadratic Equation? { }

8. Write a C program to check whether a character is an alphabet, digit, or special


character? { }

9. Write a C program to check whether an alphabet is a vowel or consonant? { }


10. Write a C program to calculate profit and loss on a transaction. Test Data:500
700Expected Output: You can book your profit amount: 200. { }

11. Write a C program to check whether an alphabet is a vowel or consonant. { }

12. Write a C program to check whether a character is an alphabet, digit, or special


character. { }

13. Write a C program to check whether the given value can form a triangle for the
angles. { }

14. Write a c program to calculate a student's grade by reading six subject marks? { }

15. Write a C program to accept a person's height in centimeters and categorize them
according to their height (dwarf, average height, tall, abnormal height). { }

Functions

Recursion pointers and structures and unions


1. Write a c program to find the factorial of a number using recursion. { }

2. Write a c program to find the GCD of two numbers using recursion. { }

3. Write a c program to find out the sum digits of a number using recursion. { }

4. Write a c program to find the power of a number using function recursion. { }

5. Write a c program to reverse any number using recursion.{ }

6. Swap two numbers using pointers. { }

7. Performs all the five arithmetic operations using Pointers { }


8. Write a program in C to find the maximum number between two numbers using a
pointer. { }

9. Write a program in C to find the factorial of a given number using pointers. { }

10.Create a structure with the name GITAM and define the data members of the structure
as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is String.
Declare one object/variable ‘E’ to the Structure GITAM .Take the values of the data
members using the object/variable ‘E’ at the run time and display those values of the data
members to the output screen

11.Create a structure with the name GITAM and define the data members of the structure
as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is String.

12.Declare two different objects/variables ‘A’ and ‘B’ to the structure GITAM . Using the
second object/variable,take the values of the data members at the runtime and display
those values of the data members using second object

13.Create a structure with the name GITAM and define the data members of the structure
as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is String.
Declare one object ‘E’ to the Structure GITAM .Take the values of the data members using
the object ‘E’ at the run time. Call the function ’display’ in the main function and the
functionality of display function is to display the values of the data members of the
structure by using E . In the display function, pass the arguments as data members.

14.Create a structure with the name CSE and define the data members of the structure as
a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is String.
Declare one object ‘E’ to the Structure CSE .Take the values of the data members using
the object ‘E’ at the run time. Call the function ’display’ in the main function and the
functionality of display function is to display the values of the data members of the
structure by using E . In the display function, pass the argument as the complete
structure .

15.Create a structure with the tag name CSE and define the data members of the
structure as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is
String.
Declare one object ‘E’ to the Structure CSE .Take the values of the data members using
the object ‘E’ at the run time. Call the function ’display’ in the main function and the
functionality of display function is to display the values of the data members of the
structure by using E . In the display function, pass the argument as the address of the
structure .
16.Create a structure with the tagname ECE and define the data members of the structure
as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is String.
Declare two objects/variables A and B to Structure ECE.Assign the values of the data
members with related to A Object is 1,2.5,”Morraco” at the compile time itself. Pass/Copy
the values of Object A data members to the Object B data members .And display the
values of those data members belonging to Object/Variable B

17.Create a Structure with tag name GITAM and data members are int a , float b and along
with this ,declare one more Structure as a datamember called as CSE . The data
members of the CSE are int c; Assign the values to those data members(using
Objects/variables) using scanf and print those values to the output values. Create G as
an variable/object to the structure GITAM and create C as an variable/object to the
Structure CSE

19.Create a union with the name GITAM and define the data members of the union as
a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is
String.Declare one object/variable ‘E’ to the union GITAM .Take the values of the data
members using the object/variable ‘E’ at the run time and display those values of the data
members to the output screen

20.Create a structure with the name GITAM and define the data members of the structure
as a,b,c.The datatype of a is integer , nature of b is float and the datatype of c is
String.Declare one object/variable ‘E’ to the Structure GITAM . Assign the values as {1} to
the structure by using variable E. Try to print the values of the data members using E
object/variable

Strings
1. Write a c program to convert the string from upper case to lower case. { }

2. Write a c program to convert the string from lower case to upper case. { }

3. Write a c program to delete all consonants from the given string. { }

5. Write a c program to sort the characters of a string.{ }

6. Write a c program to reverse a string { }

7. String concatenation in c without using strcat { }


8. How to compare two strings in c without using strcmp { }

9. String copy without using strcpy in c{ }

10. Convert a string to ASCII in c { }

11. Count the total number of vowels and consonants in a string. { }

12. Reverse the given string without using String handling functions. { }

13. Sort strings in the dictionary order { }

14. check given string is a palindrome string or not { }

Arrays
1. Write a c program for the addition of two matrices. { }

2. Write a c program for the subtraction of two matrices { }

3. Write a c program for the multiplication of two matrices. { }

4. Write a c program to find out the sum of the diagonal elements of a matrix. { }

5. Write a c program to find out the transpose of a matrix. { }

6. Find the minimum element in an array { }

7. Implement linear search. { }

8. Sort an array in descending order. { }

9. Given a two-dimensional array of integers and a row index, return the largest element
in that row. { }

10. Write a program in C to count a total number of duplicate elements in an array. { }

11. Write a program in C to find the second largest element in an array. { }

12. Write a program in C to find the second smallest element in an array. { }

13. Write a program in C to delete an element at desired position from an array. { }


14. Sort an array in ascending order. { }

15. Implement binary search. { }

16. Find the maximum element in an array { }

17.Declare a one dimensional Array A ,which stores 5 integer values .Take the values in
to the array at the run time using scanf() , and display those values stored in that array
by using printf()

18.Write a C Program which accepts your name as an input(take the input by using gets)
in character Array called ECE of size 15 and needs to display your name(display the
output using puts)

19.In C Program, declare a character Array ‘Emp’ of size 10. Accept the input into the
character Array using puts and implement the strlen() on the Character Array ‘Emp’
And store the result of that function in a variable called B .and display the value of B
variable to the output screen.

20.Declare a two dimensional array ‘MID3’ .The size of this array is 2 rows and 2 columns
Need to store all the 4 element values as ‘2’ . Display the values of the Array ‘MID3’ in
Matrix format.

21.In C Program, create two character Arrays of size 10 each with the names ABC and
XYZ.Take the input for the ‘ABC’ character array by using puts and implement strrev() on
‘ABC’ character Array and the output of that function needs to be in ‘XYZ’ Character
Array. Print the value of ‘XYZ’ Character Array using gets().

22.Declare two (2-D arrays) A and B of size 2*2 . Need to store elements 2,2,2,2 in Array A
and in B Array ,store the elements as 3,3,3,3. Perform the Addition of the two Arrays A
and B.Print the result of the Addition in matrix format

23.Declare a one dimensional array CSE of size 6 and pass the elements as
23,54,65,90,45,76 at the runtime. Write the code such that the elements has to be printed
in Ascending order of the Array

24.Create a character Array of size 10 and the name of the character Array is CSE.Need to
store your name in CSE Array . Write the code ,such that it has to find how many vowels
and how many characters are there in your name

25.Declare two dimensional array CSE of size 3*3. Assign the values at the compile time
to the array as {{1,2,3},{4,5,6},{6,7,8}}; The output should be the transpose of the array
,write the code for that
26.Create a two dimensional Array with the your name with size 3*4. Assign the values
to the array by using scanf(). The values you need to assign {{1,2,3,4},{4,2,6,7},{8,7,5,6} at
the run time. Print the values of the Array to the output screen

27. Declare a one dimensional array CSE of size 6 and pass the elements as
23,54,65,21,45,76 at the runtime. Write the code such that the elements has to be printed
in Descending order of the Array

28.Create a character Array of size 10 and the name of the character Array is CSE.Need to
store your name and print the value in the character array in reserve direction without
using strrev() function

29.Create a character Array of size 10 and the name of the character Array is CSE.Need to
store your name . If your name contains Vowels, it needs to print “WELCOME TO INDIA”
else it needs to print “WELCOME TO ENGLAND”.

30.Declare two (2-D arrays) A and B . Need to store elements 2,2,2,2 in Array A and in B
Array ,store the elements as 3,3,3,3. Perform the Multiplication of the two Arrays A and
B. Print the result of the Multiplication in matrix format

31.Declare a one dimensional array CSE of size 6 and pass the elements as
23,54,65,21,45,76 at the runtime. Implement the linear search on this array and the data
item needs to be searched is 21

32.Declare a one dimensional array CSE of size 6 and pass the elements as
23,54,87,21,45,76 at the runtime. Write the code which retrieves the largest element in the
array ‘CSE’

You might also like