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++

Video Lecture

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.