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
- Download and intall DEV C++.
- Run the DEV C++.
- Go to file menu , New and open Source file.
- Save as this file and give it any name e.g test
- Include library iostream in the text window
Syntax: #include<iostream> - Define main function , which is main body of any program
Syntax:
main()
{
}
- 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 - My program looks like this
- 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
- 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.
thanks you....!!!
ReplyDeleteThanks alot
ReplyDeleteIt helped a lot
ReplyDeleteI am written a program
ReplyDelete