Basic programming exercises and solutions in C
Let us see a list of important Basic programming exercises and solutions in C++.
- Cube of a number
- Convert temperature in Celsius to Fahrenheit
- Area of Rectangle
- Concatenate two strings
- Program to find the length of a string in C, CPP, C Plus Plus with flowchart
- Swapping Program in C++ (C Plus Plus)
- Solve expression program in C++ (C Plus Plus)
- simple compound assignment program in C++ (C Plus Plus).
- Find time, distance and speed in C++(C Plus Plus)
- Show personal details program in C++(C plus Plus)
- Cube of a number Program in C, CPP, C Plus Plus (C++) with flowchart
- Program in C, C Plus Plus (CPP) to display the ASCII Values with flowchart
- Program to convert temperature in Celsius to Fahrenheit in c++ and C with flowchart
- Area of Rectangle Program in C,C++ (C Plus Plus , CPP) with flowchart
- Program to Concatenate two strings in C++ (CPP, C Plus Plus) and C Languages with flow chart
- Arithmetic operation program in C++ (C Plus Plus) – Addition- Subtraction- Multiplication -Division
- Find Quotient and Remainder in C++(C Plus Plus)
- Convert hours into minutes and seconds program in C++ (C Plus Plus).
- Write a C++ program that prompts the user to enter values for a b and c
- Write a C++ program to calculate the wind chill factor
- Write a program that inputs principal amount, rate of interest and total time. It calculates the compound interest and displays it.
- C++ Program Basic Salary of the employee with dearness allowance
- Write a program that inputs the x, y coordinates for two points and computes distance between two points
- Write a program that display the following output using single cout
- Write a C++ program that Accept 5 digits number from the user
- Write a program which accepts days as integer and display total number of years
- Write a program which accepts a character and display its next character.
- A car can travel 5.3 miles in 1 liter. Write a program that inputs petrol in liters
If else programming Exercise and solution
- Let us see a list of important If else programming exercises and solutions in C++.
- Program to calculate the bill in c++
- CPP program to check that the entered character is small, capital, or a special character
- Program in C++ to check that whether a number is even or odd with flowchart
- 0 is a positive or negative number
- Program to find the positive and negative number
- Enter Range of numbers and replaced them in C++
- Program to find greater number among three numbers in c++ and C with flowchart
- Armstrong Number Program in C++, C Plus Plus CPP with Flowchart
- ASCII code Program in C++ (C Plus Plus)
- Find the Maximum value program in C++ (C Plus Plus).
- C++ Program to find the maximum between three numbers by using the if-else statement. C++ Program for the maximum number
- C++ Program to take a value from the user as input the basic salary of an employee and calculate its Gross salary according to the following: Basic Salary <= 10000: HRA = 20%, DA = 80%………………………………..Basic Salary <= 20000 : HRA = 25%, DA = 90%………………………………Basic Salary > 20000 : HRA = 30%, DA = 95%.
- C++ Program to find the maximum between two numbers by using the if-else statement. Maximum Number Program
- Using the if-else C++ Program to take a value from the user as input electricity unit charges and calculate total electricity bill according to the given condition: For the first 50 units Rs. 0.50/unit………….For the next 100 units Rs. 0.75/unit…..For the next 100 units Rs. 1.20/unit ……………For unit above 250 Rs. 1.50/unit………An additional surcharge of 20% is added to the bill…….Using if-else.
- Write a program that determines a student’s grade. The program will read three types of scores (quiz, mid-term, and final scores) and determine the grade based on the following rules:if the average score =90% =>grade=A…………………..-if the average score >= 70% and <90% => grade=B……………………-if the average score>=50% and <70% =>grade=C……………………..-if the average score<50% =>grade=F.
- C++ Program to check whether a number is divisible by 5 and 11 or not by using if-else. The number is divisible by 11 or 5 or not
- C++ Program to count the total number of notes in a given amount. Using if-else
- C++ Program to take a value from the user as input the angles of a triangle and check whether the triangle is valid or not by using the if-else statement. Triangle program
- C++ Program to take a value from the user as input all sides of a triangle and check whether the triangle is valid or not. Using if-else.
- C++ Program to check whether the triangle is an equilateral, isosceles or scalene triangle. Using the if-else statement.
- C++ Program to find all the roots of a quadratic equation. Using if-else.
- C++ Program to calculate profit or loss. Using if-else.
- C++ Program to check whether a year is a leap year or not by using an if-else statement. Leap year program
- C++ Program to check whether a character is an alphabet or not. Using if-else.
- C++ Program to take a value from the user as input any alphabet and check whether it is vowel or consonant. Using if-else.
- Using if-else C++ Program to take a value from the to take a value from the user as input marks of five subjects Physics, Chemistry, Biology, Mathematics, and Computer. Calculate percentage and grade according to the following: Percentage >= 90% : Grade A, Percentage >= 80% : Grade B, Percentage >= 70% : Grade C, Percentage >= 60% : Grade D, Percentage >= 40% : Grade E, Percentage < 40% : Grade F, Write this program with the help of if-else statement. Grade and Percentage Program
- C++ Program to take a value from the user as input any character and check whether it is the alphabet, digit or special character. Using if-else.
- C++ Program to check whether a character is an uppercase or lowercase alphabet. Using if-else.
- C++ Program to take value from the user as an input weekday number and print weekday by using if-else statement. Weekday program
- C++ Program to take a value from the user as input the month number and print number of days in that month. Using if-else.\
- C++ Program to check whether a number is a prime or composite number.
- Program to take the hours and minutes as input by the user and the show that whether it is AM or PM using if-else statement
- Write a program to swap the values of two number if values of both variables are not the same using if-else statement
- Program to update even number into its upper nearest odd number. C++ Program to update even to odd
- Write a C program to calculate profit or loss by using if-else. Profit Loss Program
- Write a C++ Program to convert centimeter into meter and kilometer using the if-else statement. Program of centimeter into meter and kilometer
- Write a C++ program to input all sides of a triangle and check whether the triangle is valid or not. Using the switch statement. Triangle Program
- C PROGRAM TO INPUT THE BASIC SALARY OF AN EMPLOYEE AND CALCULATE ITS GROSS SALARY BY USING THE IF-ELSE STATEMENT – Salary Program
- Write a C++ program in which a user enters a number, and the program will find the Even and odd number. Your program should only accept integers of length 2 or higher and should ask the user to re-enter a value if the value containing total numbers of integers less than 2. The program with goto statement. Even odd program with goto statement.
- C++ program to calculate area of the circle if the radius is greater than 0 using goto statement.
- Write a C++ program to find the roots of a quadratic equation ax2 + bx + c = 0
- Basic Tutorial of conditional statements
Switch Exercise and solution
- Using switch statement Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following:
Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F - C++ Program to find the maximum between two numbers. Using the switch statement. Download Program to find maximum
- C++ Program to find the maximum between three numbers. Using the switch statement.
- C++ Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement.
- C++ Program to check whether a year is a leap year or not. Using switch statement
- C++ Program to check whether a character is an alphabet or not. Using the switch statement. Click Here
- C++ Program to take the value from the user as input any alphabet and check whether it is vowel or consonant. Using the switch statement. C++Program to check Vowel
- C++ Program to take the value from the user as input any character and check whether it is the alphabet, digit or special character. Using the switch statement. C++ Program Details
- C++ Program to check whether a character is an uppercase or lowercase alphabet. Using the switch statement. Click Here
- C++ Program to take the value from the user as an input week number and print weekday by using the switch statement. Weekday Program
- C++ Program to take the value from the user as input the month number and print number of days in that month. Using switch statement – Click Here
- C++ Program to count the total number of notes in a given amount. Using the switch statement. Click Here
- C++ Program to take the value from the user as input all sides of a triangle and check whether the triangle is valid or not. Using switch statement – Click Here
- C++ Program to check whether the triangle is an equilateral, isosceles or scalene triangle. Using switch statement
- C++ Program to find all the roots of a quadratic equation. Using switch statement
- C++ Program to calculate profit or loss. Using switch statement. Program to calculate profit or loss
- Using switch statement C++ Program to take the value from the user as input marks of five subjects Physics, Chemistry, Biology, Mathematics, and Computer. Calculate percentage and grade according to the following: Percentage >= 90% : Grade A, Percentage >= 80% : Grade B, Percentage >= 70% : Grade C, Percentage >= 60% : Grade D, Percentage >= 40% : Grade E, Percentage < 40% : Grade F, Using switch statement.
- C++ Program to take the value from the user as input the basic salary of an employee and calculate its Gross salary according to the following: Basic Salary <= 10000: HRA = 20%, DA = 80%………………………………..Basic Salary <= 20000 : HRA = 25%, DA = 90%………………………………Basic Salary > 20000 : HRA = 30%, DA = 95%.
- C++ Program to take the value from the user as input electricity unit charges and calculate total electricity bill according to the given condition: For the first 50 units Rs. 0.50/unit………….For the next 100 units Rs. 0.75/unit…..For the next 100 units Rs. 1.20/unit ……………For unit above 250 Rs. 1.50/unit………An additional surcharge of 20% is added to the bill…….Using the switch statement. C++Program to find the bill.
- Write a program that determines a student’s grade. The program will read three types of scores (quiz, mid-term, and final scores) and determine the grade based on the following rules:if the average score =90% =>grade=A…………………..-if the average score >= 70% and <90% => grade=B……………………-if the average score>=50% and <70% =>grade=C……………………..-if the average score<50% =>grade=F
- Program to take the hours and minutes as input by the user and the show that whether it is AM or PM by using the switch statement. Click Here
- Program to convert a positive number into negative number and negative number into a positive number using switch statement Click Here
- Write a program to swap the values of two numbers if the values of both variables are not the same using a switch statement. C++ Code
- Program to Convert even number into its upper nearest odd number Switch Statement. Even and odd conversion program
Loop programming exercises and solutions
For loop
For loop is a methodology to use a piece of code again and again until the given condition remains true. Loop will terminate when the given condition will false.
- For loop have three parts. Loop initialization, Condition, and increment or decrement of a loop.
- Program to find the length of a number in C++ (CPP). Solution
- Program to find the square root of a number in C++. Solution
- Factorial Program in C, C++ (C Plus Plus, CPP) with flow chart. Solution
- Fibonacci Series Program in C++ and C with flowchart. Solution
- Palindrome Program in C, C++, C Plus Plus (CPP) with flow chart. Solution
- Program to the Print sum of the number of Series in C Plus Plus (CPP, C++) and C with Flowchart. Solution
- C++ and C Program to Find the Number of Vowels, Digits, Consonants and White Spaces in a String with flowchart. Solution
- Program in C++, C to display the reverse of a number with a flowchart. Solution
- Write a program that lets the user enter the total rainfall for each of 12 months
- Write a C++ program to print a triangle of prime numbers up to given number of lines of the triangle
- Write a C++ program to print all numbers between a and b (a and b inclusive) using for loops
while loop
- The while loop is a methodology to use a piece of code again and again until the given condition remains true. Loop will terminate when the given condition will false.
- Just lie for loop, the while loop has three parts. 1. Loop initialization, 2. Condition, and 3. increment or decrement of a loop.
- Program of the sum of all digits of a number in C, C Plus Plus (CPP, C++) with flow chart. the solution
- converts a number into binary in C++and C with a flowchart. Solution
- Program in C Plus Plus and C with an explanation to find the Greatest Common Division (GCD). Solution with flowchart. Solution
- C++ Program to convert Octal to decimal number using while loop. Solution
- Write a program using integers usernum and x as input, and output usernum divided by x four times.
- Write a C++ program to add two numbers without using the addition operator
- Write a C++ program that simulates the rolling of two dice
Do while loop
- In Do, while loop, first one time we execute the do part of the loop, and then we check the condition. It means that if the condition is false then still do part execute one time.
- C++ Program to Display English Alphabets from A-Z. Solution
- <spanhelvetica’,’sans-serif’;”>Write a program in C++ to display the multiplication table vertically from 1 to n. Solution</spanhelvetica’,’sans-serif’;”>
- C++ Program to Find the Sum of Digits of a Number – C++ Program. Solution
- Program in C++ to display the n terms of even natural number and their sum. Solution
- C++ program to find the sum of all integer between 100 and 200 which are divisible by 9. Solution
- Write a program in C++ to print Floyd’s Triangle. Solution
- C++ program to print pyramid pattern of numbers. Solution
- C++ Program to display the n terms of odd natural number and their sum. Solution
- Convert a binary number to octal in C++. Solution
- c++ program to check whether a given number is a perfect number or not. Solution
- C++ program to find HCF (Highest Common Factor) of two numbers. Solution
- Program in C++ to convert a decimal number into binary without using an array. Solution
- Program C++ to convert an octal number into binary. Solution
- Write a c program to find out the sum of an A.P. series. Solution
- Program in C++, C to display the reverse of a number with flowchart. Solution
- Write the Octal to Decimal number program in C++. Solution
- C++ Program right angle triangle with a number that will repeat a number in a row. Solution
- C++ program to print rhombus or parallelogram star pattern. Solution
- Program in C++ to make such a pattern like a pyramid with a number that will repeat the number in the same row. Solution
- Write a program in C++ to Check Whether a Number can be Express as a Sum of Two Prime Numbers. Solution
- C++ program to print mirrored right triangle star pattern. Solution
- Decimal to octal number conversion program in C++. Solution
- C++ program to print a hollow square or rectangle star pattern. Solution
- C++ Program Sum of odd Natural Number. Solution
- The sum of the first 10 natural numbers program in C++. Solution
Prefix and postfix
- Prefix and postfix increment and decrement in C++. Solution