You are on page 1of 9

*1. Write A Program (WAP) in C to add two number.

*2. WAP in C to calculate simple interest.

3. WAP in C to convert the temperature in Celsius into Fahrenheit.

4. WAP in C to find area, perimeter and volume of a cylinder.

*5. WAP in C to swap two number with using/without using third variable.

6. WAP in C to find the value of x of the equation ax2+bx+c.

7. WAP in C to find the distance between two points (x1, y1) and (x2, y2).

*7. WAP in C to check whether a given number is odd or even and number is entered by user.

8. WAP in C to check whether a given number is BUZZ number or not.

*9. WAP in C to check whether year is leap year or not and year is entered by user.

*10. WAP in C to print the largest number among three number and numbers are entered by user.

*11. WAP in C to calculate the percentage of marks of five subjects of a student and print whether he is failed or passed with
division using nested if-else, where marks are entered by user.

12. There are 3 company, Facebook, Flipkart and TCS. The eligibility criteria of companies are as follows:

Company Eligibility criteria


Facebook Backlog = 0, percentage >= 75, computer programming knowledge >= 2
Flipkart Backlog = 0, percentage >= 75
TCS Backlog = 0

WAP in C to check which companies a student is eligible for.

*13. WAP in C to check whether entered character is consonant or vowel using switch statement.

14. WAP in C to make a simple calculator using switch statement.

*15. WAP in C to show the nesting of switch statement of following table:

Number Character Output

1 R RED

B BLUE

2 R RAT

B BAT

*16. WAP in C to print the table of a given number.

17. WAP in C to calculate a b of given numbers a and b and numbers are entered by user.

18. WAP in C to calculate the factorial of a given number.

19. WAP in C to reverse the digits of a given number.

*20. WAP in C to check whether given number is palindrome number or not.

21. WAP in C to check whether given number is Armstrong number or not.


22. WAP in C to check whether given number is prime number or not.

*23. WAP in C to print the prime numbers between 1 to 50.

24. WAP in C to check whether a number is Fibonacci Number or not.

25. WAP in C to print the sum of Fibonacci series up to nth term.

26. WAP in C to print the sum of series 1-2x+3x2-4x3+……………………………. up to nth term.

*27. WAP in C to find sum of 1/1! + 1/2! + 1/3! + ……….. + 1/n! where n will be entered by user.

28. WAP in C to print the sum of 1/2 + 1/4 +1/8+……………………..

29. WAP in C to find the GCD of two number.

30. WAP in C to print equivalent binary number of given decimal number.

31. WAP in C to print equivalent octal number of given decimal number.

32. WAP in C to print the PASCAL tringle.

33. WAP in C to find the all Pythagorean triplets less than 100.

*34. WAP in C to print the following patterns:

1 * 1 1

2 3 * * 12 21

4 5 6 * * 123 321

7 8 9 0 * * * * * 1234 4321

1234554321

1 1 1 1 2 3 4 5 A
2 2 2 2
33 3 3 16 17 18 19 6 B A
4 4 4
33 3 3 15 24 25 20 7 C B A
2 2 2 2
1 1 1 14 23 22 21 8 D C B A

13 12 11 10 9

1 * * ****
* *
2 3 2 * A * * *
*******
3 4 5 4 3 * A * A * * *
* *
4 5 6 7 6 5 4 * A * A * A * **** *

35. Given a matrix of 2D array of n rows and m columns. Write a C program to print matrix in ZIG-ZAG fashion as shown in figure.
Example:
Input: 123
456
789

Output: 124753689

36. WAP in C to calculate sum of squares of first n even numbers.

*37. WAP in C to accept 50 numbers and print the smallest and largest numbers among them.

38. WAP in C to print the odd position elements of an array and, also calculate their sum, where elements of array are entered by

user.

39. Write a program in C to print the all elements of an array who have value greater than average of elements of same array.
*40. WAP in C to fill third array in ascending order from two sorted arrays.
41. WAP in C to enter an element and find whether this element is in the array.

