Basic Programs

Fundamental C++ programs to get started with programming

14 program solutions

Back to Topics

Program Solutions

1

Hello World

A simple C++ program that prints "Hello World" on the screen and introduces basic C++ concepts for beginners.

Beginner
View Solution
2

Display Your Name

Beginner-friendly C++ program that shows how to store your name in a string variable and print it on the screen.

Beginner
View Solution
3

User Input

Beginner-friendly C++ program that teaches how to take input from the user using cin and display it on the screen.

Beginner
View Solution
4

Sum of Two Numbers

Beginner-friendly C++ program that teaches how to take two numbers from the user, add them, and display the result.

Beginner
View Solution
5

Swap Two Numbers

Beginner-friendly C++ program that shows how to swap two numbers using a temporary variable.

Beginner
View Solution
6

Size of int, float, double, char

Beginner-friendly C++ program that shows how much memory different data types use, using the sizeof operator.

Beginner
View Solution
7

Float Multiplication

Beginner-friendly C++ program that multiplies two decimal numbers using float and formats the output to two decimal places.

Beginner
View Solution
8

ASCII Value of a Character

Beginner-friendly C++ program that takes a character as input and prints its ASCII value using type casting.

Beginner
View Solution
9

Convert Fahrenheit to Celsius

Beginner-friendly C++ program that converts temperature from Fahrenheit to Celsius using the standard formula and formats the result.

Beginner
View Solution
10

Calculate Simple Interest

Beginner-friendly C++ program that reads principal, rate, and time to calculate simple interest and total amount payable.

Beginner
View Solution
11

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.

Beginner
View Solution
12

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.

Beginner
View Solution
13

Find Quotient and Remainder

Beginner-friendly C++ program that finds the quotient and remainder when one number is divided by another.

Beginner
View Solution
14

Add Two Numbers

Beginner-friendly C++ program that reads two numbers from the user, adds them, and displays the result.

Beginner
View Solution

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.