These are the c++/cpp objective questions related to coding. these objective questions consists of programs to test your knowledge on syntax's. so learn the concepts and check these objective questions to test and improve your programming and error debugging skills. I am sharing 10+ objective questions related to programs in cpp in this post. practice all these objective questions and improve your programming skills.
C++/cpp objective questions on coding to practice useful for beginners :-
1)
If the variable count exceeds 100, a single statement that prints “Too many” is(A) if (count<100) cout << “Too many”;
(B) if (count>100) cout >> “Too many”;
(C) if (count>100) cout << “Too many”;
(D) None of these.
Ans:C
2)
If x = 5, y = 2 then x Ù y equals________.(where Ù is a bitwise XOR operator)
(A) 00000111 (B) 10000010 (C) 10100000 (D) 11001000
Ans: A
3)
If an array is declared asint a[4] = {3, 0, 1, 2}, then values assigned to a[0]& a[4] will be ________
(A) 3, 2 (B) 0, 2 (C) 3, 0 (D) 0, 4
Ans: C
4)
Consider the following statements:int x = 22, y=15;
x = (x>y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?
(A) 22 (B) 37
(C) 7 (D) Error. Cannot be executed
Ans:B
5)
What is the output of given code fragment?int f=1, i=2;
while(++i<5)
f*=i;
cout<<f;
(A) 12 (B) 24
(C) 6 (D) 3
Ans:A
6)
What will be the values of x, m and n after the execution of the following statements?int x, m, n;
m = 10;
n = 15;
x = ++m + n++;
(A) x=25, m=10, n=15 (B) x=26, m=11, n=16
(C) x=27, m=11, n=16 (D) x=27, m=10, n=15
Ans:B
7)
Which of the following will produce a value 10 if x = 9.7?(A) floor(x) (B) abs(x)
(C) log(x) (D) ceil(x)
Ans:D
8)
Which of the following expressions is illegal?(A) (10 6). (B) (false && true)
(C) bool (x) = (bool)10; (D) float y = 12.67;
Ans:C
9)
What would be the output of the following program?int main()
{
int x,y=10,z=10;
x = (y = =z);
cout<<x;
return 0;
}
(A) 1 (B) 0 (C) 10 (D) Error
Ans:A
10)
What is the error in the following code?class t
{
virtual void print();
}
(A) No error.
(B) Function print() should be declared as static.
(C) Function print() should be defined.
(D) Class t should contain data members.
Ans:A
11)
What will be the output of following program?#include<iostream.h>
void main()
{
float x;
x=(float)9/2;
cout<<x;
}
(A) 4.5 (B) 4.0 (C) 4 (D) 5
Ans:A
12)
What would be the output of the following?#include<iostream.h>
void main()
{
char *ptr=“abcd”
char ch;ch = ++*ptr++;
}
(A) a (B) b
(C) c (D) d
Ans:B
13)
What will be the output of the following program?#include<iostream.h>
void main()
{
float x=5,y=2;
int result;
result=x % y;
cout<<result;
}
(A) 1 (B) 1.0
(C) Error message (D) 2.5
Ans:C
More C Objective Questions related to other concepts :-
There are more c objective questions related to other concepts. learn all those concepts and improve your programming skills.click here for more objective type questions on c programming.
Recommended for you :-
Complete C Programming Tutorials
C Programming Exercises
C Solved Programs
C Programming Useful Tips
Thanks for posting this great post. Do have a nice day...
ReplyDelete√
√
Check.. Twerk it VPN 4g app download
*
All coming from W3HowTo.com
This is my best game so far, I do play it day and night after downloading the Pokémon Go app apk online.
.
But I need to improve my ability in playing the android game...I wonder if this will turn out one day to become the best Xbox game
.
Thanks for this updating this post!! Do have a nice day.
My regards,
Joseph
W3HowTo.com