C++ programming basic input, output, data types, declaration Aptitude Questions and Answers

This section contains C++ programming Basic Input, Output, Data types, Declaration etc Aptitude Questions and Answers with explanations.

List of C++ programming basic Aptitude Questions and Answers

1) Which header file is required to run this program?
#include <.....>
int main()
{
	cout<<"Hello World.";
	return 0;
}    
    
  1. stdio.h
  2. conio.h
  3. iostream.h
  4. ostream.h

2) Which is the correct statement to print the value of age?
#include <iostream.h>
int main()
{
	int age=19;
	.....
	return 0;
}
    
  1. cout << "Age: %d",age;
  2. cout << "Age: %d" << age;
  3. cout << "Age: " + age;
  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;
}
    
  1. 10
  2. 20
  3. ::10
  4. ::20



5) Which header file is required to use setw() function?
  1. conio.h
  2. iostream.h
  3. stdlib.h
  4. iomanip.h

6) Why setw() is used?
  1. To set width of the variable in memory.
  2. To pad the value with space or any defined special character of next variable.
  3. To set the white spaces in the input buffer.
  4. None of these.

7) What will be the output of following programs?
#include >iostream>

using namespace std;

int main()
{
   cout <<P"includehelp.com";
   
   return 0;
}
    
  1. Compile Time Error
  2. Run Time Error
  3. includehelp.com
  4. None of these.





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.