Posted by: pinakinayak on: 15/12/2008
‘C’ Probable Questions for Sem-end:
SIMPLE PROGRAMS:
1. Write a program that accept two integer numbers from user, and print their values in exchange form without using third variable.
2. Write a program to calculate total distance traveled by a vehicle in t seconds, distance = ut + (at^2)/2, Where ‘u’ is initial velocity, ‘a’ is acceleration & t is time period.
IF-ELSE & SWITCH-CASE:
1. Write a program that accept a character from user, and check whether the character is a special character or not.
2. Write a program that accepts three alphabets from user in same case, and print those three alphabets in a form that second one as the successor of first one and 3rd the successor of 2nd one.
3. Write a program that accept three numbers from user, and print the largest number between them, without using if-else.
4. Write a program that accept three numbers from user, and print the greatest number by using macro substitution.
5. Write a program that accept student roll no and 3 subject marks. Calculate the total & average marks and print the grade of that student if average is greater then 50 and grade as (‘O’ for >=90, 90>’E’>=80,80>‘A’>=70,70>’B’>=60,60>’C’>=50,70>’B’>=60), using switch-case.
6. Write a program that accept year from user, and check whether the entered year is leap year or not.
7. Write a program that continues accepting integers from user until a negative number is entered.(using goto).
8. Write a program to print a series of number from 1 to 100 without using any looping statements.
LOOPs(Do-while,While& For loops):
1. Print ibonacci series: 0,1,1,2,3,5,8,13, …20 elements.
2. Wap to generate the first ‘n’ terms of Fibonacci series.
3. Print Lucas series: 1,3,4,7,11,18,29 …20 elements.
4. Print series: 1,2,2,3,4,6,9,14,22 20 elements.
5. Print series:0, 1,2,4,6,10,12,16,18,22… 20 elements.
6. Print series: 1,2,4,7,11,16,22,29,37upto20 elements.
7. Wap to calculate the following sum.
8. sum=1-x2/2! + x4/4!-x6/6!+x8/8!-x10/10!
9. Print the prime series between a starting number & an end number.
10. Print the Armstrong numbers from 1 to 1000.
11. Input a number and display all the factors of the number.
12. Input a number and display the factorial of the number (while loop).
13. Input a number and display the sum of the digits of a positive no.
14. Input a number and display the sum of the digits of a number till the result is a single digit.
15. Input a number and display the reverse of the given number.
16. Input a number and check if the number is ‘palindrome’ or not.
17. Input a number and check if the number is a Prefect number or not.
18. Write a program that accept one by one character from user and print its ASCII code until the Esc key (ASCII code=27) is pressed.
19. Input a starting no and an end no. Display the multiplication table from the starting no to the end no, upto 10 terms each.
20. Write a program that accept two numbers from user and find their addition, subtraction, multiplication and division according to the user choice and then continue the process until user choice becomes true or ‘yes’.
21. Wap for given capital ‘C’, rate of interest ‘r’ and no. of years ‘n’ to compute the sum with compound interest for n=1,2,3, …….,5
22. Write a program that accept a binary number from user and convert it into decimal number.
23. Write a program that accept a decimal number from user and convert it into binary number.
24. Write a program that computes LCM & GCD of two given integers.
25. Input numbers till the number is not equal to ‘0’. Add all these numbers accepted.
26. Wap to generate the pyramid of numbers upto height ‘h’. (Input ‘h’).
Arrays: (Single dimension)
1. Input any 10 no.s in an array and find the max, min, 2nd max & 2nd min out of the array.
2. Input any 10 no.s in an array and reverse the order of the array, without using another array.
3. Enter a name and print the initials of the name.
4. Input any 10 no.s in an array. Store the reverse of all the no.s of the of the array in another array.
5. Input any 10 no.s in an array and a searching number. Find the locations and no. of occurrences of the no present in the array.
6. Input any 10 no.s in an array and sort the array in ascending order (Bubble sort).
7. Input any 10 no.s in an array, including odd & even no.s. Store all the odd nos, then all the even no.s from the 1st array to a 2nd array.
8. Wap to input ‘n’ numbers in an array. Check all numbers for prime no. Store all primary numbers in one array and non-prime numbers in another array
ARRAYS: (2-dimension)
1. Find the Addition & subtraction of two matrices, using function
2. Wap to input elements into two 3*3 matrices. Perform the matrix multiplication with proper error checking in a 3rd matrix.
3. Wap to input elements into a 3*3 matrix. Display the transpose of the matrix.
4. Wap to check if the given matrix of 3*3 is symmetric or not.
5. Wap to input elements into a 3*3 matrix. Find the sum of the diagonal elements of the matrix.
6. Wap to input elements into a 3*3 matrix and find maximum values from each row and columns of the matrix.
7. Input ‘m’ subject marks for ‘n’ students in a 2-d array. Calculate the grand total secured by each student.
STRINGS: (Character array)
1. Wap to find the length of a given string explicitly.
2. Find the longest word and its length in a given text.
3. Wap to copy & reverse a given string explicitly.
4. Wap to check if a input string is ‘palindrome’ or not.
5. Wap to delete vowels form a given string.
6. Input two strings and merge the two strings in another string explicitly.
7. Input two strings and compare the two strings for equality. If not equal find the difference of the unequal characters explicitly.
8. Wap to get a substring of specified length from a given string from a starting position.
9. Wap to read a string and rewrite it in the alphabetical order.
10. Wap to sort of names of ‘n’ customers.
11. Wap to accept number of strings in a array and store reverse of all these strings in another array.
12. Wap to search a pattern in a string.
13. Wap to count the lines, words and characters in a given text.
Functions: (f)
5.Using function find roots of quadratic equation: ax2 + bx + c=0
Recursive functions: (rf)
1. Wap to find the factorial of a number, using recursive function.
2. Find the GCD of two given numbers.
3. To solve Tower of Hanoi problem.
4. Sum of the digits of a number, using recursion.
5. Wap to find Xn, using recursive function, for a given values of ‘X’ & integer ‘n’.
6. Find the sum of ‘n’ Fibonacci numbers.
7. To find the largest element of a array.
POINTERS:
DYNAMIC MEMORY ALLOCATION:
1. Wap to convert a string to alternate case using a function altcase( ), using pointers and dynamic memory allocation methods.
STRUCTURES:
1. Wap to create a database for ‘n’ students and then find the total & avg marks for each student.
2. Wap to create a student database (roll,name,sub1, sub2, sub3, total) for ‘n’ students using structures. Display the details of the student securing highest & 2nd highest totals.
3. Wap to accept the following elements to a structure and print the total & average. Use a function which will return the structure. Structure elements are Regno, mark1, mark2, mark3, total, average.
FILES:
1. Wap which copies one file to another.
2. Wap to count the no of characters in a file.
3. Wap to merge contents of two files into another.
4. Wap to input integer numbers into a file and store the even numbers from the file to a file ‘even’ and odd numbers to the file ‘odd’.
5. Wap to open a file named “profile.txt” and write all your details in it by reading the text from the keyboard.
6. Wap to reverse the first ‘n’ characters in a file.( File name and ‘n’ are specified on the command line).
7. Wap to remove the comment lines, i.e. text with // and /* … */ from an input ‘c’ file. Use command line arguments.
8. Wap to delete all the vowels from a input file.
‘C’ CONCEPTS / THEORY:
1. What is a function prototype? Explain briefly the need for a function prototype with examples.
2. What is a pointer variable. Explain its advantages.
3. What is a pointer to pointer or a double pointer? Explain with examples.
4. What is the difference between structure & union?
5. Explain initializing elements of a structure variable with an example.
6. How does the template relate to a structure.
7. What is self-referencing structure?
8. Explain briefly bit-wise operators.
9. Explain the concept of recursive function with examples.
10. Is an iterative solution better to a recursive function.
11. Explain briefly the different types of storage classes, i.e, auto, static, extern & register.
12. Explain the use of ‘typedef’ with an example.
13. Define the use of Dynamic memory allocation, by taking examples.
14. Give the full syntax of malloc(),calloc() & free(). In which header file these functions are defined.
15. What are the different ways of accessing a file is known and which file access is possible in ’c’ Prog.
16. Define structure pointer as an argument to a function.
17. What is a file? How many files are there in ‘C’.
18. Define the different function categories with examples.
19. Define the command-line arguments, argC & argV.
20. Give an example of command-line arguments in a file.