42. WAP in C to find an element in the array using binary search.

*43. WAP in C to sort the array elements using bubble sort.

44. Write a program in C to print the repeated elements of an array and, count how many times they are repeated.
For example, suppose an array contains following elements:
2 0 7 2 2 0 1 2 0 9 1
Find the output according to following manner (in general).
Element Frequency
2 4
0 3
7 1
1 2
9 1
45. Write a program in C to subtract two matrices.

46. Write a program in C to print the lower triangle elements of a matrix.

47. Write a program in C to print the border elements of a matrix of M x N where M, N > 3.

48.Write a program in C to print the diagonals elements of a matrix and, also calculate the sum of diagonals elements of a matrix.

49.Write a program in C to multiply two matrices.

50. 6 x 6 matrix is entered through the keyboard. Write a program in C to obtain the determinant value of this matrix.
51. WAP in C which accept the radius and height in main function and pass them to a function. Function calculate the area, volume

and perimeter of a cylinder and their values get printed in main function.

52. Write a program in C to swap two number using function.

*53. Write a program in C to find factorial of a number using recursion function.

54. Write a program in C to find GCD of two number using recursion function.

55. Write a program in C to solve the TOWER of HANOI problem using recursion function.

56. Write a program in C to find the Armstrong numbers between 1 to n using function.

57. WAP in C which accepts a string and finds, if it is palindrome or not. For example, abeabba is such a string.

58. WAP in C that converts a string like “124” to an integer 124.

59. WAP in C that extracts part of the given string from the specified position. For example, if string is “Working with strings is

fun”, then if from position 4, 4 characters are to be extracted then the program should return string as “king”.

*60. WAP in C to reverse the string for example, input string is as “I am in MMMUT” and output string should be “MMMUT in

am I”.

61. WAP in C to read a string as “Amit Kumar Singh” and give the output as A. K. Singh.

62. WAP in C to delete all vowels from a sentence.

63. WAP in C to sort a set of names stored in an array in alphabetical order.

64. Create a structure to specify data on students given below:

Roll number, Name, Brach, Year of joining.

Consider there are 100 students.

WAP in C to print the names of all students who joined in a particular year.

*65. Suppose there are 100 employees in a company. Write a program in C to print the details of employees of the company who
have experiences more than 10 years by passing structure in function and access the details by using the pointer and, employee’s
details are inputted by user. Details contains following information:
Employee _ID
Employee _Name
Employee _Experience
Employee _Department

66. Write a function that compare two given dates. To store a date use structure that contains three members namely day, month,

year. If the dates are equal, function should return 0, otherwise 1.

*67. Write a program in C to print the details of 100 books using union. And details contain following information:
Book_Name
Page_No
Book_Price
68. Write a program in C to store n elements in an array and print the elements using pointer.
69. Write a program in C to print all permutations of a given string using pointers.
70. Write a C function that takes two set as input and prints cartesian product of two sets. e.g.
Input: A = {1, 2}, B = {3, 4}

output: A × B = {{1, 3}, {1, 4}, {2, 3}, {2, 4}}

71.Given an array of elements of length N, ranging from 1 to N. All elements may not be present in the array. If element is not

present, then there will be -1 present in the array. Write a C function that rearrange the array such that A[i] = i and if i is not

present, display -1 at that place. e.g.

Input: arr = [-1, -1, 6, 1, 9, 3, 2, -1, 4, -1]

Output: arr= [-1, 1, 2, 3, 4, -1, 6, -1, -1, 9]

72. Given an array of n integers (duplicates allowed). Write a C function that prints “Yes” if it is a set of contiguous integers else

print “No”.

Examples:

Input: arr[] = {5, 2, 3, 6, 4, 4, 6, 6}

Output: Yes

The elements form a contiguous set of integers which is {2, 3, 4, 5, 6}.

