0% found this document useful (0 votes)
921 views

C Output Prediction Questions

c outputs

Uploaded by

guest499aa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
921 views

C Output Prediction Questions

c outputs

Uploaded by

guest499aa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

C Programming Output Prediction Questions

Question 1

#include <stdio.h>

int main() {

int x = 10;

if (x == 10) {

printf("x is 10\n");

} else {

printf("x is not 10\n");

return 0;

Answer

x is 10

Question 2

#include <stdio.h>

void func(int *p, int *q) {

p = q;

*p = 2;

}
C Programming Output Prediction Questions

int main() {

int a = 1, b = 3;

int *p = &a, *q = &b;

func(p, q);

printf("%d %d\n", a, b);

return 0;

Answer

12

Question 3

#include <stdio.h>

int main() {

int x = 5;

if (x > 1) {

printf("x is greater than 1\n");

if (x < 10) {

printf("x is less than 10\n");

} else {
C Programming Output Prediction Questions

printf("x is 1 or less\n");

return 0;

Answer

x is greater than 1

x is less than 10

Question 4

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

int main() {

int x = 10, y = 20;

swap(&x, &y);

printf("x = %d, y = %d\n", x, y);

return 0;
C Programming Output Prediction Questions

Answer

x = 20, y = 10

Question 5

#include <stdio.h>

void changeValue(int *a) {

*a = 100;

int main() {

int x = 10;

changeValue(&x);

printf("x = %d\n", x);

return 0;

Answer

x = 100
C Programming Output Prediction Questions

Question 6

#include <stdio.h>

int main() {

int x = 10;

printf("x = %d\n", x);

return 0;

Answer

x = 10

Question 7

#include <stdio.h>

int main() {

int x = 5;

printf("%d %d %d\n", x, x++, x);

return 0;

Answer
C Programming Output Prediction Questions

656

Question 8

#include <stdio.h>

int main() {

int a = 10, b = 20, c;

c = a + b;

printf("Sum = %d\n", c);

return 0;

Answer

Sum = 30

Question 9

#include <stdio.h>

int main() {

int x = 10, y = 20, z = 30;

printf("%d %d %d\n", x, y, z);

return 0;
C Programming Output Prediction Questions

Answer

10 20 30

Question 10

#include <stdio.h>

void func(int *p) {

*p = 20;

int main() {

int a = 10;

func(&a);

printf("a = %d\n", a);

return 0;

Answer

a = 20
C Programming Output Prediction Questions

Question 11

#include <stdio.h>

int main() {

int x = 10;

if (x == 10) {

printf("x is 10\n");

} else {

printf("x is not 10\n");

return 0;

Answer

x is 10

Question 12

#include <stdio.h>

void func(int *p, int *q) {

p = q;

*p = 2;

}
C Programming Output Prediction Questions

int main() {

int a = 1, b = 3;

int *p = &a, *q = &b;

func(p, q);

printf("%d %d\n", a, b);

return 0;

Answer

12

Question 13

#include <stdio.h>

int main() {

int x = 5;

if (x > 1) {

printf("x is greater than 1\n");

if (x < 10) {

printf("x is less than 10\n");

} else {
C Programming Output Prediction Questions

printf("x is 1 or less\n");

return 0;

Answer

x is greater than 1

x is less than 10

Question 14

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

int main() {

int x = 10, y = 20;

swap(&x, &y);

printf("x = %d, y = %d\n", x, y);

return 0;
C Programming Output Prediction Questions

Answer

x = 20, y = 10

Question 15

#include <stdio.h>

void changeValue(int *a) {

*a = 100;

int main() {

int x = 10;

changeValue(&x);

printf("x = %d\n", x);

return 0;

Answer

x = 100
C Programming Output Prediction Questions

Question 16

#include <stdio.h>

int main() {

int x = 10;

printf("x = %d\n", x);

return 0;

Answer

x = 10

Question 17

#include <stdio.h>

int main() {

int x = 5;

printf("%d %d %d\n", x, x++, x);

return 0;

Answer
C Programming Output Prediction Questions

656

Question 18

#include <stdio.h>

int main() {

int a = 10, b = 20, c;

c = a + b;

printf("Sum = %d\n", c);

return 0;

Answer

Sum = 30

Question 19

#include <stdio.h>

int main() {

int x = 10, y = 20, z = 30;

printf("%d %d %d\n", x, y, z);

return 0;
C Programming Output Prediction Questions

Answer

10 20 30

Question 20

#include <stdio.h>

void func(int *p) {

*p = 20;

int main() {

int a = 10;

func(&a);

printf("a = %d\n", a);

return 0;

Answer

a = 20
C Programming Output Prediction Questions

Question 21

#include <stdio.h>

int main() {

int x = 10;

if (x == 10) {

printf("x is 10\n");

} else {

printf("x is not 10\n");

return 0;

Answer

x is 10

Question 22

#include <stdio.h>

void func(int *p, int *q) {

p = q;

*p = 2;

}
C Programming Output Prediction Questions

int main() {

int a = 1, b = 3;

int *p = &a, *q = &b;

func(p, q);

printf("%d %d\n", a, b);

return 0;

Answer

12

Question 23

#include <stdio.h>

int main() {

int x = 5;

if (x > 1) {

printf("x is greater than 1\n");

if (x < 10) {

printf("x is less than 10\n");

} else {
C Programming Output Prediction Questions

printf("x is 1 or less\n");

return 0;

Answer

x is greater than 1

x is less than 10

Question 24

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

int main() {

int x = 10, y = 20;

swap(&x, &y);

printf("x = %d, y = %d\n", x, y);

return 0;
C Programming Output Prediction Questions

Answer

x = 20, y = 10

Question 25

#include <stdio.h>

void changeValue(int *a) {

*a = 100;

int main() {

int x = 10;

changeValue(&x);

printf("x = %d\n", x);

return 0;

Answer

x = 100
C Programming Output Prediction Questions

Question 26

#include <stdio.h>

int main() {

int x = 10;

printf("x = %d\n", x);

return 0;

Answer

x = 10

Question 27

#include <stdio.h>

int main() {

int x = 5;

printf("%d %d %d\n", x, x++, x);

return 0;

Answer
C Programming Output Prediction Questions

656

Question 28

#include <stdio.h>

int main() {

int a = 10, b = 20, c;

c = a + b;

printf("Sum = %d\n", c);

return 0;

Answer

Sum = 30

Question 29

#include <stdio.h>

int main() {

int x = 10, y = 20, z = 30;

printf("%d %d %d\n", x, y, z);

return 0;
C Programming Output Prediction Questions

Answer

10 20 30

Question 30

#include <stdio.h>

void func(int *p) {

*p = 20;

int main() {

int a = 10;

func(&a);

printf("a = %d\n", a);

return 0;

Answer

a = 20
C Programming Output Prediction Questions

Question 31

#include <stdio.h>

int main() {

int x = 10;

if (x == 10) {

printf("x is 10\n");

} else {

printf("x is not 10\n");

return 0;

Answer

x is 10

Question 32

#include <stdio.h>

void func(int *p, int *q) {

p = q;

*p = 2;

}
C Programming Output Prediction Questions

int main() {

int a = 1, b = 3;

int *p = &a, *q = &b;

func(p, q);

printf("%d %d\n", a, b);

return 0;

Answer

12

Question 33

#include <stdio.h>

int main() {

int x = 5;

if (x > 1) {

printf("x is greater than 1\n");

if (x < 10) {

printf("x is less than 10\n");

} else {
C Programming Output Prediction Questions

printf("x is 1 or less\n");

return 0;

Answer

x is greater than 1

x is less than 10

Question 34

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

int main() {

int x = 10, y = 20;

swap(&x, &y);

printf("x = %d, y = %d\n", x, y);

return 0;
C Programming Output Prediction Questions

Answer

x = 20, y = 10

Question 35

#include <stdio.h>

void changeValue(int *a) {

*a = 100;

int main() {

int x = 10;

changeValue(&x);

printf("x = %d\n", x);

return 0;

Answer

x = 100
C Programming Output Prediction Questions

Question 36

#include <stdio.h>

int main() {

int x = 10;

printf("x = %d\n", x);

return 0;

Answer

x = 10

Question 37

#include <stdio.h>

int main() {

int x = 5;

printf("%d %d %d\n", x, x++, x);

return 0;

Answer
C Programming Output Prediction Questions

656

Question 38

#include <stdio.h>

int main() {

int a = 10, b = 20, c;

c = a + b;

printf("Sum = %d\n", c);

return 0;

Answer

Sum = 30

Question 39

#include <stdio.h>

int main() {

int x = 10, y = 20, z = 30;

printf("%d %d %d\n", x, y, z);

return 0;
C Programming Output Prediction Questions

Answer

10 20 30

Question 40

#include <stdio.h>

void func(int *p) {

*p = 20;

int main() {

int a = 10;

func(&a);

printf("a = %d\n", a);

return 0;

Answer

a = 20
C Programming Output Prediction Questions

Question 41

#include <stdio.h>

int main() {

int x = 10;

if (x == 10) {

printf("x is 10\n");

} else {

printf("x is not 10\n");

return 0;

Answer

x is 10

Question 42

#include <stdio.h>

void func(int *p, int *q) {

p = q;

*p = 2;

}
C Programming Output Prediction Questions

int main() {

int a = 1, b = 3;

int *p = &a, *q = &b;

func(p, q);

printf("%d %d\n", a, b);

return 0;

Answer

12

Question 43

#include <stdio.h>

int main() {

int x = 5;

if (x > 1) {

printf("x is greater than 1\n");

if (x < 10) {

printf("x is less than 10\n");

} else {
C Programming Output Prediction Questions

printf("x is 1 or less\n");

return 0;

Answer

x is greater than 1

x is less than 10

Question 44

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

int main() {

int x = 10, y = 20;

swap(&x, &y);

printf("x = %d, y = %d\n", x, y);

return 0;
C Programming Output Prediction Questions

Answer

x = 20, y = 10

Question 45

#include <stdio.h>

void changeValue(int *a) {

*a = 100;

int main() {

int x = 10;

changeValue(&x);

printf("x = %d\n", x);

return 0;

Answer

x = 100
C Programming Output Prediction Questions

Question 46

#include <stdio.h>

int main() {

int x = 10;

printf("x = %d\n", x);

return 0;

Answer

x = 10

Question 47

#include <stdio.h>

int main() {

int x = 5;

printf("%d %d %d\n", x, x++, x);

return 0;

Answer
C Programming Output Prediction Questions

656

Question 48

#include <stdio.h>

int main() {

int a = 10, b = 20, c;

c = a + b;

printf("Sum = %d\n", c);

return 0;

Answer

Sum = 30

Question 49

#include <stdio.h>

int main() {

int x = 10, y = 20, z = 30;

printf("%d %d %d\n", x, y, z);

return 0;
C Programming Output Prediction Questions

Answer

10 20 30

Question 50

#include <stdio.h>

void func(int *p) {

*p = 20;

int main() {

int a = 10;

func(&a);

printf("a = %d\n", a);

return 0;

Answer

a = 20

You might also like