Now we will see how to write a program in C++. The idea of this program is to introduce you to the overall structure of a C++ program.
//My first program
#include<iostream.h>
int main()
{
//Print text message on console
cout<<"Hello Universe.. Give me Red ";
return 0;
}
Now after writing program in a text file(Source file) , save text file by name first.c
Note:
C++ source files conventionally use one of the suffixes .C, .cc, .cpp, .CPP, .c++, .cp, or .cxx;
if you are using GNU Compiler, you can give following command to compile first.c
g++ first.c
To run
a.out
Output will be:
Hello Universe.. Give me Red
Example 2:
#include<iostream.h>
int main()
{
//Print multiple text messages on console
cout<<"Hello Universe.. Give me Red "<<endl;
cout<<"Congrats! Sachin ...";
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment