c++ tutorial

What is the computer programming language C++?

 

C++ is a Computer Programming Language.  It is a very popular high level for graphical application programming language.

Firstly to learn computer programming you need to learn algorithm and flowcharting. I would suggest reading this to understand the algorithm and flowcharting.

In this post, you will learn C++ programming from basic to advanced. You will find this the best C++ tutorial. 

I suggest you must learn the “GW-Basic” language for a better understanding of computer programming.


programming examples

First Programme with Codding

#include<iostream>
using namespace std;
int main()
{
cout<<“Welcome to C++ Tutorial with Rana Mehtab Alam”;
}

Compile and Execute the programme.

Save the file

OutPut

c++ first Programme


Multi Line Text Codding

#include<iostream>
using namespace std;
int main()
{
cout<<“Welcome to Cpp Tutorial with Rana Mehtab Alam\n”;
cout<<“This is Lunar Computer College” <<endl;
cout<<“endl and slash n both used for change line in output”;
}


String Variable in C++

#include<iostream>
using namespace std;
int main()
string a;
string b;
string c;
a=”Welcome to Cpp Tutorial with Rana Mehtab Alam”;
b=”This is Lunar Computer College”;
c=”endl and /n both used for change line in output”;
{
cout<<a<<“/n”;
cout<<b <<endl;
cout<<c;
}


Variables int float double char string bool in C++

#include<iostream>
using namespace std;
int main()
int a 100;
float f =10.5;
double d=12.5;
char c = ‘A’;
char x=’a”;
char cc=65;
char n=97;
string z = “Rana Mehtab Alam Lunar Computer College”;
bool y = “true”; both used for change line in output”;
{
cout<<a<<endl;
cout<<f <<endl;
cout<<d <<endl;
cout<<c <<endl;
cout<<x <<endl;
cout<<cc <<endl;
cout<<n <<endl;
cout<<z <<endl;
cout<<y;
}

Compile and Execute the programme.

Save the file

OutPut

c++ variables


Get Data From User With cin then Solve It and Give output with cout

#include<iostream>
using namespace std;
int main()
{

int a;
int b;
int c;

cout << “Enter 1st value”;cin >>a;
cin >>a;

cout << “Enter 2nd value”;cin >>b;
cin >>b;

c=a+b;

cout<<c;
{

Compile and Execute the programme.

Save the file

OutPut

c++ get value


To get a formatted result of the upper programme
cout« a «” + ” « b « ” = ” « c;

Output
Enter 1st value 5
Enter 2nd value 4
5 + 4 = 9


Shop Billing Software with DIM, If and Goto Statement.

#include <iostream>
using namespace std;

int main()
{
char str[30];
char op;
int k;
int s;
int sn[30];
int q[30];
int r[30];
int a[30];

lahore:
s=s+1;
cout<<“\nItem “;
cin>>str[s];

cout<<“\nQntity “;
cin>>q[s];

cout<<“\nRate “;
cin>>r[s];

a[s]=q[s]*r[s];

cout<<“\nMore Item”;
cin>>op;
if (op==’y’)
goto lahore;

system(“cls”);
cout<<“S/No\t”<<“item\t”<<“Rate\t”<<“qntity\t”<<“Amout\n”;
for (k=1; k<=s; k++)
cout<<s<<“\t”<<str[k]<<“\t”<<q[k]<<“\t”<<r[k]<<“\t”<<a[k];

return 0;
}


How to Use Switch function in C++?

#include <iostream>
using namespace std;

int main()
{
int day;

lunar:
cout<<“\nEnter no of weekday (0 for exit) “;
cin>>day;
switch (day)
{
case 0:
exit(0);
break;
case 1:
cout << “Monday”;
break;
case 2:
cout << “Tuesday”;
break;
case 3:
cout << “Wednesday”;
break;
case 4:
cout << “Thursday”;
break;
case 5:
cout << “Friday”;
break;
case 6:
cout << “Saturday”;
break;
case 7:
cout << “Sunday”;
break;

}

goto lunar;
return 0;
}


In the upper programme, you can find the required weekday using the switch function.


How to Find Even or Odd Value in C++?

#include <iostream>
using namespace std;

int main()

{

int n;
lunar:
cout<< “Enter a numeric value”;
cin>>n;

if (n%2==0)
cout<<“Even” <<endl <<endl;

else
cout<<“Odd” <<endl <<endl;
goto lunar;
}


How to make 1 to 5 sequence counting in C++?

Understanding If and Goto

#include <iostream>
using namespace std;

int main ()
{
int n=0;

rana:
n=n+1;
cout<<n <<endl;
if (n<5)
goto rana;
else
exit(0);

}


How To Use For Loop In Cpp?

#include <iostream>
using namespace std;
int main()
{
int a;

for (a=1; a<=10; a=a+1)
{
cout<<a<<endl;
}

return (0);

}


C++ Total, Average, Grade and Remarks

How to Make A Result Card?

#include<iostream>
using namespace std;
int main ()

{
string n,g,r;
int s1,s2,s3,s4,s5,t,a;

cout<<“Enter Name of Student ?”;
cin>>n;

cout<<“Enter Subject-1 Marks?”;
cin>>s1;

cout<<“Enter Subject-2 Marks?”;
cin>>s2;

cout<<“Enter Subject-3 Marks?”;
cin>>s3;

cout<<“Enter Subject-4 Marks?”;
cin>>s4;

cout<<“Enter Subject-5 Marks?”;
cin>>s5;

t=s1+s2+s3+s4+s5;
a=t/5;

if (a>=80)
g=”A+”;

else
if(a>=70)
g=”A”;

else
if (a>=60)
g=”B”;

else
if (a>=50)
g=”C”;

else
if (a>=40)
g=”D”;

else
if (a>=33)
g=”E”;

else
g=”Fail”;

if (a>=80)
r=”Most Excellent”;

else
if(a>=70)
r=”Excellent”;

else
if (a>=60)
g=”Very Good”;

else
if (a>=50)
r=”Good”;

else
if (a>=40)
r=”Fair”;

else
if (a>=33)
r=”Poor”;

else
r=”Very Bad”;

cout<<n<<” “<<t<<” “<<a<<” “<<” “<<g<<” “<<r;

}


C++ Table Learning Software.

Enter Table to learn ?3
Enter where to start ?1
Enter where to end ?5
Table of 3
3 x 1=3
3 x 2=6
3 x 3=9
3 x 4=12
3 x 5=15


How to make a Table Learning Software in C++

#include<iostream>
using namespace std;
int main()
{

int t;
int s;
int e;

cout<<“Enter Table to learn ?”;
cin>>t;

cout<<“Enter where to start ?”;
cin>>s;

cout<<“Enter where to end ?”;
cin>>e;

cout <<“Table of “<<t <<endl;

rana:
cout<<t <<” x “<<s <<“=”<<t*s <<endl;
s=s+1;
if (s<=e)
goto rana;
else
exit(0);

}


How to find the size of using bytes for int, float, double, bool, char in C++?

#include<iostream>
using namespace std;
int main()
{
char a =’a’;
cout<<a <<endl;

char b=97;
cout<<b <<endl;

int i = 1000;
cout<<i <<endl;

float f=45.34;

cout<<f<<endl;

double d = 123456;

cout<<d <<endl;

cout <<sizeof(int)<<endl;
cout <<sizeof(float)<<endl;
cout <<sizeof(double)<<endl;
cout <<sizeof(bool)<<endl;
cout <<sizeof(char)<<endl;
cout <<sizeof(string)<<endl;

}


      Home      Courses     


You can watch A Complete C++ Video Tutorial from my YouTube Lunar Computer College Channel.