Exercise

1. What is the output of this program?

#include <stdio.h>
int main()
{
printf("variable! %d \n", x);
return 0;
}

A. variable! x
B. variable! followed by a junk value
C. Compile time error
D. variable!

View Answer


2. What is the output of this program?

#include <stdio.h>
int main()
{
int main = 3;
printf("%d", main);
return 0;
}

A. 3
B. Compile time error
C. Run time error
D. give garbage value

View Answer


3. What is the output of this program?

#include <stdio.h>
int main()
{
int a, b;
printf("%d", scanf("%d%d",&a,&b));
return 0;
}

A. 1
B. 2
C. Value of a
D. compile time error

View Answer


4. What is the output of this program?

#include <stdio.h>
void main()
{
printf("hello\rworld\n");
printf("hello\b\b\bworld\n");
}

A. hello
     helloworld
B. world
    heworld
C. helloworld
    hellold
D. None of the mentioned

View Answer


5. What is the output of this program?

#include<stdio.h>
int main()
{
int i;
i = printf("letsfindcourse");
i = printf("%d ", i);
printf("%d ", i);
return 0;
}

A. letsfindcourse 15 3
B. letsfindcourse 14 2
C. letsfindcourse 14 3
D. Compilation Error

View Answer


6. Output of this statment is : printf ( "%d" , printf ( "hello" ) );

A. Syntex Error
B. hello5
C. gives garbage value
D. print hello and terminates

View Answer


7. What is the output of this program?

#include <stdio.h>
# define scanf "%s Find best course "
main()
{
printf(scanf, scanf);
return 0;
}

A. %s Find best course Find best course
B. %s Find best course %s Find best course
C. Invalid Syntex
D. Run time error

View Answer


8. Which statment is true about the given code ?

#include <stdio.h>
int main()
{
printf("%d", main);
return 0;
}

A. Goes in infinite loop
B. Gives Address of function main.
C. Gives garbage value
D. Compilation Error

View Answer


9. What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = 1, 2, 3;
printf("%d", i);
return 0;
}

A. 1
B. 2
C. 3
D. Invalid Syntex

View Answer


10. Comment on the given statment:
scanf("%d",i);

A. Will execute without any error
B. Will give Segmentation fault
C. Will give Compilation Error
D. None of the above

View Answer


11. What is the output of this program?

#include<stdio.h>
int main()
{
int x = 1, y = 2;
printf("%d", x, y);
return 0;
}

A. 1
B. 2
C. Compilation Error
D. Garbage Value

View Answer


12. What is the output of this program?

#include<stdio.h>
int main()
{
int x = 1, y = 2;
printf("%*d", x, y);
return 0;
}

A. 1
B. 2
C. Compilation Error
D. Garbage Value

View Answer



Discussion

* You must be logged in to add comment.