C++ Basics Programs (Variables, Datatypes, Operators)

Back To C++ Index


1. program to display hello world on the output screen - Code
2. program to display abcdefxyz on the output screen - Code
3. program to input an integer (or number) and display its value - Code
4. program to input two numbers or integers and display their values - Code
5. program to input three numbers and display their values - Code
6. program to input two numbers and find their sum - Code
7. program to input three numbers and find sum of three numbers - Code
8. program to input two numbers and find the difference between them - Code
9. program to input two numbers and find their product - Code
10. program to input two numbers and display their quotient (division) - Code
11. program to input two numbers and find their remainder (division) - Code
12. program to enter a character and display its value - Code
13. program to input a float value (number with decimal point ) - Code
14. program to add two decimal point values - Code
15.program to input two decimal point numbers and display difference between them - Code
16. program to input two float (decimal point) values and find their product - Code
17. program to input two float (decimal point ) values and find their quotient - Code
18.example of unsigned int variable (unsigned int can store value from 0 to 255 - Code
19.program to input principal, rate of interest and time and compute simple interest - Code
20. program to input length and breadth of rectangle and find area of rectangle - Code
21 . program to input length and breadth of rectangle and compute perimeter of rectangle - Code
22 . program to input side of square and compute area of square - Code
23 . program to input side of square and find perimeter of square - Code
24 . program to input base and height of right angled triangle and find area of right angled triangle - Code
25 . program to input radius of circle and find area of circle - Code
26 . program to input radius of circle and find circumference of circle - Code
27 . program to demonstrate increment(++) operator , i++ is same as i=i+1 - Code
28 . program to demonstrate decrement(--) operator , i-- is same as i=i-1 - Code
29 . program to assign value 10 to a, initializing variable a - Code
30 . program to demonstrate (+=) operator, a+=2 is same as a=a+2 - Code
31 . program to demonstrate (-=) operator, a-=2 is same as a=a-2 - Code
32 . program to demonstrate (*=) operator, a*=2 is same as a=a*2 - Code
33 . program to demonstrate (/=) operator, a/=2 is same as a=a/2 - Code
34 . program to demonstrate (%=) operator, a%=2 is same as a=a%2 - Code
35 . program to input price of an item from user and calculate discount as 10 percent on the price - Code
36 . program to find volume of box based on width, depth and height - Code
37 . program to demonstrate ternary operator or conditional operator, displays 'p' if marks>=40 else displays 'f' - Code
38 . program to create a float constant pi with value 3.14 using const keyword - Code
39 . program to calculate size of a variable using sizeof operator - Code
40 . program to demonstrate unsigned integer variable - Code
41 . program to demonstrate typedef keyword (typedef keyword can be used to give a new name to a datatype) - Code
42 . program to create a reference to a variable (reference means to create an alias for a variable )- Code
43 . program to create macros using #define directive - Code
44 . program to demonstrate global variables - Code
45 . program to create local and global variable with the same name and use scope resolution operator(::) to access global variable - Code