0% found this document useful (0 votes)
25 views

Questions SET

Uploaded by

Shivam Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Questions SET

Uploaded by

Shivam Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Write a C program to find the average of n numbers using arrays and loop.

Take number
of elements (n) from the user. For example: If array = {2, 3, 5, 6} then average is
(2+3+5+6)/4 = 4. Here n is equal to 4.
2. Write a C program to find the minimum element of an array with n elements. Take
number of elements (n) and elements of array from keyboard. For example: If array =
{5, 3, 2, 6} then minimum element is 2. Also, display the index position of minimum
element in the array.
3. Write a C program to find the maximum element of an array with n elements. Take
number of elements (n) and elements of array from keyboard. For example: If array =
{5, 3, 2, 6} then maximum element is 6. Also, display the index position of maximum
element in the array.
4. Write a C program to input elements in array from user and count even and odd
elements in array with n elements. Also, take number of elements (n) from user. For
example: If array = {5, 4, 3, 2, 6} then number of even and odd elements is 3 and 2,
respectively.
5. Write a C program to sort an array in ascending order. For example: If array = {5, 4, 3,
2, 6} then sorted array = 2, 3, 4, 5, 6}.
6. Write a C program to sort an array in descending order. For example: If array = {5, 4,
3, 2, 6} then sorted array = 6, 5, 4, 3, 2}.
7. Write a C program to input elements in array and put even and odd elements in separate
array. Take number of elements (n) from the user. For example: If array = {5, 4, 3, 2,
6} then odd and even arrays are {5, 3} and {4, 2, 6}, respectively.
8. Write a C program to read elements in a matrix and find the sum of main diagonal
(major diagonal) elements of matrix. For example: if matrix = {{2, 5, 3}, {7, 1, 6}, {8,
9, 4}} then sum of major diagonal is (2+1+4 = 7).
9. Write a C program to read elements in a matrix and find the sum of minor diagonal
(opposite diagonal) elements. For example: if matrix = {{2, 5, 3}, {7, 1, 6}, {8, 9, 4}}
then sum of minor diagonal is (3+1+8 = 12).
10. Write a C program to read elements in a matrix and find the sum of elements of each
row of matrix. For example: if matrix = {{2, 5, 3}, {7, 1, 6}, {8, 9, 4}} then sum of 1st,
2nd and 3rd rows are (2+5+3 = 10), (7+1+6 = 14) and (8+9+4 = 21), respectively.
11. Write a C program to read elements in a matrix and find the sum of elements of each
columns of matrix. For example: if matrix = {{2, 5, 3}, {7, 1, 6}, {8, 9, 4}} then sum
of 1st, 2nd and 3rd rows are (2+7+8 = 17), (5+1+9 = 15) and (3+6+4 = 13), respectively.
12. Write a C program to read elements in a matrix and find transpose of the given matrix.
13. For example: if matrix = {{2, 5, 3}, {7, 1, 6}, {8, 9, 4}} then transpose of matrix = {{2,
7, 8}, {5, 1, 9}, {3, 6, 4}}.
14. What is a function? Why we use functions in C language? Give an example.
15. Distinguish between Library functions and User defined functions in C and Explain
with examples.
16. Explain the various categories of user defined functions in C with examples?
17. Explain the Parameter Passing Mechanisms in C-Language with examples.
18. Write a program to find factorial of a number using recursion.
19. Write a program to calculate GCD of two numbers using recursion.
20. Write a program to generate Fibonacci series using recursive functions.
21. What are different types of storage classes in C? Differentiate them using suitable
examples.
22. What is pointer in c programming? What are its benefits?
23. Write a C program for exchanging of two numbers using call by reference mechanism.
24. Explain in detail how to access a one dimensional array using pointers with an example
program?
25. Write a C Program to convert binary number to octal by using a user-defined function.
26. Write a C program to define a function which returns multiplication of digits of a
number. Take number from the user. For example: If number taken from user is 234
then result is (2*3*4 = 24).
27. Write a C Program to convert binary number to decimal by using a user-defined
function.
28. Write a program to find sum of digits of a number using function recursion.
29. Write a C Program to delete duplicate elements from an array with n elements. Take
number of elements (n) and elements from user. For example: If array = {2, 5, 2, 3, 2,
3} then resultant array = (2, 5, 3).
30. Write a C program to pass an array containing age of person to a function. This function
should find average age and display the average age in main function.
31. Write a python program to print the following pattern using nested for loop:
1
123
12345
1234567
32. Write C program using nested loop to print the following pattern. Also, discuss about
the difference between break and continue using a suitable example.

33. Write a python program to define a function which accepts two numbers (integers) to
be passed while calling the function and returns the greatest common divisor (GCD) of
these two integers. Take both the numbers as input given by user. For example: GCD
of 15 and 20 is 5.

34. Write a C program to print the following pattern.

5
45
345
2345
12345
35. Write a C program to print the following pattern.
1
21
321
4321
54321

36. Explain how passing an array to a function in C differs from passing a pointer to an
array as a function parameter. What are the advantages of using pointers in function
parameters when dealing with arrays?
37. Explain the concept of pointer arithmetic with respect to arrays in C. How does
incrementing or decrementing a pointer relate to the size of the data type it points to?
38. Explain the difference between function call by value and call by reference with a
suitable example.
39. What is the significance of the name of a string?
40. WAP to find length of string, copy one string to other, reversing the string etc. without
using pre-defined functions.
41. Create a structure named as employee and take data like Name, age, salary, YOB (year
of birth) and designation. If there are 50 employees then print name and age of all such
employees whose YOB is greater than a specific YOB. Users need to take a specific
YOB as input through keyboard. Next, print all the details of employees whose age is
more than 40 years.
42. What is the difference between reg and auto storage classes? Discuss with suitable
examples.
43. WAT to take string as input and count the number of consonants from the string.
44. What is null character in a string? What is its importance?
45. WAP to search an entered string from an array of strings.

You might also like