Professional Documents
Culture Documents
II PUC Accountancy Question Bank 2019new
II PUC Accountancy Question Bank 2019new
II PUC Accountancy Question Bank 2019new
{ Output :
SimpleInterest si; enter principle amount , time and rate: 5000, 5.5,
clrscr( ); 8.75
si.readdata( ); principle: 5000
si.compute( ); time: 5.5
si.display( ); rate: 8.75
getch( ); simple intrest: 2406.25
}
LAB PROGRAM – 7
Write a C++ program to create a class with data x=-b/(2*a);
members a, b, c and member functions to input cout<<"Root is."<<x;
data, compute the discriminant based on the }
following conditions and print the roots. else
If discriminant = 0, print the roots are if(disc>0)
equal and their value. {
If discriminant > 0, print the real roots and
their values. cout<<"Real and Distinct Roots..."<<endl;
If discriminant < 0, print the roots are x1=(-b+sqrt(disc))/(2*a);
imaginary and exit the program. x2=(-b-sqrt(disc))/(2*a);
cout<<"Root 1 is "<<x1<<endl;
#include<iostream.h> cout<<"Root 2 is "<<x2<<endl;
#include<conio.h> }
#include<math.h> else
class Quadratic cout<<"Imaginary Roots..."<<endl;
{ }
private: void main( )
int a, b, c; {
float disc, x, x1, x2; Quadratic q;
clrscr( );
public: q.readdata( );
void readdata( ); q.display( );
void compute( ); getch( );
void display( ); }
};
output 1:
void Quadratic::readdata( ) Enter the co-efficients: 1 2 1
{ roots are equal
cout<<"Enter the values for a, b, c (Co- first root=-1
efficeient)"<<endl; second root=-1
cin>>a>>b>>c;
} output 2:
Enter the co-efficients:2 -3 1
void Quadratic::compute( ) roots are positive and different
{ first root=1
disc = b*b-4*a*c; second root=0.5
}
if(ans==2)
Write a C++ program to find the area of square/ {
rectangle/ triangle using function overloading. cout<<"enter two sides:";
#include<iostream.h> cin>>x>>y;
#include<conio.h> cout<<"area of the
#include<stdlib.h> rectangle="<<f1.area(x,y)<<endl;
#include<math.h> }
class funcoverload else
{ if(ans==3)
float s; {
public: double area(double a) cout<<"enter three sides: ";
{ cin>>x>>y>>z;
return a*a; cout<<setprecision(8);
} cout<<"area of triangle="<<f1.area(x,y,z)<<endl;
double area(double l , double b) }
{ else
return l*b; cout<<"invalid input";
} getch();
double area(double a, double b, double c) }
{
s=(a+b+c)/2.0; OUTPUT1:-
return(sqrt(s*(s-a)*(s-b)*(s*b))); Enter the number of inputs (1,2,3) :1
} enter the side: 4.5
}; Area of the square = 20.25
void main()
{ OUTPUT 2:-
clrscr(); Enter the number of inputs (1,2,3) :2
double x,y,z; enter the side: 4.5, 2.75
int ans; Area of the retangle = 12.375
funoverload f1;
cout<<"enter the number of inputs(1,2,3):"; OUTPUT 3:-
cin>>ans; Enter the number of inputs (1,2,3) :3
if(ans==1) enter the side: 2,3.5,2.75
{ Area of the triangle =2.74462
cout<<"enter the side:";
cin>>x; output 4:-
cout<<"area of the square="<<f1.area(x)<<endl; Enter the number of inputs (1,2,3) :5
} invlid input
else
LAB PROGRAM – 9
clrscr( );
Write a C++ program to find cube of a number cout<<"Enter the input number"<<endl;
using inline function. cin>>n;
#include<iostream.h> cout<<"Cube of"<<" = "<<cube(n);
#include<conio.h> getch( );
}
inline int cube(int a) OUTPUT 1:
{ Enter a nmber:- -5
return a*a*a; cube of -5 = -125
}
OUTPUT 2:
void main() Enter a nmber:10
{ cube of 10 = 1000
int n;
LAB PROGRAM – 10
Write a C++ program to find sum of the series 1 + sum=sum+pow(x,i);
x + x2 + x3 + ….xn using constructors. return sum;
#include<iostream.h> }
#include<conio.h> void main()
#include<math.h> {
class Series int x,n;
{ clrscr( );
private: cout<<"Enter the value for Base(X)="<<endl;
int sum, x, n; cin>>x;
cout<<"Enter the value for Power(n)"<<endl;
public: cin>>n;
int sumseries( ); Series s1(x,n);
Series s2 = s1;
cout<<"Sum of Series using Parameterised
Series(int y, int m) Constructor:";
{ cout<<s1.sumseries()<<endl;
cout<<"Sum of Series using Copy Constructor:";
sum = 1; x = y; cout<<s2.sumseries( );
n = m; getch( );
} }
OUTPUT 1:
};
Enter the base and the power(x,n): 2 , 5
Object1: sum of the series is 63
int Series::sumseries( ) object2: sum of the series is 63
{
for(int i=1;i<=n; i++)
LAB PROGRAM – 11
cin>>name;
Create a base class containing the data member }
roll number and name. Also create a member void display( )
function to read and display the data using the {
concept of single level inheritance. Create a cout<<"\nRollNumber:"<<rollnumber<<endl;
derived class that contains marks of two subjects cout<<"Student Name:"<<name<<endl;
and total marks as the data members. }
#include<iostream.h> };
#include<conio.h>
class Report : public Student
class Student {
{ private:
private: int marks1, marks2, total;
int rollnumber;
char name[20]; public:
public:
void readmarks( )
{
void readdata( )
{ cout<<"\nEnter Subject 1 Marks: ";
cin>>marks1;
cout<<"Enter the Roll Number: "; cout<<"Enter Subject 2 Marks: ";
cin>>rollnumber; cin>>marks2;
cout<<"Enter the Student Name:"; }
void Student::display( )