All about Problems on C
Questions on basic to Loops concepts:
Learning C Programming does not get completed if we do not learn coding in C. Coding is the ultimate help to Learn C. These question set will guide you further on How to code in C.
- Draw patterns of various shapes like diamond and triangle with the help of for loop it may be nested loops.
- Make point of sale system using while loop and for loop
- Write a program in C to find the sum of first 10 natural numbers
- Write a program in C to find the factorial of a number
- Write a program in C to find the Greatest Common Divisor (GCD) of two numbers
- Write a program in C to ask the user to input positive integers to process count, maximum, minimum, and average or terminate the process with -1. Hint (using while loop).
Questions on arrays and functions
- Basically, the same as exercise 1, but this time, the function that adds the numbers should be void, and takes a third, pass by reference parameter; then puts the sum in that.
- Create a calculator that takes a number, a basic math operator (+,-,*,/,^), and a second number all from user input, and have it print the result of the mathematical operation. The mathematical operations should be wrapped inside of functions.
- Write a C program to find the most occurring element in an array of integers
- Write a C program to sort a given unsorted array of integers, in the waveform.
Further visit: 10 Causes Why C is the Best Programming Language For Beginners
Mix Practice Question of C
Practice Examples
Analyze the problem, design an unambiguous and precise algorithm, and draw a flowchart for each of the following problems.
- Compute the cost per square foot of living space for a house, given the dimensions (Length, Width) of the house, the number of stories, the size of the non-living space (garage, closets), the total cost of the house.
- Given a positive integer number, find whether the number is even or odd.
- Given a positive integer number, find a display if the number is a prime number.
- Find the slope of a line through two points using formula m =. The values of y1, y2, x1, and x2 are given. If x1 equals x2, the line is vertical and the slope is undefined. If y1 equals y2, the line is horizontal.
- Write code to calculate and print the diameter, the circumference, or the area of a circle given the radius. The input is two data items. The first is a character – ‘D’ (for diameter), ‘C’ for circumference, or ‘A’ for the area – to indicate the calculation needed. The next data value is a floating-point number indicating the radius of the particular circle.
- A company manufactures a line of traffic cones. It requires painting its cones in different colors. The company has hired you to write a program that will compute the surface area of the cone, and the cost of painting it, given its radius, height, and the cost per square foot of three different colors of paint. The surface area of the cone can be calculated using a formula.
- Mother had just filled the cookie jar when the three children went to bed. That night one child woke up, ate half of the cookies, and went back to bed. Later, the second child woke up, ate half of the remaining cookies and went back to bed. Still later, the third child woke up, ate half of the remaining cookies, leaving 5 cookies in the jar. How many cookies were in the jar, to begin with? Find a generic solution to this problem.
- Find and display the sum of numbers from 1 to n where n is input by the user.
- Display a line of n stars.
- Input an integer value and if the input value is equivalent to the value of a British coin, print it out in words. Otherwise, it should print an error message.
Input Print
1 One Penny
2 Two Penny
5 Five Penny
10 Ten Pence
50 Fifty Pence - Add a series of numbers input by the user and find the average of these numbers. It is not known in advance how many values will be input.
- Display the status of the students (Pass or Fail) based on the marks entered by the user. It is not known in advance how many marks will be entered.
- Find the hypotenuse of the right-angled triangle given its two sides using the Pythagorean Theorem.
- Write a program that reads the lengths of the sides of a triangle from the user and computes and displays the area of the triangle using Heron’s formula. Heron’s formula is:
Area calculation
Where A, B, C are three sides of a triangle and S is half perimeter and is calculated by
- Given the cost of a sales item, calculate the amount of sales tax and total cost of the sales item including tax assuming 7% sales tax.
- A person’s weekly pay is Rs. 2500/-. He is scheduled to receive a 3% pay raise next week. Calculate the amount of his new salary.
- In a video store, a daily rental fee of a video is Rs. 50/-. Customers are charged a late fee of Rs. 20/- per day when the video is returned past the due date. Assume that a customer can return only one video at a time, calculate the amount the customer owes when he/she returns the video.
- Given a positive integer number N, find display all the prime numbers that is less than or equal to N.
- A woman is going shopping to buy fifteen items only. Find the total cost of these fifteen items given the price of each item. Also, display the highest price and the lowest price.
- A perfect number is a positive integer such that the sum of proper divisors equals the number. Thus 28 = 1 + 2 + 4 + 7 + 14 is a perfect number. If the sum of proper divisors is less than the number, it is deficient. If the sum exceeds the number, it is abundant. Write a program that allows the user to enter a positive integer N and then displays all perfect, deficient, and abundant numbers less than or equal to N.