Input: arr[] = {10, 14, 10, 12, 12, 13, 15}

Output: No

73. Given an amount, write a C function that find the minimum number of notes of different denominations that sum up to the given

amount. Starting from the highest denomination note, try to accommodate as many notes possible for given amount. Suppose

notes of values {2000, 500, 200, 100, 50, 20, 10, 5, 1} are only available.

74. Given an array, write a C function that find maximum triplet sum in the array

Input: arr[] = {1, 2, 3, 0, -1, 8, 10}

Output: 21

10 + 8 + 3 = 21

Input: arr[] = {9, 8, 20, 3, 4, -1, 0}

Output: 37

20 + 9 + 8 = 37

75. Given a square matrix, write a C function that checks the matrix is in lower triangular form or not. A square matrix is called

lower triangular if all the entries above the main diagonal are zero.

76. Given a robot which can only move in four directions, UP(U), DOWN(D), LEFT(L), RIGHT(R). Given a string consisting of

instructions to move. Write a program in C that output the co-ordinates of robot after the executing the instructions. Initial

position of robot is at origin (0, 0).

Input: move = "UDDLRL"

Output: (-1, -1)


Move U: (0, 0)--(0, 1)

Move D: (0, 1)--(0, 0)

Move D: (0, 0)--(0, -1)

Move L : (0, -1)--(-1, -1)

Move R : (-1, -1)--(0, -1)

Move L : (0, -1)--(-1, -1)

Therefore, final position after the complete movement is: (-1, -1)

77. Here given a range from low to high and given a number k. Write a C function to find out the number of count which a number

has same digit as k

Input: low = 2, high = 35, k = 2

Output: 4

Numbers are 2, 12, 22, 32.

Input: low = 3, high = 30, k = 3

Output: 3

Numbers are 3, 13, 23.

78. Given two arrays arr1[] and arr2[], Write a C function to combine two arrays in such a way that the combined array has alternate

elements of both. If one array has extra element, then these elements are appended at the end of the combined array.

Input: arr1[] = {1, 2, 3, 4, 5, 6}

arr2[] = {11, 22, 33, 44}

Output: {1, 11, 2, 22, 3, 33, 4, 44, 5, 6}

Input: arr1[] = {1, 2, 3, 4, 5, 6, 7, 8}

arr2[] = {11, 22, 33, 44}

Output: {1, 11, 2, 22, 3, 33, 4, 44, 5, 6, 7, 8}

79. Given two arrays A [] and B[] of size n. It is given that both arrays individually contain distinct elements. Write a C function to

find sum of all elements that are not common.

Input: A [] = {1, 5, 3, 8}

B [] = {5, 4, 6, 7}

Output: 29

1 + 3 + 4 + 6 + 7 + 8 = 29

Input: A[] = {1, 5, 3, 8}

B [] = {5, 1, 8, 3}

Output: 0
All elements are common.

80. Given an array of unique integers where each integer of the given array lies in the range [1, N]. The size of array is (N-4). No

Single element is repeated. Hence four numbers from 1 to N are missing in the array. Write a C function to find the 4 missing

numbers in sorted order.

Input: arr[] = {2, 5, 6, 3, 9}

Output: 1 4 7 8

Input: arr[] = {1, 7, 3, 13, 5, 10, 8, 4, 9}

Output: 2 6 11 12

81. Given an array a[] and an element x, find number of occurrences of x in a[].

Input: a[] = {0, 5, 5, 5, 4}

x=5

Output: 3

Input: a[] = {1, 2, 3}

x=4

Output: 0

82. Given a positive integer n. Write a C function to print the pyramid pattern as described in the

below.

Input: 2

Output:

22

Input: 3

Output:

22

333

22

83. Given a square matrix of order n*n, write a C function to print elements of the matrix in Z form

Input: mat[][] = {1, 2, 3,

4, 5, 6,
7, 8, 9}

Output: 1 2 3 5 7 8 9

