Professional Documents
Culture Documents
Akash Sethi
Akash Sethi
Sol:
#include<iostream.h>
#include<conio.h>
void main ( )
{
int a , b , c , s ;
void sum ( )
clrscr ( );
sum ( );
getch ( );
}
void sum ( )
{
cout<<” Enter three numbers “ ;
cin>>a>>b>>c;
s=a+b+c;
cout<<” \n The sum of three numbers is “ << s;
}
OUTPUT
a = 30
a = 20
a = 10
Q. WAP to Illustrate Global Variables?
Sol.
# include <iostream.h>
#include <conio.h>
int i = 0 ;
void main ( )
{
void test ( );
void demo ( );
clrscr ( );
cout <<” i = “<<i<<”\n”;
test ( );
demo ( );
getch ( );
}
void test ( )
{
i = i + 10;
cout <<” i = “<<i<<”\n”;
}
void demo( )
{
i = i – 5;
cout <<” i = “<<i;
}
OUTPUT
i=0
i = 10
i=5
Q. 4. WAP to find the cube of a given number by passing argument and return type?
Sol.
#include <iostream.h>
#include <conio.h>
void main ( )
{
int cube (int);
int n;
clrscr ( );
cout <<“Enter the number”;
cin >> n;
cube (n);
getch ( );
}
int cube (int x)
{
int y;
y = x * x * x;
cout <<”\n cube is “<<y;
}
OUTPUT