Basic Programs
Fundamental C++ programs to get started with programming
14 program solutions
Program Solutions
Hello World
A simple C++ program that prints "Hello World" on the screen and introduces basic C++ concepts for beginners.
Display Your Name
Beginner-friendly C++ program that shows how to store your name in a string variable and print it on the screen.
User Input
Beginner-friendly C++ program that teaches how to take input from the user using cin and display it on the screen.
Sum of Two Numbers
Beginner-friendly C++ program that teaches how to take two numbers from the user, add them, and display the result.
Swap Two Numbers
Beginner-friendly C++ program that shows how to swap two numbers using a temporary variable.
Size of int, float, double, char
Beginner-friendly C++ program that shows how much memory different data types use, using the sizeof operator.
Float Multiplication
Beginner-friendly C++ program that multiplies two decimal numbers using float and formats the output to two decimal places.
ASCII Value of a Character
Beginner-friendly C++ program that takes a character as input and prints its ASCII value using type casting.
Convert Fahrenheit to Celsius
Beginner-friendly C++ program that converts temperature from Fahrenheit to Celsius using the standard formula and formats the result.
Calculate Simple Interest
Beginner-friendly C++ program that reads principal, rate, and time to calculate simple interest and total amount payable.
Calculate Compound Interest
Beginner-friendly C++ program that calculates compound interest using the formula A = P(1 + R/100)^T and prints both interest and total amount.
Area and Perimeter of Rectangle
Beginner-friendly C++ program that calculates the area and perimeter of a rectangle using length and width provided by the user.
Find Quotient and Remainder
Beginner-friendly C++ program that finds the quotient and remainder when one number is divided by another.
Add Two Numbers
Beginner-friendly C++ program that reads two numbers from the user, adds them, and displays the result.
Topic Strategy: Basic Programs
This topic is best practiced through repetition with variation. Solve each program, then modify constraints and test alternate approaches so you understand why one solution performs better than another.
During interviews, explain the approach before coding: input assumptions, core logic, complexity, and edge cases. Clear reasoning often matters as much as final code correctness.
Once comfortable, time-box each question and target clean, readable code with meaningful variable names and a quick dry run explanation.