C++ PROGRAMMING

Build your C++ foundation.

DAY 01

Introduction to C++

Start your programming journey by understanding what C++ is, why it is used and how it differs from C.

START DAY 01
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello, World!";
    return 0;
}

Course Introduction

01

Learn C++ from the foundation

This course is designed to take you from the fundamentals of C++ programming to advanced concepts. Each day focuses on a specific topic followed by practice and MCQ tests.

Day-wise Learning Concept Based MCQ Tests Practice
DAY 01 • LESSON 01

Introduction to C++

Understand the foundation of C++ programming.

01

What is C++?

C++ is a cross-platform language that can be used to create high-performance applications.

C++ was developed by Bjarne Stroustrup, as an extension to the C language.

02

Why Use C++?

  • C++ is one of the world's most popular programming languages.
  • C++ can be found in today's operating systems, Graphical User Interfaces and embedded systems.
  • C++ is an object-oriented programming language which gives a clear structure to programs.
  • C++ allows code to be reused, lowering development costs.
03

Difference Between C and C++

C++ was developed as an extension of C, and both languages have almost the same syntax.

C
C++
Procedural programming language
Supports object-oriented programming
Does not support classes and objects
Supports classes and objects
IMPORTANT

The main difference between C and C++ is that C++ supports classes and objects, while C does not.

DAY 01

Lesson Summary

3 Topics
Beginner Level
100% Completed
DAY 02 • LESSON 01

C++ Data Types

Learn the basic data types used in C++ programs.

01

C++ Data Types

Data types specify the type of data that a variable can store.

In this lesson, we will learn four basic data types: int, char, string, and float.

02

int — Integer

int is used to store whole numbers.

Examples: 1, 2, 3, 10, 100

int a = 10;
int b = 20;
03

char — Character

char is used to store a single character.

It can store letters such as a to z and A to Z.

A character is written inside single quotes (' ').

char grade = 'A';
char letter = 'b';
04

string — Text

string is used to store a sequence of characters.

A string can contain a word, name, or sentence.

A string is written inside double quotes (" ").

string name = "Gautam";
string message = "Hello World";
05

float — Decimal Value

float is used to store decimal values.

Examples: 1.23, 4.24, 10.5

float a = 1.23;
float b = 4.24;
PROGRAM 01

Write a C++ Program to Add Two Numbers

#include <iostream>
using namespace std;

int main() {

    int a = 10;
    int b = 20;

    int sum = a + b;

    cout << "Sum = " << sum;

    return 0;
}
Output: Sum = 30

Here, a + b adds the two numbers and stores the result in sum.

PROGRAM 02

Write a C++ Program to Subtract Two Numbers

#include <iostream>
using namespace std;

int main() {

    int a = 20;
    int b = 10;

    int difference = a - b;

    cout << "Difference = " << difference;

    return 0;
}
Output: Difference = 10
PROGRAM 03

Write a C++ Program to Multiply Two Numbers

#include <iostream>
using namespace std;

int main() {

    int a = 10;
    int b = 20;

    int product = a * b;

    cout << "Product = " << product;

    return 0;
}
Output: Product = 200
PROGRAM 04

Write a C++ Program to Divide Two Numbers

#include <iostream>
using namespace std;

int main() {

    float a = 20;
    float b = 5;

    float quotient = a / b;

    cout << "Quotient = " << quotient;

    return 0;
}
Output: Quotient = 4
QUICK REVISION

Data Types at a Glance

Data Type Used For Example
int Whole numbers 10
char Single character 'A'
string Text / Sentence "Hello"
float Decimal values 1.23
OPERATORS USED

+ → Addition

- → Subtraction

* → Multiplication

/ → Division

DAY 02

C++ Data Types

01 Lesson
04 Data Types
04 Programs
Beginner Level
DAY 03 • LESSON 01

C++ Data Types

Learn char, string and float with simple C++ examples.

01

char — Character

char is used to store a single character.

It can store characters from a to z and A to Z.

Example

#include <iostream>
using namespace std;

int main() {

    char letter = 'A';

    cout << "Character = " << letter;

    return 0;
}
Output: Character = A
02

string — Text

string is used to store a sequence of characters.

Characters can be combined to make a word, name or sentence. This is called a string.

Example

#include <iostream>
using namespace std;

int main() {

    string message = "Hello World";

    cout << message;

    return 0;
}
Output: Hello World
03

float — Decimal Value

float is used to store decimal values.

Examples: 1.23, 4.24, 10.5

Complete Code Example

#include <iostream>
using namespace std;

int main() {

    float a = 20;
    float b = 5;

    float quotient = a / b;

    cout << "Quotient = " << quotient;

    return 0;
}
Output: Quotient = 4
DAY 03

C++ Data Types

01 Lesson
03 Topics
03 Examples
Beginner Level
DAY 04 • LESSON 01

Swap Two Numbers

Learn how to swap two numbers using a third variable.

01

Swap Two Numbers Using a Third Variable

Write a C++ program to swap two numbers using a third variable.

Suppose: a = 10 and b = 20.

STEP 01

Store the Value of a in c

a = 10 b = 20 c = 0

First, store the value of a in the third variable c.

c = a;
After Step 1: a = 10, b = 20, c = 10
STEP 02

Store the Value of b in a

Now, store the value of b in a.

a = b;
After Step 2: a = 20, b = 20, c = 10
STEP 03

Store the Value of c in b

Finally, store the original value of a, which is saved in c, into b.

b = c;
After Step 3: a = 20, b = 10, c = 10
FINAL RESULT

Before swapping: a = 10, b = 20

After swapping: a = 20, b = 10

The third variable c temporarily stores the original value of a.

COMPLETE CODE

C++ Program to Swap Two Numbers

#include <iostream>
using namespace std;

int main() {

    int a = 10;
    int b = 20;
    int c = 0;

    c = a;
    a = b;
    b = c;

    cout << "a = " << a << endl;
    cout << "b = " << b;

    return 0;
}
Output:
a = 20
b = 10
DAY 04

Swap Two Numbers

01 Lesson
03 Steps
01 Program
Beginner Level

MCQ Test Series

Test your understanding after completing the lessons.

TEST 01

C++ Introduction Test

Basic questions based on Day 01.

5 Questions
15 Minutes
100 Marks

Practice Area

Practice questions coming soon.

After completing each day, practice questions will be added here.