Time:
00:
00:
00What is the output of below code?
#include <iostream>
using namespace std;
int main()
{
int number=0141;
printf("%c",number);
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
0141 means that in the octal base, %c will print the character value.
Octal value of a is 141 so, a get printed.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What is the output of the following
#include <iostream>
using namespace std;
int main()
{
int m=10;
int n=m<<2;
printf("%d",n);
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Explanation : Since, m =10, and n=m<<2 => n = m*(2^2) => n=10*4 =>n =40.
As, << is the bitwise left shift operator.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code
Integer TruckTyres=8;
Integer trucktyres =6;
Display TruckTyres
Display trucktyres
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Explanation :As, TruckTyres=8 and trucktyres =6 so,
Display TruckTyres //Prints 8
Display trucktyres //Prints 6
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
#include <iostream>
int main()
{
int digit=8 ;
printf("%d",digit<<1);
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Here in the code a bitwise left shift operator is used. A single left shift multiplies a binary number by 2.
Hence if we do left shift operation on a digit variable this will multiply the number by 2. And 8 * 2 =16 hence the solution is 16.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
#include <iostream>
int function1(int,int);
int main()
{
int a=10,b=10;
printf("%d",function1(a,b));
return 0;
}
int function1(int a , int b)
{
return(a-(a==b));
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
The print function1 will be called with a=10 and b=10 this function is returning
a-(a==b) first the checking will take place whether a is equal equal to b or not. As a is equal to b that is 10 this is true so we will get 1.
Now a-1 (ie) 10-1 = 9
Hence 9 is the output.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
#include<iostream>
using namespace std;
int main()
{
int a=5,b=0,c=15,d=20,e=0;
while(a<b)
e=(a+c)*d+c;
cout<<e<<""<<b;
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Check the condition in the while loop it’s false in the first iteration itself hence the value of e=0 and b=0 that is initialized earlier will be printed on the console.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code:
#include<iostream>
using namespace std;
int main()
{
int num=5,i;
long int result=1;
for(i=num;i>(num-num);i--){
result=result*i;
}
printf("%d",result);
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Initially the value of num=5
In the for loop 5 > 0 condition is true
result=1*5 //5
Again will check condition now i=4 and 4>0
result=5*4 //20
Again will check condition now i=3 and 3>0
result = 20*3 //60
Again will check condition now i=2 and 2>0
result = 60*2 //120
Again will check condition now i=1 and 1>0
result = 120*1 //120
Now the value of i=0 and 0>0 condition is false
At this point the value of result = 120 hence the output will be 120
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
Integer x,y,z
Set z=6,y=8,x=9
if(z>x && y>z)
z=x+y-1
Else
x=y-z+9
End if
Print x+y+z
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
First the condition inside the if block will be checked (Z > X)
(6>8 && 8>9) since (6 is not greater than 8)the condition is false
The control will jump to the else part of the block that is
x=y-z+9
Here the value of x= 8-6+9 = 11
Hence the solution is 11
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
#include <iostream>
using namespace std;
int main()
{ char *p="1st code";
printf("%c\n",*&*p);
return 0;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Here the * and & will equalize and we will be remaining with *p in other words *&* can be written as *p (this is pointing to the 0th index of the string)
Hence the output is 1.
Please login to submit your explanation
Login to see your performance analytics by signing in
Time:
00:
00:
00What will be the output of the following code below
#include
int func(int);
int main()
{
int i = func(100);
printf("%d" ,++i);
return 0;
}
int func (int i)
{
return i*i;
}
PrepInsta Explanation
User Explanation
Once you attempt the question then PrepInsta explanation will be displayed.
Ans:- value of i= func(100) this will call the func function 100 as a parameter
This func will return 10000 and now the value of i=10000
While printing there is a pre-increment of i that is ++i so here the value will be first updated and used.
Hence the value printed on console will be 10000+1 (ie) 10001
Please login to submit your explanation
Login to see your performance analytics by signing in
["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]