14 Nov 2011

C++ If-Else and Do-While Loop


using C++ If-Else statement and Do-While Loop to find the smaller number
#include<iostream.h>
#include<conio.h>
main()
{
char m;
do
{
clrscr();
int i,j;
cout<<"\n\t\tEnter First Number=";
cin>>i;
cout<<"\n\t\tEnter second number=";
cin>>j;
if(i<j)
{
cout<<"\n\t\tFirst number is Smaller"<<endl;
}
else
{
cout<<"\n\t\tSecond number is Smaller"<<endl;
}
cout<<"\t\t\tTo stop the process press \"s\" and"<<endl;
<<"\t\t\t"<<"To continue press any key"<<endl;
m=getche();
}
while(m!='s' && m!='S');
return 0;
}

C++ If-Else Statement


using c++ if-else statement
#include<iostream>

using namespace std;

main()
{
int a=1;
if(a==1)
{
cout<<"Yes";
}
else
{
cout"no";
}

return 0;

}

C++ variable processing


// Processing of  variables using addition and subrraction

#include <iostream>
using namespace std;

int main ()
{
  // declaring variables:
  int a, b;
  int result;

  // processing:
  a = 10;
  b = 10;
  a = a + 1;
  result = a - b;

  // printing :
  cout << result;

  return 0;
}

C++ Data Types

C++ have man data types that is used top stored variables in computer memory. using different data types computer compiler can easily understand the or identify the character, numbers and etc... some of the important and commonly used data types are

  • int
  • char
  • string
  • long int
  • float
  • bool
  • double 
  • long dounle