C++ Programming - Functions
Exercise : Functions - Programs
- Functions - General Questions
- Functions - Programs
1.
What will be the output of the following program?
#include<iostream.h>
long BixFunction(int x, int y = 5, float z = 5)
{
return(++x * ++y + (int)++z);
}
int main()
{
cout<< BixFunction(20, 10);
return 0;
}
2.
What will be the output of the following program?
#include<iostream.h>
int BixFunction(int a, int b = 3, int c = 3)
{
cout<< ++a * ++b * --c ;
return 0;
}
int main()
{
BixFunction(5, 0, 0);
return 0;
}
3.
What will be the output of the following program?
#include<iostream.h>
void MyFunction(int a, int b = 40)
{
cout<< " a = "<< a << " b = " << b << endl;
}
int main()
{
MyFunction(20, 30);
return 0;
}
4.
Which of the following statement is correct about the program given below?
#include<iostream.h>
static int b = 0;
void DisplayData(int *x, int *y = &b)
{
cout<< *x << " " << *y;
}
int main()
{
int a = 10, b = 20 ;
DisplayData(&a, &b);
return 0;
}
5.
What will be the output of the following program?
#include<iostream.h>
typedef void(*FunPtr)(int);
int Look(int = 10, int = 20);
void Note(int);
int main()
{
FunPtr ptr = Note;
(*ptr)(30);
return 0;
}
int Look(int x, int y)
{
return(x + y % 20);
}
void Note(int x)
{
cout<< Look(x) << endl;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers