How To Write a Simple Program Using Language C++ in DEV C++

How To Write a Simple Program Using Language C++ in DEV C++

Today i am going to talk about how to write a simple program in Dev C++ using language C++  . It is very useful for the beginners of C++. Those who want to learn C++ language will be very pleased to find this.


By simple program i mean i will display the output like i will show the text "Information". So lets start


STEPS
  1. Download and intall DEV C++.
  2. Run the DEV C++.
  3. Go to file menu , New and open Source file.
  4. Save as this file and give it any name e.g test
  5. Include library iostream in the text window

     Syntax:    #include<iostream>
  6. Define main function , which is main body of any program

    Syntax:
                     main()
                      {
                       }
     
  7. Write the statement for the output

    Syntax:
                   std::cout<<;
    e.g          std::cout<< "            Information        ";

            Note: 
     before and after Information i have given spaces but it is not necessary
  8. My program looks like this

  9. Now go to option Execute as shown above in the top menu bar , click the Compile option, it will open the compile progress window as shown below which will tell you there is a mistake in your program or not. If program is correct , it will compile correctly other wise it will show the errors. If there are errors, correct them and compile again





  10. After compiling , again go to Execute option and select Compile and Run , it will show you the output .exe file and its done.


    Now you are ready to use DEV C++.

Exercises:
1. what is the output of following program code ?

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

  cout<<  "     Nouman        ";
  
  getch();

}

2.what is the output of this program ?

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

  cout<<  "     i am a programmer     ";
  
  getch();

}


3.what is the output of this program ?

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

  cout<<  "     i am a programmer     "<<endl;
  cout<<  " i have no life :D " ;
  
  getch();
}

4.what is the output of this program ?

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

  cout<<  "     i am a programmer     "<< " i have no life :D " ;
  
  getch();
}

5.what is the output of this program ?

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

  cout<<  "     i am a programmer     "<< " i have no life :D "<<endl<< "Hehe" ;
  
  getch();

}

6.what is the output of this program ?

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

  cout<<  "Hy i am learning programming "<<endl<<endl<<"thank you";
  getch();
}

7.what is the output of this program ?

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

  cout<<endl<<endl<< "Hy i am learning programming "<<endl<<endl<<"thank you";
  getch();
}

8.what is the output of this program ?

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

  cout<<endl<<endl;
  cout<<"thank"<<endl<<"you";
  getch();
}

9.what is the output of this program ?

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

  cout<<endl<<endl;
  cout<<"thank"<<endl<<endl<<"you";
  getch();
}

10.what is the output of this program ?

#include<iostream>

using namespace std ;
int main()
{

  cout<<endl<<endl;
  cout<<"thank"<<endl<<endl<<"you";
  
  
}

    Hope that you will find this helpful.

    4 comments:

    Please disable your ad blocker to support this website.

    Our website relies on revenue from ads to keep providing free content.