List of C Program Scenarios

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

NMIMS University

Mukesh Patel School of Technology Management & Engg (Mumbai)


Programming for Problem Solving (PPS)
B.Tech. EXTC Sem II AY 2018-19
C Program Scenarios for Practice
Faculty Incharge: Pratidnya S. Hegde Patil

Programs on Expressions &


Conditional Statements
(if-else, switch-case)
1. To calculate compound interest. (CI= principal*((pow((1+rate/100),year)-1)))
2. Check if a given number is even or odd.
3. To check if an inputted character is a vowel, consonant, digit or special character.
4. Calculate simple interest.
5. Find roots of a quadratic equation. Input a, b and c float values. Calculate as per condition
roots of the quadratic equation.
6. To print the number of days in a particular month.
7. Check if a given year is Leap Year.
8. Calculate profit or loss with sell price and cost price input.
9. Check if a given number is Zero, Negative or Positive.
10. Input three subject marks each out of 100 and calculate the total & percentage. Then print
grade as per the following (use if-else if ladder) Grade A 80% to 100%, Grade B 60% to 79%,
Grade C 50% to 59% and Grade D below 50%.
11. Find the largest out of three inputted numbers.
12. To swap two numbers.
13. C program to convert temperature from Fahrenheit to Celsius and vice versa using choice as
the input. Formula fh= (cl*1.8)+32 and cl = (fh -32) / 1.8
14. Calculate feet to inches.
15. Calculate net salary of an employee with basic salary as the input. Follow the given constraints.
DA : 12% of Basic salary
HRA : 150
TA : 120
Others : 450
Tax cuts – a) PF :14% of Basic salary and b) IT: 15% of Basic salary
Net Salary = Basic Salary + DA + HRA + TA + Others – (PF + IT)

Page 1 of 5
NMIMS University
Mukesh Patel School of Technology Management & Engg (Mumbai)
Programming for Problem Solving (PPS)
B.Tech. EXTC Sem II AY 2018-19
C Program Scenarios for Practice
Faculty Incharge: Pratidnya S. Hegde Patil

Programs on Looping construct


(while, do-while, for)
16. Print the ascii chart between 0 to 255.
17. Find GCD and LCM of two numbers.
18. To print sum of n numbers inputted (if negative number entered then stop the program &
print the sum). Use break statement.
19. To print sum of n numbers inputted (if negative number entered just ignore it). Use continue
statement.
20. To find sum and average of n inputted numbers.
21. Menu driven program to create a simple calculator which performs 1-add, 2-subtract, 3-
multiply, 4-divide on two inputted numbers use (do while) to create the menu 1-4 options and
any other option to quit.
22. Find max and min of n inputted numbers.
23. Print only odd numbers between 1 to n.
24. Print only even numbers between 1 to n.
25. Find if a give number n is prime or not.
26. Find prime numbers between the given range m to n.
27. To read an integer and print its multiplication table.
28. To print tables from numbers 1 to 20.
29. To check entered number is ZERO, POSITIVE or NEGATIVE until user does not want to quit.
30. C Program to find factorial of a number.
31. C program to print all Armstrong numbers from 1 to N. For example 153=13+53+33
32. C program to print square, cube and square root of all numbers from 1 to N.
33. C program to print all leap years from 1 to N.

Page 2 of 5
NMIMS University
Mukesh Patel School of Technology Management & Engg (Mumbai)
Programming for Problem Solving (PPS)
B.Tech. EXTC Sem II AY 2018-19
C Program Scenarios for Practice
Faculty Incharge: Pratidnya S. Hegde Patil

Programs of Patterns (nested loops)


34. Print of n 35. Print for n 36. Print for n 37. Print for n
1 1 * 4321
12 121 ** 321
123 12321 *** 21
1234 1234321 **** 1
38. Print for n 39. Print for n 40. Pascal’s Triangle 41. Floyd’s Triangle
A 1234 1 1
BB 123 1 1 2 3
CCC 12 1 2 1 4 5 6
DDDD 1 1 3 3 1 7 8 9 10
1 4 6 4 1
42. Print for n 43. Print for n 44. Print for n 45. Print for n
A 1 1 4321
ABA 101 13 432
ABCBA 10101 135 43
ABCDCBA 1010101 1357 4
46. Print for n 47. Print for n 48. Print for n 49. Print for n
* * 1234 A
** ** 4321 AB
*** *** 1234 ABC
**** **** 4321 ABCD
*** ***
** **
* *

