C++ Revision and example

C++ Revision and example

This lab teaches you the following topics:

  • Basic syntax of C++
  • Data types and operators in C++
  • Control flow statements in C++
  • Arrays and Functions


C++, as we all know is an extension to C language and was developed by Bjarne stroustrup at bell labs. C++ is an intermediate level language, as it comprises a confirmation of both high level and low level language features.

Following features of C++ makes it a stronger language than C,

  1. There is Stronger Type Checking in C++.
  2. C++ supports and allows user defined operators (i.e Operator Overloading) and function overloading is also supported in
  3. Exception Handling is there in C++.
  4. Inline Functions in C++ instead of Macros in C language. Inline functions make complete function body act like Macro, safely.
  5. Variables can be declared anywhere in the program in C++, but must be declared before they are used.

Lab Activities:

Activity 1:

Write a Hello World program in C++.



Activity 2:

Write a program to use different data types in C++


Activity 3:

Write a program to use string data type in C++


Activity 4:

Write a program to use arithmetic operators in C++


Activity 5:


Write a program to use relational operators in C++



Activity 6:

Write a program to use if-else statement in C++



Activity 7:

Write a program to use while loop in C++



Activity 8:

Write a program to use do-wḥile loop in C++


Activity 9:

Write a program that will add two numbers in a function and call that function in main.


Activity 10:

Write a program to use the concept of Arrays in C++


Home Activities:

  • Use nested loops that print the following patterns in three separate


  • (Printing numbers in a pyramid pattern) Write a nested for loop that prints the following output:

Lab Task 2
Write the computer program to apply the concepts of Array List. The array list will include the following
1. Insert the value at end of the list
2. Insert the value at start of the list
3. Insert the value after specific value
4. Insert the value before specific value
5. Display the array list
6. Delete the value from end of the list
7. Delete the value from start of the list
8. Delete specific value

Lab Task 3
Using while loop apply linear search on the Array List you developed in Lab Task 2


Lab Assignment 

  1. Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score.
  2. Write a program that displays all the numbers from 100 to 1000, ten per line, that are divisible by 5 and 6.
  3. Write a C++ program to generate Fibonacci Series like given below using loop up to given number by If user enter number = 20, your output must be

Fibonacci Series upto 20

0    1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

[Hint: add the last two number in the series to get new number of the series]


Related links 

Single link list                 Stack              AVL Trees             Binary search          Counting Sort

Doubly link list               Queue              Graphs                  Bubble Sort               Radix sort

Circular link list              Binary search tree       Hashing         Insertion Sort         Bucket Sort

Josephus Problem          Tree Traversal              Heaps                Quick Sort              Merge Sort


At Cui tutorial, courses, past papers and final year projects

#tutorial #cui #pastpaper #courses

Scroll to Top