MCQ - Functions And Pointers in C Programming

22. What is the output of this program?

#include<stdio.h>
void main()
{
test();
void test()
{
printf("1");
}
}

A. 1
B. Compilation Error
C. Run Time Error
D. None of the above

View Answer


23. What is the output of this program?

#include<stdio.h>
void test(int * , int *);
void main()
{
int a = 5 , b = 6;
test(&a,&b);
printf("%d %d",a,b);
}
void test(int *p, int *q)
{
*p = *p * *q;
*q = *p / *q;
*p = *p / *q;
}

A. 30 5
B. 6 5
C. 5 6
D. None of the above

View Answer


24. What is the output of this program?

#include<stdio.h>
void test(char**);
int main()
{
char *argv[] = {"a", "b", "c", "d"};
test(argv);
return 0;
}
void test(char **p)
{
char *m;
m = (p+= sizeof(int))[-2];
printf("%s", m);
}

A. a
B. b
C. c
D. d

View Answer


25. What is the output of this program?

#include<stdio.h>
int main()
{
char *ptr = "Hello";
printf("%c", *&*&*ptr);
return 0;
}

A. H
B. Compilation Error
C. Run Time Error
D. Garbage Value

View Answer


26. What is the output of this program?

#include<stdio.h>
void test(int *a, int *b)
{
a = b;
*a = 15;
}
int x = 10, y = 20;
int main()
{
test(&x, &y);
printf("%d %d", x, y);
return 0;
}

A. 15 15
B. 10 15
C. 10 20
D. 15 20

View Answer


27. What does the following statment mean?

int (*ptr)[5];

A. ptr is an array of 5 integers
B. ptr is a pointer to an array of 5 integers
C. ptr is array of pointers to 5 integers
D. ptr is an pointer to array

View Answer


28. What is the output of this program?

#include<stdio.h>
int main()
{
int a = 5;
void *ptr = &a ;
printf("%f", *(float*)ptr);
return 0;
}

A. 5
B. 5.000000
C. 0.000000
D. 0

View Answer


29. What is the output of the given code ?

#include<stdio.h>
void main()
{
int a = 0 ;
int *const ptr = &a ;
printf("%p ", ptr);
ptr++;
printf("%p ", ptr);
}

A. 0 1
B. compilation Error
C. Run Time Error
D. None of the above

View Answer


30. What is the output of this program?

#include<stdio.h>
void main()
{
int a = 5 ;
int *b = &a ;
int **c = &b ;
printf("%d%d%d\n", a, *b, **c);
}

A. 5 garbage value garbage value
B. 5 5 garbage value
C. 5 5 5
D. Error

View Answer


31. What is the output of this program?

#include<stdio.h>
void main()
{
int arr[3] = {1, 2, 3};
int *ptr = arr;
int **temp = &ptr ;
printf("%p %p", *temp, arr);
}

A. Same Address
B. Different Address
C. 1 2
D. 2 3

View Answer


32. The pointer ptr points to which string?

char *ptr;
char myString[]="letsfind";
ptr=myString
ptr+=5;

A. find
B. ind
C. letsf
D. f

View Answer


33. What will be the output ?

void main()
{
char far *farther, *farthest;
printf("%d %d", sizeof(farther), sizeof(farthest));
}

A. 4 2
B. 2 2
C. 4 4
D. 2 4

View Answer







Also check :


Discussion


* You must be logged in to add comment.