Saturday, August 18, 2012

ch-8 practicle file output by Anand Ohri


     

 Sumita Arora Class --XI  C++ Answer Programme code 01

In this Blog You can find the answer program of chapter 8 which are important
If you have not Downloaded C++ turbo downlaod from this link

For Windows 7 and XP wether  64/32 Bit check this if showing error install dos box
https://docs.google.com/open?id=0B5n8JG_4DZBFNWtfQ01pTHd3ejQ

     CHAPTER – 8  (BY: Anand Ohri)

Q28

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{     clrscr();
unsigned int n;
int X;
      cout<<"Enter value of X and n-";
      cin>>X>>n;
      cout<<pow(X,n);
      getch();
}

Q29

#include<iostream.h>
#include<conio.h>
void main()
{     clrscr();
float time, amount;
      cout<<"Enter principal amount-";
      cin>>amount;
      cout<<"Enter time-";
      cin>>time;
      cout<<((time>10)?(amount*time*12):(amount*time*8));  //error in the formula of simple intrest do correct yourself
      getch();
}

Q30

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{     clrscr();
int num;
      cout<<"Enter a number-";
      cin>>num;
      cout<<((num%2==0)?(pow(num,2)):(pow(num,3)));
      getch();
}

Q31
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{     clrscr();
int n;
      cout<<"Enter value of n-";
      cin>>n;
      cout<<((n%2==1&&n==(unsigned)(int)n)?(sqrt(n)):(pow(n,5)));
      getch();
}

Q32
#include<iostream.h>
#include<conio.h>
void main()
{     clrscr():
float val, r;
      cout<<"Select 1 or 2-";
      cin>>val;
      cout<<"Enter radius-";
      cin>>r;
      cout<<((val==1)?(3.14*r*r):(3.14*2*r));
      getch();
}

Q33
#include<iostream.h>
#include<conio.h>
void main()
{     clrscr();
int a,b,c;
      cout<<"Enter three integers-";
      cin>>a>>b>>c;
      cout<<((a>b&&a>c)?(a):((b>c)?b:c));
      getch();
}

Q34
#include<iostream.h>
#include<conio.h>
void main()
{     clrscr();
char ch;
      cout<<"Enter student type ('A'or 'B')-";
      cin>>ch;
      cout<<((ch=='A')?("College Account Rs 200/-"):("Hostel Account Rs 200/-"));
      getch();
}



Chapter- 8
Q35
#include<iostream.h>
#include<conio.h>
void main()
{     clrscr();
      char ch;
      cout<<"Enter character : ";
      cin>>ch;
      (ch>='A'&&ch<='Z' || ch>='a'&&ch<='z') ? ( (ch>='A'&&ch<='Z')?cout<<"Upper case \n Lower case character is "<<(char)(ch+32):cout<<"lower case\n Upper case character is "<<(char)(ch-32)):cout<<"Not a character";
      getch();
}

1 comment:

Post a Comment