Assignment 1
Assignment 1
#include <iostream>
int main()
{
if(0)
{
std::cout<<"Hi";
}
else
{
std::cout<<"Bye";
}
return 0;
}
(A) Hi
(B) Bye
(C) HiBye
(D) Compilation Error
Question: 2 What is size of int data type in C++?
(A) 2 Bytes
(B) 4 Bytes
(C) 1 Byte
(D) Depends on Compiler
(A) +
(B) -
(C) *
(D) ::
#include<iostream>
int main()
{
int a=10;
std::cout<<a++;
return 0;
}
(A) 11
(B) 10
(C) Error
(D) 0
(A) Yes
(B) No
(C) Compilation Error
(D) Runtime Error
int main()
{
const int a=10;
a++;
std::cout<<a;
return 0;
}
(A) 10
(B) 11
(C) Compilation Error
(D) Linking Error
(A) 4.5
(B) 4.0
(C) 4
(D) Compilation Error
Question: 8
What is output of the below C++ program?
int main()
{
int a=10;
int b,c;
b = a++;
c = a;
std::cout<<a<<b<<c;
return 0;
}
(A) 111011
(B) 111111
(C) 101011
(D) 101010
Question: 9 #include<iostream>
class Mycpp
{
int Mycpp()
{
std::cout<<"Constructor";
return 0;
}
};
int main()
{
Mycpp obj;
return 0;
}
(A) Constructor
(B) 0
(C) Compilation Error
(D) Runtime Error
(A) 1
(B) 5
(C) There is no limit
(D) 256
(A) Single
(B) Byte
(C) Short
(D) Integer
(A) class
(B) field
(C) function
(D) property
Question: 13 What is the purpose of 'default' keyword in C++?