Wednesday, 18 December 2013

Even or Odd For 1 to 100 Number Using C++


#include<iostream.h>
#include<conio.h>
void main()
{
  int  i;
  for(i=1;i<=100;i++)
  {
  if(i%2==0)
  {
                  cout<<i<<"  number is even \n “;
   }
  else
  {
                 cout<<i<<"   number is odd\n“;
  }
}
  getch();

}

Given Number Even Or Odd Using C++


#include<iostream.h>
#include<conio.h>
void main()
{
  int  num;
cout<<" Even or odd Number given by user\n “;
 cout<<" Enter number for verification  “;
 cin>>num;
if(num%2==0)
  {
  cout<<" Given number is even   “;
   }
  else
  {
      cout<<" Given number is odd“;
  }
 getch();
}

Fibonacci Series Using C++

/*Fibonacci  Series up to user Given number Using C++
   Series Limit is Defined by User
*/
#include<iostream.h>
#include<conio.h>
void main()
{
  int  n,i,fst=0,sec=1,num;
  cout<<" Enter number for Fibonacci  Series “;
  cin>>num;
  cout<<" Fibonacci Series 0 to” <<num <<”number”;
  for(i=0;i<= num;i++)
  {
  if(i<=1)
  {
    n=i;
  }
  else
  {
    n= fst+sec;
   fst=sec;
   sec=n;
  }
 Cout<<”\t”<<n;
 }
 getch();
}

PROGRAM TO ADDITION TWO NUMBERS USING C++



#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  int a,b,sum;
  cout<<"enter  the value of number 1 and number 2";
  cin>>a>>b;
  sum=a+b;
  cout<<"\n"<<"sum of "<<" number 1 ="<<a<<" number  2="<<b<<”is”<<sum;
  getch();
}

Fibonacci Series up to 1 to 100 Using c++


#include<iostream.h>
#include<conio.h>
void main()
{
  int  n,i,fst=0,sec=1;
  cout<<" Fibonacci  Series up to 1 to 100";
  for(i=0;i<=100;i++)
  {
  if(i<=1)
  {
    n=i;
  }
  else
  {
    n= fst+sec;
   fst=sec;
   sec=n;
  }
Cout<<”\t”<<n;
}
  getch();
}

PROGRAM TO FIND LEAP YEAR USING C++


/*THIS PROGRAM CHECKS WHETHER THE
ENTERED YEAR IS LEAP OR NOT*/

#include<iostream.h>
#include<conio.h>
void main()
{
 int n;
 cout<<"enter the year";
 cin>>n;
 if(n%4==0)
 {
  cout<<"entered year is leap year";
 }
 else
 {
  cout<<"the entered year is not leap year";
 }
 getch();
}

TWO NUMBERS INTERCHANGE WITHOUT USING THE THIRD VARIABLE IN C++


#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  int a,b;
  cout<<"enter  the value of number 1 =”;
  cin>>a;
  cout<<"enter  the value of number 2";
  cin>>b;
  a=a+b;
  b=a-b;
  a=a-b;
 
  cout<<"\n"<<"after interchanging value of"<<" number 1 ="<<a<<"\n"<<" number  2="<<b;
  getch();
}
/*THIS PROGRAM ACCEPT TWO NUMBERS AS INPUT AND GENERATE TWO NUMBER IN OUTPUT BY     SWAPPING THEIR VALUES*/