Tuesday, 15 May 2018

how to get values from user in c++

#include<iostream>
using namespace std;
int main()
{
   
     int a,b;
     cout<<"Enter two number please "<<endl;
     cin>>a;
     cin>>b;
      int sum;
      sum=a+b;
      cout<<"sum is "<<sum;
}

how to declare a variable in c++

//A variable is that whose value can be change during the program execution



#include<iostream>
using namespace std;
int main()
{
      int a=10;
      int b=3;
      int sum;
      sum=a+b;
      cout<<"sum is "<<sum;
}

escape sequences in c++

\n  for new line
\t for tab


for new line 

#include<iostream>
using namespace std;
int main()
       cout<<"this is my\n book";
}

for tab

#include<iostream>
using namespace std;
int main()
       cout<<"this is my\tbook";
}

c++ program that print hello world

#include<iostream>
using namespace std;
int main()
{
       cout<<"Hello world";
}