C++ Programming Tutorial


Basic Programming

Input - Output - Variables - Constants

Print text Count number of words, lines and chracters Read 2 numbers from user - computes sum Size, addr of variable of type int , float, char Declaration , initialization, print constant vari Reference variables

Bitwise Operators

Bitwise operator OR ( | ) Bitwise Operator AND (&) Bitwise Operator XOR ( ^ ) Bitwise Operator Left Shift ( << ) Bitwise Operator Right Shift ( >> )

Conditional Statements

Reads marks - test of 100 marks - print pass Reads number and prints even or odd number Read, compute, display grade using switch case Read marks, compute grade using if else Compute, display result - ternary operator ( ? : ) Read integers, operator, evaluate - switch case

Loops - Continue/Break Statement

Prints 10 integers using for loop Display sum of ten integers using for loop Print odd numbers from 0 to 50 using for Loop Compute, displays num factorial using for loop Histogram using nested for loop Print a diamond using nested for loop Square of ten integers using for loop Print 20 integers using while loop Print 20 int in reverse order using while loop Odd num, even num, divisible by 5 b/w 0 to 50 Display num digits in reverse order - while loop Display num in reverse order - do while loop Display factorial using do-while loop Even num - 0 to 50 - while, do-while, for loop Use of the break statement Use of the continue statement


Use of parameterless function Largest int among 3 - function with no return type Largest int among 3 - function with return type Use of call-by-value method in functions Use of call-by-refrence method in functions Use of inline functions Use of default argument function Use of function overloading Find distance b/w 2 points - function overloading Example of function overloading Example if built-in function Compute nCr Built int functions strcomp, strcmpi, stricmp Storage class Auto, Static with global variable


Find largest element of an array Initialize array by even numbers display sum Reverse the content of an integer array Histogram using array Print an array using function definition Read marks of students display total marks, status Whole array, single array elmt as parameter to fn Bubble sorting of arrays Search element in an array - Linear search Search element in an array - Binary search Read 2D array, display it row by row and sum

Pointers - Strings

Use of operator * and & Supplying of values to pointer variables Adding values to the contents of variables Use of pointer to pointers Functions returning pointers Operations performed on pointers 2D array of int using pointers 2D array of char (string) using pointers Srray before and after adding 5 to its contents Use of call-by-reference method using pointers Sum, smallest, largest element an array pointers Features of array of char known as string Example of constant pointers to non-constant data


Computes and displays the factorial of number Computes n_th term of the fibonacci series Towers of Hanoi Problem

General Programs

