Tuesday, February 28, 2017

 (17)Write a program to enter any number and check it is armstrong No or not in Cpp

vProgram

#include<iostream.h>
#include<conio.h>
class armstrong
{
  int n,no,r,c;
  public:
    palindrom()
    { r=0;
    }
    void getdata()
    {
     cout<<"\n\t\t Enter Number:";
    cin>>no;
    }
    void putdata()
    {        c=no;
      for( ;no>=1; )
      {
       n=no%10;
       r=r+(n*n*n);
       no=no/10;
      }
      if(c==r)
      {
      cout<<"\n\t\t A Number Is Armstrong !!";

      }
      else
      {
       cout<<"\n\t\t A Number Not Armstrong !!";
      }
     }
  };
  void main()
  {
   clrscr();
   armstrong p1;
   p1.getdata();
   p1.putdata();
   getch();
 }
vOutput:

Enter Number:153
A Number Is Armstrong !!

(16)write a program to enter any no and check it is prime No Or Not. in Cpp(Using Class)

vProgram


#include<iostream.h>
#include<conio.h>
class primeno
{
  int n,no,c;
  public:
    primeno()
    { c=0;
    n=1;
    }
    void input()
    {
     cout<<"\n\t\t Enter Number:";
    cin>>no;
    }
    void output()
    {
      while(n<=no)
      {
       if(no%n==0)
       {
         c++;
       }
       n++;
      }
      if(c==2)
      {
      cout<<"\n\t\t A Prime  Number ";
      }
      else
      {
       cout<<"\n\t\t A  Not Prime number!!";
      }
     }
  };
  void main()
  {
   clrscr();
   primeno p1;
   p1.input();
   p1.output();
   getch();
 }
vOutput

Enter Number:151
 A prime Number

(15)Write a Program to enter any no and check it is palidrom no or Not.in Cpp(using Class)

vProgram

#include<iostream.h>
#include<conio.h>
class palindrom
{
  int n,no,r,c;
  public:
    palindrom()
    { r=0;
    }
    void getdata()
    {
     cout<<"\n\t\t Enter Number:";
    cin>>no;
    }
    void putdata()
    {        c=no;
      while(no>=1)
      {
       n=no%10;
       r=(r*10)+n;
       no=no/10;
      }
      if(c==r)
      {
      cout<<"\n\t\t A Palindrom Number Is:"<<r;
      }
      else
      {
       cout<<"\n\t\t A Number Not Palindrom !!";
      }
     }
  };
  void main()
  {
   clrscr();
   palindrom r1;
   r1.getdata();
   r1.putdata();
   getch();
 }
vOutput

Enter Number:343
A Palindrom number Is:343

(14)Write a program to enter any No. and display reverse No. in CPP (Using Class)

vProgram
#include<iostream.h>
#include<conio.h>
class reverse
{
  int n,no,r;
  public:
    reverse()
    { r=0;
    }
    void getdata()
    {
     cout<<"\n\t\t Enter Number:";
    cin>>no;
    }
    void putdata()
    {
      while(no>=1)
      {
       n=no%10;
       r=(r*10)+n;
       no=no/10;
      }
      cout<<"\n\t\t A reverse Number Is:"<<r;
     }
  };
  void main()
  {
   clrscr();
   reverse r1;
   r1.getdata();
   r1.putdata();
   getch();
 }
vOutput

Enter Number:123
A reverse Number Is:321

(13)Write a Program to enter electronics util and total bill use following condition in Cpp


Unit        Rate        Perunit
100         0              50-0
200         1              150-50
300         2              250-200
400         3              350-450
500         4              450-800
>500       5              550-1250
vProgram
#include<iostream.h>
#include<conio.h>
void main()
{
  int unit,tot;
  clrscr();
  cout<<"\n\t\t Enter Unit:";
  cin>>unit;
  if(unit>500)
  {
    tot=(unit-500)*5+1000;
   }
   else if(unit>400)
   {
     tot=(unit-400)*4+600;

   }
   else if(unit>300)
   {
     tot=(unit-300)*3+300;
   }
   else if(unit>200)
   {
    tot=(unit-200)*2+100;

   }
   else if(unit>100)
   {
     tot=(unit-100)*1;

   }
   else
   {
     tot=0;
   }
   cout<<"\n\t\t Your Total Bill Is:"<<tot;
   getch();
   }
vOutput

Enter Unit:200
Your Total bill Is:100

(12) Write a Program to enter any number and check (i)it is divisible by 3 only (ii) it is divisible by 5 only (iii) it is divisible by 3 & 5 both in Cpp

vProgram
/*WAP divisible by 3 and 5 or both */
#include<iostream.h>
#include<conio.h>
void main()
{
 int no;
 clrscr();
 cout<<"\n\t\t Enter Number :";
 cin>>no;
 if(no%3==0)
 {
  if(no%5==0)
  {
    cout<<"divisible by 3 & 5";
    }
    else
    {
    cout<<"divisible by 3 Only";

    }
   }
   else
   {
      if(no%5==0)
      {
       cout<<"\n\t\t Divisible By 5 Only";
      }
      else
      {
       cout<<"\n \t\tnot Divisible 5 & 3";
       }
    }
    getch();
  }
vOutput

Enter number:30
Divisible by 3 & 5

(11)Write a program Enter Year Find It Leep YEAR Or Not. in C++

vProgram
#include<iostream.h>
#include<conio.h>
void main()
{
 int year;
 cout<<"Enter Check Year:";
 cin>>year;
 if(year%400==0)
 {
 cout<<year<<"\tLeap Year:";
 }
 else if(year%100==0)
 { cout<<year<<"\t NOT Leap Year:";
 }
 else if(year%4==0)
 {   cout<<year<<"\tLeap Year:";
 }
 else
 {   cout<<year<<"\tNOT Leap Year:";
 }
 getch();
 }
vOutput:

Enter Check Year:2016
2016  leap Year

(10)WAP Enter Salary And Bonuse Rate And Find Out Total Salary in cpp

vProgram
#include<iostream.h>
#include<conio.h>
void main()
{
  float salary,tot,bns;
  clrscr();
  cout<<"\n\t\tEnter Employee Salary:";
  cin>>salary;
  cout<<"\n\t\t Enter Bonuse Rate:";
  cin>>bns;
  tot=salary+(salary*bns/100); //Salary Plus Bonuse Formula

  cout<<"\n\t\t A Employee Total Salary Is:"<<tot;


  getch();
  }
vOutPut:

Enter Employee Salary:5000
Enter Bonuse Rate:5
A Employee Total Salary Is:5250

(9) WAP Simple Interest Find Out in cpp

vProgram.
#include<iostream.h>
#include<conio.h>
void main()
{
  int amount,rate,time,ans;
  clrscr();
  cout<<"\n\t\tEnter Amount:";
  cin>>amount;
  cout<<"\n\t\tEnter Rate:";
  cin>>rate;
  cout<<"\n\t\tEnter Time/year:";
  cin>>time;
  ans=(amount*rate*time)/100;//simple Interest Formula

  cout<<"\n\t\t A Simple Interest Is:"<<ans;

  getch();
  }

vOutput:

Enter Amout:1000
Enter Rate:10
Enter Time/Year:1
A Simple Interest Is:100