Input: mat[][] = {5, 19, 8, 7,

4, 1, 14, 8,

2, 20, 1, 9,

1, 2, 55, 4}

Output: 5 19 8 7 14 20 1 2 55 4

84. Given a circle (coordinates of centre and radius) and a point (coordinate), find if the point lies inside or on the circle, or not.

Examples:

Input: x = 4, y = 4 // Given Point

circle_x = 1, circle_y = 1, rad = 6; // Circle

Output: Inside

Input: x = 3, y = 3 // Given Point

circle_x = 0, circle_y = 1, rad = 2; // Circle

Output: Outside

85. Given an array of N integers. Write a C function to find an index such that Frequency of Even numbers on its left side is equal

to the frequency of even numbers on its right sides or frequency of odd numbers on its left side is equal to the frequency of Odd

numbers on its right sides. If No such index exists in an array print -1 Else print required index. Note- (If more than one index

exists then return index that comes first)

Examples:
Input: arr[] = {4, 3, 2, 1, 2, 4}
Output: index = 2
Explanation: At index 2, there is one odd number on its left and one odd on its right.

Input: arr[] = { 1, 2, 4, 5, 8, 3, 12}


Output: index = 3

86. You are given an array of n-elements with a basic condition that occurrence of greatest element is more than once. Write a C

function to find the minimum distance between maximums. (n>=2).

Examples:
Input: arr[] = {3, 5, 2, 3, 5, 3, 5}
Output: Minimum Distance = 2
Explanation: Greatest element is 5 and its index are 1, 4 and 6. Resulting minimum distance of 2 from position 4
to 6.
Input: arr[] = {1, 1, 1, 1, 1, 1}
Output: Minimum Distance = 1
Explanation: Greatest element is 1 and its index are 0, 1, 2, 3, 4 and 5. Resulting minimum distance of 1.

87.You are given an array. Write a C function to sort the even positioned elements in the ascending order and the odd positioned

elements in the descending order.


Examples:
Input: a[] = {7, 10, 11, 3, 6, 9, 2, 13, 0}
Output: {11, 3, 7, 9, 6, 10, 2, 13, 0}
Even positioned elements after sorting in ascending order: 3 9 10 13
Odd positioned elements after sorting in descending order: 11 7 6 2 0

88. Given an array of numbers, write a C function to find the number among them such that all numbers are divisible by it. If not

possible print 1.

Examples:
Input: arr = {25, 20, 5, 10, 100}
Output: 5
Explanation: 5 is an array element which divides all numbers.
Input: arr = {9, 3, 6, 2, 15}
Output: -1
Explanation: No numbers are divisible by any array element

89.Given a n x n matrix. Write a C function to sort the matrix row-wise and column wise.

Examples:
Input: mat[][] = { {4, 1, 3},
{9, 6, 8},
{5, 2, 7}}

Output: 134
257
689

90. Given a n x n matrix. Write a C function to sort the given matrix in strict order. Here strict order means that matrix is sorted in

a way such that all elements in a row are sorted in increasing order and for row ‘i’, where 1 <= i <= n-1, first element of row 'i'

is greater than or equal to the last element of row 'i-1'.

Examples:
Input: mat[][] = { {5, 4, 7},
{1, 3, 8},
{2, 9, 6}}

Output: 123
456
789

91. Given a number n. Write a C function to find out number of Reflexive Relation on a set of first n natural numbers {1, 2, ..n}.

Examples:
Input: n = 2
Output: 4
The given set A = {1, 2}. The following are reflexive relations on A * A:
{{1, 1), (2, 2)}, {(1, 1), (2, 2), (1, 2)}, {(1, 1), (2, 2), (1, 2), (2, 1)},
{(1, 1), (2, 2), (2, 1)}
Input: n = 3
Output: 64
The given set is {1, 2, 3}. There are 64 reflexive relations on A * A.

Note:- * marked programs write in the file.

You might also like