C++ Coding Exercises - Input and Output
Practice C++ programming with coding exercises covering variables, data types, operators, input and output, type casting, conditional statements, loops, functions, arrays, and other C++ fundamentals.
Problem Statement 1: – Student Information
Write a C++ program that takes the student's name, age, and marks as input and displays them using cout.
Problem Statement 2: – Calculate Total
Write a C++ program that takes the prices of three items from the user, calculates the total, and displays the result.
Problem Statement 3: – Calculate Rectangle Perimeter
Write a C++ program that takes the length and width of a rectangle and calculates:
Perimeter = 2 × (Length + Width)Display the result using cout.
Problem Statement 4: – Calculate Average
Write a C++ program that takes marks of three subjects, calculates the average, and displays the result.
Problem Statement 5: – Student Age
Write a C++ program that asks the user to enter their age and displays:
Your age is: 20Problem Statement 6: – Two Numbers
Write a C++ program that takes two integers from the user and displays their:
- Sum
- Difference
- Product
Problem Statement 7: – Student Marks
Write a C++ program that takes marks of three subjects and displays the total marks.
Problem Statement 8: – Rectangle
Write a C++ program that takes the length and width of a rectangle and calculates its area.
Formula:
Area = Length × WidthProblem Statement 9: – Student Information
Write a C++ program that takes the following information from the user:
- Name
- Age
- Department
- Marks
Then display all the information using cout.
Problem Statement 10: – endl
Write a C++ program that displays your:
- Name
- Department
- Semester
Use endl to print each item on a separate line.
Problem Statement 11: – setw
Write a C++ program to display the following table using setw(10):
Number Cube
2 8
3 27
4 64
5 125Problem Statement 12: – Both Manipulators
Write a C++ program that uses both endl and setw() to display a simple student information table containing:
- Roll No.
- Name
- Marks