Programs on Recursion
50. C program to add natural numbers from 1 to n using recursion.
51. C program to find factorial using recursion.
52. Reverse a string using recursion.
53. C program to print fibonacci series till n using recursion.
54. C program to calculate power of a number using recursion. For example (2^3=8).

Page 3 of 5
NMIMS University
Mukesh Patel School of Technology Management & Engg (Mumbai)
Programming for Problem Solving (PPS)
B.Tech. EXTC Sem II AY 2018-19
C Program Scenarios for Practice
Faculty Incharge: Pratidnya S. Hegde Patil

55. C program to count digits of a number using recursion. For example: input value is 34562, and
then total number of digits is: 5.
56. C program to find sum of all digits using recursion. For example: input value is 34562, and then
sum of all digits is: 20.
57. C program to calculate length of the string using recursion.
58. To convert decimal number to its binary equivalent using recursion. For example decimal 10
= binary 1010.
59. Print the reverse of an inputted string using recursion.

Programs on One-dimensional array


(Searching, Sorting)
60. Print all unique elements from an integer array.
61. Print all duplicate elements from an integer array.
62. To print the frequency of each element in an array.
63. To find min & max from an array.
64. To separate odd & even numbers from an array into separate arrays.
65. To sort elements of an integer array in descending/ascending order using Bubble Sort.
66. To sort elements of an integer array in descending/ascending order using Insertion Sort.
67. To sort elements of an integer array in descending/ascending order using Selection Sort.
68. Search an element in an integer array using linear search.
69. To find the second largest and second smallest element of an array.
70. To print the elements which occur odd times in an array.

Programs on Strings
(One-dimensional array)
71. C Program to Find the Frequency of Characters in a String.
72. C Program to Find the Number of Vowels, Consonants, Digits and White space in a String
73. C Program to Find the Length of a String
74. C program to Concatenate Two Strings
75. C Program to Copy a String

Page 4 of 5
NMIMS University
Mukesh Patel School of Technology Management & Engg (Mumbai)
Programming for Problem Solving (PPS)
B.Tech. EXTC Sem II AY 2018-19
C Program Scenarios for Practice
Faculty Incharge: Pratidnya S. Hegde Patil

76. C Program to Remove all Characters in a String except alphabet


77. C Program to Sort characters of a string in Lexicographical Order (Dictionary Order)

Programs on 2-D Arrays (Matrices)


78. To input a NXM array and display it in a matrix form.
79. To print the transpose of a matrix
80. To print the matrix helically (spirally).
81. To add or subtract two integer matrices.
82. To multiply two matrices.
83. To print sum of right diagonal & sum of left diagonal of a matrix.
84. To print the upper or lower triangle of a matrix.
85. To find an element in a matrix and display its index (rowno, colno) where found.

Programs on Structures
86. Store information (roll, name, percentage) of one student using structure and print it on the
screen.
87. Store information (roll, name, percentage) of n students using array of structure and print
each student information.
88. Display a student’s record with the given roll number as input.
89. Create a shopping bill with (item, quantity, rate) for n items and then print the final bill amount
payable. (price=quantity*rate and bill amount=addition of all item prices).
90. Add two distances having (inch, feet) using structures.
91. Add two complex numbers having (real, imaginary) using structures by passing the structure
variable to a function.
92. Create a union of student(roll, name, percentage) and display the union elements.

Programs on Pointers
93. Swap two values through a function using call by reference and compare with swap function
using call by value.
94. Reverse a string through a function using pointer.
95. Dynamically create an array of n elements using malloc() and search a given number in it.
96. Comparing two strings using pointers.
97. Search for a character in a string using pointers.
98. Count the length of a string using pointer.
99. A function to return more than one value (sum, average) of two numbers using pointer.
100. Concatenate two strings using pointers.

Page 5 of 5

You might also like