Skip to main content

basic syntax of c++


Basic syntax of c++ 


#include<iostream>     // it is  a library used for display
#include<conio.h>      // its is also a library used for input output statement
using namespace std;
main()                 // it is the start of you your program its means form here you will
                       // start the coding . .  computer only understand this main
                     
{                      // starting your program  from starting

cout<<"here is my first program in c++ "; // cout mean show me . . . << mean the thing infront of this <<
                                         // " is used to give a simple string and you should put this after
                                         // finishing your line . . . . and this ; is use to finish your one
                                         // statement.

}

/* when you are going to save your this program you should give his extension cpp */

put this program in your Dev c++ compiler

Comments

Popular posts from this blog

Cin function

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { int a,b; // two variable are taken as a and b cout<<"enter a value "<<endl; /* as you know cout is used to print out your comment enclosed in " " this                              endl is used for next line */ cin>>a;        /* here is new thing "cin" it is used to input values on running time of program*/ cout<<"enter a value "<<endl; /* as you know cout is used to print out your comment enclosed in " " this                              endl is used for next line */ cin>>b;        /* here is new thing "cin" it is used t...

Temperature Convertor

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { float c,f ;   // as i discussed earlier float is used for floating values like value is decimel so two variable are take  cout<<"Enter the temperature in Fahrenheit  ? :"; // its just comment whatever you want can add here within "" after cout  cin>>f;                                         // giving a value which will convert the program to Fahrenheit c= (f-32)*5.0/9.0;      // it is the formula to convert to fahrenheit cout<<"Temperature in celsius = "<<c; // here its show the value save in the c throgh the formula   } /* Here is your temperature converter to farhrenheid is ready */

Age Calculator

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { int age;           // age variable with datatype int long int age_month; /* long is also a datatype but it can hold more bigger data then int                      so variable age_month with datatype long */ char name[50];     // char is datatype with variable name name it can only hold character like " naveed" cout<<"Enter name of person:"<<endl; // will output Comment "enter the name of person cin>>name;                   //here is input object through which you can enter the name of person cout<<"enter the age of person in year:"<<endl; // here its output the comment "enter the age " cin...