From Today i have start a tutorials for you.
Today's Task is that i have to teach you a basic of C++.
Cout is an object. It is one of the members of iostream family, and iostream is a header file.
#include<iostream.h> // header file
#include<conio.h> // header file
void main() // main function
{ // Opening brackets of main function
clrscr(); /* clrscr function is used to clear the screen and it is good habit for programmers to use that function in the start of every program.*/
int var; // Variable Declaration
var = 1; // Value Assignment
cout<< " Value of var is: "; /* cout is use to print something in on the screen. In this line we simply print Value of var is: on the screen. */
cout<< var ; // in this result of this line value stored in var is shown on the screen.
getch(); /* this function is used to get character from the user. The purpose of this function at that place is only that we want to stop the execution and see the result of the program. If you donot use that function when you run the program it may only blink and do not show any result. */
} // Closing brackets of main function
In this program I try to teach you a simple structure of a C++ program and how a cout works. I use cout function in two different ways 1st is to print the message(Value of var is: ) and 2nd is to print the value stored in var which is 1.
Now your task is to read this post very carefully and practice it on your on pc.
InshAllah Next I will try to teach All of you the new function which is cin .
Today's Task is that i have to teach you a basic of C++.
Cout is an object. It is one of the members of iostream family, and iostream is a header file.
#include<iostream.h> // header file
#include<conio.h> // header file
void main() // main function
{ // Opening brackets of main function
clrscr(); /* clrscr function is used to clear the screen and it is good habit for programmers to use that function in the start of every program.*/
int var; // Variable Declaration
var = 1; // Value Assignment
cout<< " Value of var is: "; /* cout is use to print something in on the screen. In this line we simply print Value of var is: on the screen. */
cout<< var ; // in this result of this line value stored in var is shown on the screen.
getch(); /* this function is used to get character from the user. The purpose of this function at that place is only that we want to stop the execution and see the result of the program. If you donot use that function when you run the program it may only blink and do not show any result. */
} // Closing brackets of main function
In this program I try to teach you a simple structure of a C++ program and how a cout works. I use cout function in two different ways 1st is to print the message(Value of var is: ) and 2nd is to print the value stored in var which is 1.
Now your task is to read this post very carefully and practice it on your on pc.
InshAllah Next I will try to teach All of you the new function which is cin .
0 comments:
Post a Comment