What will be output of following program?
#include<stdio.h>
#include<iostream.h>
int main(){
register a = 25;
int far *p;
p=&a;
printf("%d ",*p);
return 0;
}
25
4
Address
Compilation error
Answer: Option D
Shravanti writes the following program:
Integer i = 0,
j while ( i < 2 )
{
j = 0;
while ( j <= 3*i )
{
print j
print blank space
j = j + 3
}
print end-of-line \takes the cursor to the next line
i = i + 1
}
What will be the output of the program?
0
0 3
0
0 3
0 3 6
0
0 3
0 3 6 9
0
0 3
0 3 6
0 3 6 9
0 3 6 9 12
Answer: Option A
What is the output of this program?
class main_class {
public static void main(String args[])
{
if (a == 20) {
int a= 18;
System.out.println(x);
}
}
}
20
18
Compilation error
Runtime error
Answer: Option C
Predict the output of the following program:
#include<iostream.h>
Class Green
{
int x;
}
int main()
{
Green g;
cout < return0;
}
Runtime Error
0
Compiler Error
Garbage Value
Answer: Option C
As x is a private member of Class Green so it cannot be accessed outside the class. It shows a compiler error.
What is the output of the following code?
x=15;
y=0;
if(x=10) y=7;
else y=1;
cout<< y;
7
0
1
6
Answer: Option C
Since x is not equal to 10, the flow will go to else statement hence y=1.