1) Which header file is required to run this program?
#include <.....>
int main()
{
cout<<"Hello World.";
return 0;
}
- stdio.h
- conio.h
- iostream.h
- ostream.h
Correct Answer - 3
iostream.h
2) Which is the correct statement to print the value of age?
#include <iostream.h>
int main()
{
int age=19;
.....
return 0;
}
- cout << "Age: %d",age;
- cout << "Age: %d" << age;
- cout << "Age: " + age;
- cout << "Age: " << age;
Correct Answer - 4
cout << "Age: " << age;
3) What will be the output of following program?
#include <iostream.h>
int a=10;
int main()
{
int a=20;
cout<<::a;
return 0;
}
- 10
- 20
- ::10
- ::20
Correct Answer - 1
10
:: is a Scope Resolution Operator, it is used to access the value of global variable and ::a will return the value of global declared variable.
5) Which header file is required to use setw() function?
- conio.h
- iostream.h
- stdlib.h
- iomanip.h
Correct Answer - 4
iomanip.h
setw() is a manipulator and it is declared in iomanip.h header file.
7) What will be the output of following programs?
#include >iostream>
using namespace std;
int main()
{
cout <<P"includehelp.com";
return 0;
}
- Compile Time Error
- Run Time Error
- includehelp.com
- None of these.
Correct Answer - 1
Compile Time Error
main.cpp:7:11: error: 'P' was not declared in this scope
cout <<P"includehelp.com";
^