Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Basic Program in C++

Basic Program in C++

Write a program to print a message on the screen?

#include<iostream>
using namespace std;
int main()
{
cout<<"welcome to dear students";
cout<<"welcome to t4tutorials";

}

Program with comments.

We can comment the program for better understanding. Comments can be started with the symbols //.

#include<iostream>
//this is header file to ensure inputs and outputs
using namespace std;
//here we are adding namespace within the program
int main()
//this is main function- every program must have a main function. Here this main function is of integer type.
{
//Starting of main funtion
cout<<"welcome to dear students";
//displays the message in double qoutation as: welcome to dear students.
cout<<"welcome to t4tutorials";
//displays the message in double qoutation as: welcome to t4tutorials. 
}
//Ending of main funtion

Output.

basic program in c plus plus


Write a program to print two messages on two different lines on the screen?

#include<iostream>
using namespace std;
int main()
{
cout<<"welcome to dear students"<<endl;
cout<<"welcome to t4tutorials"<<endl;

}

Program with comments.

#include<iostream>
//this is header file to ensure inputs and outputs
using namespace std;
//here we are adding namespace within the program
int main()
//this is main function- every program must have a main function. Here this main function is of integer type.
{
//Starting of main funtion
cout<<"welcome to dear students"<<endl;
//displays the message in double qoutation as: welcome to dear students. Then due to endl control moves to the next line.
cout<<"welcome to t4tutorials"<<endl;
//displays the message in double qoutation as: welcome to t4tutorials. Then due to endl control moves to the next line.
}
//Ending of main funtion

Output of the program.

first program in c++

.