Find Book in the list of Books Year is a leap year or not Swap two variables using header file swap.h Find day of a week of a given date using arrays Convert decimal into binary, octal, pental code Covert given decimal into Roman Code Covert given Decimal into English Code Add two integers without using + operator Factorial of first five elements of the fibonacci Add two integers of any length Non-Linear function in one variable and evaluate



 int year_code(int,int);

 //-----------------------------  Main( )  -------------------------------//


       int date;
       int year;
       int month;
       int birth_week;
       int century;
       int birth_year;
       int century_remainder;
       int century_code;
       int birth_year_code;
       int day;

       cout<<\"\\n Enter the date in the following pattern :\"<<endl;
       cout<<\"Date - Month - Year\"<<endl;

       cout<<\"-       -       \"<<endl;







       else if(century_remainder==1)

       else if(century_remainder==2)



       cout<<\"\\n The day on the given date is : \";


         case 0: cout<<\"Friday\";

         case 1: cout<<\"Saturday\";

         case 2: cout<<\"Sunday\";

         case 3: cout<<\"Monday\";

         case 4: cout<<\"Tuesday\";

         case 5: cout<<\"Wednesday\";

         case 6: cout<<\"Thursday\";

       return 0;

 //------------------------  Function Definitions  -----------------------//

 //-------------------------  year_code(int,int)  ------------------------//

 int year_code(int year,int month)
       int code;

       int array_1[12]={3,6,6,2,4,7,2,5,1,3,6,1};
       int array_2[12]={4,7,7,3,5,1,3,6,2,4,7,2};
       int array_3[12]={5,1,1,4,6,2,4,7,3,5,1,3};
       int array_4[12]={6,2,3,6,1,4,6,2,5,7,3,5};
       int array_5[12]={1,4,4,7,2,5,7,3,6,1,4,6};
       int array_6[12]={2,5,5,1,3,6,1,4,7,2,5,7};
       int array_7[12]={3,6,6,2,4,7,2,5,1,3,6,1};
       int array_8[12]={4,7,1,4,6,2,4,7,3,5,1,3};
       int array_9[12]={6,2,2,5,7,3,5,1,4,6,2,4};
       int array_10[12]={7,3,3,6,1,4,6,2,5,7,3,5};
       int array_11[12]={2,3,1,2,4,7,2,5,1,3,6,1};
       int array_12[12]={7,3,4,7,2,5,7,3,6,1,4,6};
       int array_13[12]={5,1,2,5,7,3,5,1,4,6,2,4};
       int array_14[12]={3,6,7,3,5,1,3,6,2,4,7,2};
       int array_15[12]={1,4,5,1,3,6,1,4,7,2,5,7};

       if(year==1 || year==29 || year== 57 || year==85 || year==7 ||
     year==35 || year==63 || year==91 || year==18 || year==46 || year==74)

       else if(year==2 || year==30 || year== 58 || year==86 || year==13 ||
     year==41 || year==69 || year==97 || year==19 || year==47 || year==75)

       else if(year==3 || year==31 || year== 59 || year==87 || year==14 ||
     year==42 || year==70 || year==98 || year==25 || year==53 || year==81)

       else if(year==4 || year==32 || year== 60 || year==88)

       else if(year==5 || year==33 || year== 61 || year==89 || year==11 ||
     year==39 || year==67 || year==95 || year==22 || year==50 || year==78)

       else if(year==6 || year==34 || year== 62 || year==90 || year==17 ||
             year==45 || year==73 || year==23 || year==51 || year==79)

       else if(year==7 || year==35 || year== 63 || year==91)

       else if(year==8 || year==36 || year==64 || year==92)

       else if(year==9 || year==37 || year== 65 || year==93 || year==15 ||
     year==43 || year==71 || year==99 || year==26 || year==54 || year==82)

       else if(year==10 || year==38 || year==66 || year==94 || year==21 ||
             year==49 || year==77 || year==27 || year==55 || year==83)

       else if(year==12 || year==40 || year==68 || year==96)

       else if(year==16 || year==44 || year==72 || year==100)

       else if(year==20 || year==48 || year==76)

       else if(year==24 || year==52 || year==80)

       else if(year==28 || year==56 || year==84)

       return code;

    Related Post:
  1. Program to show the projection of 3D objects using Standard Perspective Projection w.r.t. an Arbitrary Plane and Center of Projection...

  2. Program to read a Non-Linear equation in one variable, then evaluate it using Secant Method and display its kD accurate root

  3. Program of reflection in x axis

  4. Program that performs SCANNING of the following program and finds the entire float,integer variables and keywords present in the program

  5. Code for finding a no in a binary search tree and displaying its level where it is found (root is at zero level)

  6. Program to illustrate printing data on the printer

  7. Program to illustrate strings as member of classes

  8. Program of swapping numbers using pointers

  9. Program to show a 3D object using Polygon-Mesh Representation

  10. Program to illustrate the binary operator(*) overloading without creating a new object

  11. Program to read a Linear System of Equations,then evaluate it by using Guass-Seidel Itrative Method and show the result

  12. Program to read 2D array and display it row by row and its sum

  13. To parse a string using Recursive-Descent parser

  14. Program to illustrate array of objects in classes

  15. Program that take font and background color and text input from a user and display it in right aligned

  16. Program to implement the Kurskals Algorithm to solve Minimum Cost Spanning Tree Problem (MST) using Graphics with Mouse Support

  17. Program to display numeric triangle for user given value

  18. Program to illustrate operator overloading from String object to basic string

  19. Program of KSCANNER

  20. Program that computes the n_th term of the fibonacci series and also print the series upto the n_th term using recursion