Vous êtes sur la page 1sur 15

# ID.

NO: - 096380307038

Practical – 1

## AIM: - Write a program to simple c++ programming statement.

Program: -

#include<iostream.h>

#include<conio.h>

int main()

clrscr();

getch();

return 0;

Output: -

## First program in c++

1
ID.NO: - 096380307038

Practical – 2

## AIM: - Write a Program to total of odd numbers.

Program: -

#include<iostream.h>

#include<conio.h>

int main()

int i,sum=0;

clrscr();

for(i=1;i<=100;i++)

if(i%2!=0)

sum=sum+i;

## cout<<"Sum Of Odd number between 1 to 100:"<<sum;

getch();

return 0;

2
ID.NO: - 096380307038

Output: -

## Sum Of Odd number between 1 to 100: 2500

3
ID.NO: - 096380307038

Practical – 3

## AIM: - Write a program to discount on bill.

Program: -

#include<iostream.h>

#include<conio.h>

int main()

int bill,dis,t;

clrscr();

cin>>bill;

if(bill>=500)

## cout<<"You get 20% Discount";

dis=(bill/100)*20;

t=bill-dis;

cout<<"\nTotal Bill:"<<t;

else if(bill>=300)

## cout<<"You get 10% Discount";

4
ID.NO: - 096380307038

dis=(bill/100)*10;

t=bill-dis;

cout<<"\nTotal Bill:"<<t;

else if(bill<300)

else

cout<<"Invalid";

getch();

return 0;

Output: -

## Total Bill: 610

5
ID.NO: - 096380307038

Practical - 4

## AIM: - Write a program of scope variable.

Program: -
#include<iostream.h>

#include<conio.h>

int m=10;

int main()

int m=20;

clrscr();

int k=m;

int m=30;

## cout<<"We are in Inner Block\n";

cout<<"K="<<k<<"\n";

cout<<"M="<<m<<"\n";

cout<<"::M="<<::m<<"\n";

## cout<<"\nWe are in Outer Block\n";

cout<<"M="<<m<<"\n";

cout<<"::M="<<::m<<"\n";

getch();

return 0;

6
ID.NO: - 096380307038

Output: -

k=20

m=30

::m=10

## We are in outer block

M=20

::m=10

7
ID.NO: - 096380307038

Practical – 5

## AIM: - Write a program to simple class.

Program: -

#include<iostream.h>

#include<conio.h>

class person

char name[30];

int age;

public:

void getdata(void);

void display(void);

};

void person::getdata(void)

cout<<"Enter Name:";

cin>>name;

cout<<"Enter Age:";

cin>>age;

void person::display(void)

cout<<"\nName:"<<name;

8
ID.NO: - 096380307038

cout<<"\nAge:"<<age;

int main()

person p;

clrscr();

p.getdata();

p.display();

getch();

Output: -

## Enter Name: Monark

Enter Age: 16

Name: Monark

Age: 16

9
ID.NO: - 096380307038

Practical – 6

AIM: - Write a Program to inner side and outer side class imtlementation.

Program: -

#include<iostream.h>

#include<conio.h>

class item

int number;

float cost;

public:

## void getdata(int a,float b);

void putdata(void)

cout<<"Number:"<<number<<"\n";

cout<<"Cost:"<<cost<<"\n";

};

## void item::getdata(int a,float b)

number=a;

cost=b;

int main()

10
ID.NO: - 096380307038

item x;

clrscr();

cout<<"\nObject X"<<"\n";

x.getdata(100,299.95);

x.putdata();

item y;

cout<<"\nObject Y"<<"\n";

y.getdata(200,175.50);

y.putdata();

getch();

Output: -

Object x

Number: 100

Cost: 299.95

Object y

Number: 200

Cost: 175.5

11
ID.NO: - 096380307038

Practical -7

## AIM: - Write a program to illustrates the use of inline functions.

Program: -

#include<iostream.h>

#include<conio.h>

return(x*y);

## inline double div(double p,double q)

return(p/q);

int main()

float a=12.345;

float b=9.82;

clrscr();

cout<<mul(a,b)<<"\n";

cout<<div(a,b)<<"\n";

getch();

12
ID.NO: - 096380307038

return 0;

Output: -

121.227898

1.257128

13
ID.NO: - 096380307038

Practical -8

Program: -

#include<iostream.h>

#include<conio.h>

int volume(int);

double volume(double,int);

long volume(long,int,int);

int main()

clrscr();

cout<<volume(10)<<"\n";

cout<<volume(2.5,8)<<"\n";

cout<<volume(100L,75,15)<<"\n";

getch();

return 0;

int volume(int s)

return(s*s*s);

## double volume(double r,int h)

14
ID.NO: - 096380307038

return(3.14519*r*r*h);

return(l*b*h);

Output: -

1000

157.2595

112500

15