What will be the output of the following programs ?
(a) # include < iostream.h>
void add (float);
void main ( )
{
float x = 5.0;
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
(b) # include < iostream.h >
void add (float);
float x = 5.0;
void main ( )
{
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
(c) # include < iostream.h >
float add (float);
void main ( )
{
float x = 5.0;
float y;
y = add (x);
cout << x << " " << y < < "\n"
}
float add (float x)
{
return (x +2);
}
(d) # include < iostream.h >
void P1 (int &, int);
void main ( )
{
int a = 5;
int b = 6;
cout << "output of the program \n";
cout << "values of a and b are " << a << b << "\n";
P1 (a, b);
cout << "values of a and b are" << a << b;
}
void P1 (int & a, int b)
{
a = 7 ;
b = 10 ;
}
(e) include < iostream.h >
int a, b;
void try2 (int x, int & y);
void main ( )
{
int a = 10 ;
int b = 7 ;
try2 (a, b);
cout << a << b << "\n";
}
MODULE – 3
327
Functions
Computer Science
Programming in C++
Notes
void try2 ( int x, int & y)
{
b = x;
y = y + b;
x = y;
cout << x << y << b << "\n";
}y = add (x);
cout << x << " " << y < < "\n"
}
float add (float x)
{
return (x +2);
}
(d) # include < iostream.h >
void P1 (int &, int);
void main ( )
{
int a = 5;
int b = 6;
cout << "output of the program \n";
cout << "values of a and b are " << a << b << "\n";
P1 (a, b);
cout << "values of a and b are" << a << b;
}
void P1 (int & a, int b)
{
a = 7 ;
b = 10 ;
}
(e) include < iostream.h >
int a, b;
void try2 (int x, int & y);
void main ( )
{
int a = 10 ;
int b = 7 ;
try2 (a, b);
cout << a << b << "\n";
}
MODULE – 3
327
Functions
Computer Science
Programming in C++
Notes
void try2 ( int x, int & y)
{
b = x;
y = y + b;
x = y;
cout << x << y << b << "\n";
}
Answers
Answered by
3
What will be the output of the following programs ?
(a) # include < iostream.h>
void add (float);
void main ( )
{
float x = 5.0;
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
(b) # include < iostream.h >
void add (float);
float x = 5.0;
void main ( )
{
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
(c) # include < iostream.h >
float add (float);
void main ( )
{
float x = 5.0;
float y;
y = add (x);
cout << x << " " << y < < "\n"
}
float add (float x)
{
return (x +2);
}
(d) # include < iostream.h >
void P1 (int &, int);
void main ( )
{
int a = 5;
int b = 6;
cout << "output of the program \n";
cout << "values of a and b are " << a << b << "\n";
P1 (a, b);
cout << "values of a and b are" << a << b;
}
void P1 (int & a, int b)
{
a = 7 ;
b = 10 ;
}
(e) include < iostream.h >
int a, b;
void try2 (int x, int & y);
void main ( )
{
int a = 10 ;
int b = 7 ;
try2 (a, b);
cout << a << b << "\n";
}
MODULE – 3
327
Functions
Computer Science
Programming in C++
Notes
void try2 ( int x, int & y)
{
b = x;
y = y + b;
x = y;
cout << x << y << b << "\n";
}y = add (x);
cout << x << " " << y < < "\n"
}
float add (float x)
{
return (x +2);
}
(d) # include < iostream.h >
void P1 (int &, int);
void main ( )
{
int a = 5;
int b = 6;
cout << "output of the program \n";
cout << "values of a and b are " << a << b << "\n";
P1 (a, b);
cout << "values of a and b are" << a << b;
}
void P1 (int & a, int b)
{
a = 7 ;
b = 10 ;
}
(e) include < iostream.h >
int a, b;
void try2 (int x, int & y);
void main ( )
{
int a = 10 ;
int b = 7 ;
try2 (a, b);
cout << a << b << "\n";
}
MODULE – 3
327
Functions
Computer Science
Programming in C++
Notes
void try2 ( int x, int & y)
{
b = x;
y = y + b;
x = y;
cout << x << y << b << "\n";
}
PLEASE MAKE ME AS A BRAINLIST ANSWER BRO
Answered by
0
The compilation is terminated in all three cases.
Given,
code a.) # include < iostream.h>
void add (float);
void main ( )
{
float x = 5.0;
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
To find:
The output of the code.
Solution:
The compilation will be terminated.
code b.) # include < iostream.h >
void add (float);
float x = 5.0;
void main ( )
{
add (x);
cout << x ;
}
void add (float x)
{
x = x + 2;
}
Solution:
The compilation will be terminated.
code c.) # include < iostream.h >
float add (float);
void main ( )
{
float x = 5.0;
float y;
y = add (x);
cout << x << " " << y < < "\n"
}
float add (float x)
{
Solution: The compilation will be terminated.
The compilation is terminated in all three cases.
Similar questions