0% found this document useful (0 votes)
97 views11 pages

Practicals On C++ Programming: 1. WAP To Print Hello On Screen

The document contains examples of C++ programs to solve common practical problems. The programs demonstrate printing text, calculating sums, swapping values, finding areas and perimeters, determining the greatest of three numbers, calculating percentages, and reversing integers. Each program example includes the code, inputs/outputs and solves a basic computational or logical problem.

Uploaded by

Rnks
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views11 pages

Practicals On C++ Programming: 1. WAP To Print Hello On Screen

The document contains examples of C++ programs to solve common practical problems. The programs demonstrate printing text, calculating sums, swapping values, finding areas and perimeters, determining the greatest of three numbers, calculating percentages, and reversing integers. Each program example includes the code, inputs/outputs and solves a basic computational or logical problem.

Uploaded by

Rnks
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Practicals on c++ programming

1. WAP to print hello on screen


#include<iostream.h>

#include<conio.h>

void main()

clrscr();

cout<<"HELLO";

getch();

output
2. WAP to find sum of two numbers
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

cout<<"enter first number : ";

cin>>a;

cout<<"enter second number : ";

cin>>b;

c=a+b;

cout<<"sum of two numbers is : "<<c;

getch();

output
3. WAP to swap two numbers using third variable
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

cout<<"enter first number : ";

cin>>a;

cout<<"enter second number : ";

cin>>b;

c=a;

a=b;

b=c;

cout<<a<<endl<<b;

getch();

output
4. WAP to find area of circle
#include<iostream.h>

#include<conio.h>

void main()

float r,a;

clrscr();

cout<<"enter radius of circle : ";

cin>>r;

a=3.14*r*r;

cout<<"area of circle is : "<<b;

getch();

output
5. WAP to swap two numbers without using third variable
#include<iostream.h>

#include<conio.h>

void main()

long int a,b;

clrscr();

cout<<"enter first number : ";

cin>>a;

cout<<"enter second number : ";

cin>>b;

a=a+b;

b=a-b;

a=a-b;

cout<<a<<endl<<b;

getch();

output
6. WAP to find reverse of any number
#include<iostream.h>

#include<conio.h>

void main()

long int r,s,n;

clrscr();

cout<<endl<<"enter any number : ";

cin>>n;

s=0;

while(n>0)

r=n%10;

s=s*10+r;

n=n/10;

Cout<<reverse :<<s;

getch();

}
output

7. WAP to find total marks and percentage


#include<iostream.h>

#include<conio.h>

void main()

float a,b,c,d,e,t,p;

clrscr();

cout<<"enter marks in mathematics ";

cin>>a;

cout<<"enter marks in FCPIT ";

cin>>b;

cout<<"enter marks in EME ";

cin>>c;

cout<<"enter marks in chemistry ";


cin>>d;

cout<<"enter marks in E.D. ";

cin>>e;

t=a+b+c+d+e;

p=(t/150)*100;

cout<<"total marks : "<<t<<endl;

cout<<"pecentage of marks : "<<p<<"%";

getch();

output

8. WAP to
find greatest
of three
numbers
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

cout<<"enter first number a : ";

cin>>a;

cout<<"enter second number b : ";

cin>>b;

cout<<"enter third number c : ";

cin>>c;
if(a>b&&b>c)

cout<<"a is greatest";

else if(b>a&&b>c)

cout<<"b is greatest";

else

cout<<"c is greatest";

getch();

output

9. WAP to find area & perimeter of rectangle

#include<iostream.h>

#include<conio.h>
void main()

clrscr();

int l,b,A,P;

cout<<"enter the value of l & b";

cin>>l>>b;

A=l+b;

cout<<"area of rectagle"<<A;

P=2*(l+b);

cout<<endl<<"perimeter of rectangle"<<P;

getch();

Output

You might also like