#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>
main()
{
int n;
clrscr();
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "../bgi");
{
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 25);
outtextxy(1,7," C++ ");
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 15);
outtextxy(1,177," Tutorial");
// line(300,300,500,300);
}
getch();
closegraph();
sha:
// textcolor(2 + BLINK);
textcolor(0);
textbackground(10); //14
clrscr();
cprintf("\n\n Entre Number to Use Following Statement's");
cout<<"\n\n\n\t\t\t(1) Simple If Statement";
cout<<"\n\t\t\t(2) If...Else Statement";
cout<<"\n\t\t\t(3) Else...If Statement";
cout<<"\n\t\t\t(4) Nested If Statement";
cout<<"\n\t\t\t(5) Switch Statement";
cout<<"\n\t\t\t(6) for loop";
cout<<"\n\t\t\t(7) While loop";
cout<<"\n\t\t\t(8) do...While loop";
cout<<"\n\t\t\t(9) One Dim. Array";
cout<<"\n\t\t\t(10) Two Dim. Array";
cout<<"\n\t\t\t(11) Structure";
cout<<"\n\t\t\t(12) Function {Type-I}";
cout<<"\n\t\t\t(13) Function {Type-II}";
cout<<"\n\t\t\t(14) Function {Type-III}";
cout<<"\n\t\t\t(15) Recursion {Factrioal}";
cout<<"\n\t\t\t(16) Return Main Program PRESS 99";
cout<<"\n\n\n\t\t\tEnter Number for Given Program ";
cin>>n;
clrscr();
switch(n)
{
case 1:
{
textcolor(9); //4
textbackground(0); //0
clrscr();
cout<<"\n\n\t\t\t You are Useing Simple If Statement";
cout<<"\n\n\n\t\t\t Syntax .....(Simple If)";
cout<<"\n\n\n\t\t\t\t if(condition 1)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\n\t\t\t\t if(condition 2)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n";
cout<<"\n\n\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t\t Use Simple If Statement";
cout<<"\n\n\n\t Problem :- To Find Minimun Number of Entered Three Integers.";
int a,b,c;
cout<<"\n\n\n\tEnter Three Integers in Next Line With Space:- \n\t";
cin>>a>>b>>c;
cout<<"\n\n\t\tEntered First Integer is "<<a;
cout<<"\n\t\tEntered Second Integer is "<<b;
cout<<"\n\t\tEntered Third Integer is "<<c;
cout<<"\n\n\n\tOutPut is.....";
if( (a<b) && (a<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<a;
}
if( (b<a) && (b<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<b;
}
if( (c<a) && (c<b) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<c;
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 2:
{
textcolor(0);
textbackground(13);
clrscr();
cout<<"\n\n\t\t\t You are Useing If...Else Statement";
cout<<"\n\n\n\t\t\t Syntax .....(If Else)";
cout<<"\n\n\n\t\t\t\t if(condition 1)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\n\t\t\t\telse";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n";
cout<<"\n\n\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t\t Use If else Statement";
cout<<"\n\n\n\t Problem :- To Find Minimun Number of Entered Three Integers.";
int a,b,c;
cout<<"\n\n\n\tEnter Three Integers in Next Line With Space:- \n\t";
cin>>a>>b>>c;
cout<<"\n\n\t\tEntered First Integer is "<<a;
cout<<"\n\t\tEntered Second Integer is "<<b;
cout<<"\n\t\tEntered Third Integer is "<<c;
cout<<"\n\n\n\tOutPut is.....";
if( (a<b) && (a<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<a;
}
else
if( (b<a) && (b<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<b;
}
else
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<c;
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 3:
{
textcolor(4);
textbackground(0);
clrscr();
cout<<"\n\n\t\t\t You are Useing Else...If Statement";
cout<<"\n\n\n\t\t\t Syntax .....(Else if)";
cout<<"\n\n\n\t\t\t\t if(condition 1)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\n\t\t\t\telse if(condition 2)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n";
cout<<"\n\n\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t\t Use If else Statement";
cout<<"\n\n\n\t Problem :- To Find Minimun Number of Entered Three Integers.";
int a,b,c;
cout<<"\n\n\n\tEnter Three Integers in Next Line With Space:- \n\t";
cin>>a>>b>>c;
cout<<"\n\n\t\tEntered First Integer is "<<a;
cout<<"\n\t\tEntered Second Integer is "<<b;
cout<<"\n\t\tEntered Third Integer is "<<c;
cout<<"\n\n\n\tOutPut is.....";
if( (a<b) && (a<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<a;
}
else if( (b<a) && (b<c) )
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<b;
}
else
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<c;
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 4:
{
textcolor(4);
textbackground(0);
clrscr();
cout<<"\n\t\t\t You are Useing Nested...If Statement";
cout<<"\n\t\t\t Syntax .....(Nested...if)";
cout<<"\n\n\t\t\t\t if(condition 1)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\t\t\t\t else ";
cout<<"\n\t\t\t\t { ";
cout<<"\n\t\t\t\t if(condition 2)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\t\t\t\t else";
cout<<"\n\t\t\t\t { ";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t }";
cout<<"\n\t\t\t\t }";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t\t Use Nested If Statement";
cout<<"\n\n\n\t Problem :- To Find Minimun Number of Entered Three Integers.";
int a,b,c;
cout<<"\n\n\n\tEnter Three Integers in Next Line With Space:- \n\t";
cin>>a>>b>>c;
cout<<"\n\n\t\tEntered First Integer is "<<a;
cout<<"\n\t\tEntered Second Integer is "<<b;
cout<<"\n\t\tEntered Third Integer is "<<c;
cout<<"\n\n\n\tOutPut is.....";
if (a<b)
{
if(a<c)
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<a;
}
}
else
{
if (b<a)
{
if (b<c)
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<b;
}
}
else
{
cout<<"\n\n\tThe Minimum Number of Given Values is "<<c;
}
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 5:
{
textcolor(2);
textbackground(9);
clrscr();
cout<<"\n\t\t\t You are Useing Switch Statement";
cout<<"\n\t\t\t Syntax .....(Switch Statement)";
cout<<"\n\n\t\t\t\t switch(Variable_name)";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t case 1:";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 1;";
cout<<"\n\t\t\t\t break;";
cout<<"\n\t\t\t\t }";
cout<<"\n\t\t\t\t case 2:";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement 2;";
cout<<"\n\t\t\t\t break;";
cout<<"\n\t\t\t\t }";
cout<<"\n\n\n";
cout<<"\n\t\t\t\t default:";
cout<<"\n\t\t\t\t {";
cout<<"\n\t\t\t\t statement ;";
cout<<"\n\t\t\t\t }";
cout<<"\n\t\t\t\t }";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t\t Use Switch Statement";
cout<<"\n\n\n\t Problem :- To Find Day of Week.";
int a;
cout<<"\n\n\n\tEnter Day of Week in Next Line :- \n\t";
cin>>a;
switch(a)
{
case 1:
{
cout<<"\n\n\tOutPut is.....\n\t Monday";
break;
}
case 2:
{
cout<<"\n\n\tOutPut is.....\n\t Tuesday";
break;
}
case 3:
{
cout<<"\n\n\tOutPut is.....\n\t Wednesday";
break;
}
case 4:
{
cout<<"\n\n\tOutPut is.....\n\t Thursday";
break;
}
case 5:
{
cout<<"\n\n\tOutPut is.....\n\t Friday";
break;
}
case 6:
{
cout<<"\n\n\tOutPut is.....\n\t Saturday";
break;
}
case 7:
{
cout<<"\n\n\tOutPut is.....\n\t Sunday";
break;
}
default:
{
cout<<"\n\t OutPut is....\n\tEntered Number is Out of Range\n\t And Range is 1 to 7 only.";
}
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 6:
{
int a,b;
textcolor(2);
textbackground(9);
clrscr();
cout<<"\n\n\t\tU R Using FOR Loop And For Loop's Structure Followes.....";
cout<<"\n\n\t\t\tfor(assinement;Condition;Incr/Dicre.)";
cout<<"\n\n\t\t\t {";
cout<<"\n\n\t\t\t Statement;";
cout<<"\n\n\t\t\t }";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use For Loop Statement";
cout<<"\n\n\n\t Problem :- To Print Series for given numbers.";
cout<<"\n\nEnter First & Last Number's";
cin>>a>>b;
cout<<"\nFirst Value is "<<a;
cout<<"\nLast Value is "<<b;
cout<<"\n\n";
for(a=a;a<=b;a++)
{
cout<<" "<<a;
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 7:
{
int a,b;
textcolor(2);
textbackground(9);
clrscr();
cout<<"\n\n\t\tU R Using WHILE Loop And While Loop's Structure Followes.....";
cout<<"\n\n\t\t\tWhile(Condition)";
cout<<"\n\n\t\t\t {";
cout<<"\n\n\t\t\t\t Statement;";
cout<<"\n\n\t\t\t\t Increment/dicrement;";
cout<<"\n\t\t\t }";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use While Loop Statement";
cout<<"\n\n\n\t Problem :- To Print Series for given numbers.";
cout<<"\n\nEnter First & Last Number's";
cin>>a>>b;
cout<<"\nFirst Value is "<<a;
cout<<"\nLast Value is "<<b;
cout<<"\n\n";
while(a<=b)
{
cout<<" "<<a;
a=a+1;
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 8:
{
int a,b;
textcolor(2);
textbackground(9);
clrscr();
cout<<"\n\n\tU R Using Do...WHILE Loop And Do...While Loop's Structure Followes.....";
cout<<"\n\n\t\t\tdo";
cout<<"\n\n\t\t\t {";
cout<<"\n\n\t\t\t\t Statement;";
cout<<"\n\n\t\t\t\t Increment/dicrement;";
cout<<"\n\t\t\t }";
cout<<"\n\t\t\t While(Condition;";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use do While Loop Statement";
cout<<"\n\n\n\t Problem :- To Print Series for given numbers.";
cout<<"\n\nEnter First & Last Number's";
cin>>a>>b;
cout<<"\nFirst Value is "<<a;
cout<<"\nLast Value is "<<b;
cout<<"\n\n";
do
{
cout<<" "<<a;
a=a+1;
} while(a<=b);
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
goto sha;
}
case 9:
{
int a[20],b,c,n;
textcolor(2);
textbackground(0);
clrscr();
cout<<"\n\n\tU R Using One Dim, Array And Array's Structure Followes.....";
cout<<"\n\n\t\t int Array name[] = { 2,3,4,5,6 }; \n\t\t\t or \n";
cout<<"\n\t\t int Array name[ Array Size];";
cout<<"\n\t\t\t{";
cout<<"\n\t\t\t for loop statememt \n\t\t\t { \n\t\t\t statememt of Input numbers; \n\t\t\t }\n";
cout<<"\n\t\t\t for loop statememt \n\t\t\t { \n\t\t\t statememt of Output numbers; \n\t\t\t }";
cout<<"\n\t\t\t}";
cout<<"\n";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use Array Statement";
cout<<"\n\n\n\t Problem :- To Print given numbers.";
cout<<"\n Enter size of an Array or \n How many numbers input in Array";
cin>>n;
for(b=0;b<n;b++)
{
cin>>a[b];
}
cout<<"\n\n\n\t\t\t\t\t\tPress Any Key To Return ...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use Array Statement";
cout<<"\n\n\n\t Problem :- To Print given numbers.";
cout<<"\n\n\t\tFollowing One Dim. Array's Output is....\n";
for(b=0;b<n;b++)
{
cout<<" \n\t a["<<b<<"]-->"<<a[b];
}
cout<<"\n\n\n\n\n\t\t\tPress Any Key To Continue...";
getch();
clrscr();
goto sha;
}
case 10:
{
int a[3][3],b,c,m,n,s=0;
textcolor(2);
textbackground(0);
clrscr();
cout<<"\n\n\tU R Using Two Dim Array And Array's Structure Followes.....";
cout<<"\n\n\t\t int Array name[][] = { {2,3,4},{5,6,9} }; \n\t\t\t or \n";
cout<<"\t\t int variable name[H Array Size][V Array Size];";
cout<<"\n\t\t\t{";
cout<<"\n\t\t\t for loop statememt(for row) \n\t\t\t { \n\t\t\t for loop statememt(for column) \n\t\t\t statememt of Input numbers; \n\t\t\t }\n";
cout<<"\n\t\t\t for loop statememt(for row) \n\t\t\t { \n\t\t\t for loop statememt(for column) \n\t\t\t statememt of Output numbers; \n\t\t\t }\n";
cout<<"\n\t\t\t}";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
cout<<"\n\n\n\t\t Use Array Statement";
cout<<"\n\n\t Problem :- To Print given Matrix numbers.";
cout<<"\n Enter size of an Multi Dim Array or \n How many rows and columns Array";
cin>>m>>n;
cout<<"\n\nEnter "<<m*n<<" Numbers";
for(b=0;b<m;b++)
{
for(c=0;c<n;c++)
{
cin>>a[b][c];
}
}
cout<<"\n\n\t\tFollowing Two Dim. Array's Output is....\n";
for(b=0;b<m;b++)
{
for(c=0;c<n;c++)
{
cout<<" a["<<b<<"]["<<c<<"]-->"<<a[b][c];
s=s+a[b][c];
}
cout<<"\n";
}
cout<<"\n\nSum of matrix numbers is "<<s;
cout<<"\n\n\t\t\tPress Any Key To Continue...";
getch();
clrscr();
goto sha;
}
case 11:
{
cout<<"\n\n\tU R Using Structure And Structure's syntax Followes.....";
cout<<"\n\n\t\t struct structure_name";
cout<<"\n\t\t\t {";
cout<<"\n\t\t\t\t data_type field_name;";
cout<<"\n\t\t\t\t different_data_type field_name;";
cout<<"\n\t\t\t }";
cout<<"\n\n\t\t\t variable_name; ";
cout<<"\n\n\t\t\t\t\t\t Press Any Key To Continue...";
getch();
clrscr();
struct student
{
char name[25];
long int phone;
};
struct student a1;
cout<<"\nEnter Student's Name and Phone No.";
cin>>a1.name;
cin>>a1.phone;
cout<<"\nStudent's Name is "<<a1.name;
cout<<"\nStudent's Phone No "<<a1.phone;
getch();
clrscr();
goto sha;
//break;
}
case 12:
{
cout<<"\n\n\tU R Using Function & Function's syntax Followes.....";
cout<<"\n\n\t\t {";
cout<<"\n\n\n\t\tsum(; //Calling Function or Function Name ";
cout<<"\n\t\t\t }";
cout<<"\n\n\n\t\tsum() //Called Function ";
cout<<"\n\t\t\t {";
cout<<"\n\t\t\t cout<<Statements;";
cout<<"\n\t\t\t }";
cout<<"\n\n\n\n\n\t\t\tPress Any Key To Continue...";
void s();
int x;
{
void s();
clrscr();
s();
getch();
}
goto sha;
// break;
}
case 13:
{
cout<<"\n\n\tU R Using Function & Function's syntax Followes.....";
cout<<"\n\n\t\t {";
cout<<"\n\n\n\t\tsum(; //Calling Function or Function Name ";
cout<<"\n\t\t\t }";
cout<<"\n\n\n\t\tsum() //Called Function ";
cout<<"\n\t\t\t {";
cout<<"\n\t\t\t cout<<Statements;";
cout<<"\n\t\t\t }";
cout<<"\n\n\n\n\n\t\t\tPress Any Key To Continue...";
void s1(int c1,int d1);
{
int c,d;
clrscr();
cout<<"Enter two numbers";
cin>>c,d;
s1(c,d);
getch();
}
goto sha;
// break;
}
case 99:
{
exit(99);
}
default:
{
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\tNumber's Range Only 1 to 12";
cout<<"\n\n\n\n\n\t\t\tPress Any Key To Continue...";
getch();
// clrscr();
goto sha;
}
}
//getch();
}
void s()
{
int a,b;
cout<<"enter first no ";
cin>>a;
cout<<"enter second no";
cin>>b;
cout<<"%d",a+b;
}
void s1(int c1,int d1)
{
int e;
e=c1+d1;
cout<<"%d",e;
}