Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1. What will be the output of the C program?

#include<stdio.h>

int main(){

int a = 130;

char *ptr;

ptr = (char *)&a;

printf("%d ",*ptr);

return 0;

A. -126

B. Run Time Error

C. Garbage value

D. Compile Time Error

2. What will be the output of the C program?

#include<stdio.h>
int main(){
int i = 3;
int *j;
int **k;
j = &i;
k = &j;
k++;
printf("%d ",**k);
return 0;
}

A. Garbage value
B. Compilation Error
C. Run time error
D. Linker Error

3. What will be the output of the C program?

#include<stdio.h>
int main(){
int i = 3;
int *j;
j = &i;
j++;
printf("%d ",*j);
return 0;
}
A. Linker Error
B. Run time error
C. Compilation Error
D. Garbage value

4. What will be the output of the C program?

#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
strcpy(a, "world");
printf("\n%s %s",ptr, a);
return 0;
}
A. hello world
B. Run time error
C. Compilation Error
D. Garbage value

5. What will be the output of the C program?

#include<stdio.h>
#include<string.h>
int main(){
char *ptr = "hello";
char a[22];
*ptr = "world";
printf("\n%s %s",ptr, a);
return 0;
}

A. Linker Error
B. Run time error
C. Compilation Error
D. Garbage value

6. What will be the output of the C program?

#include<stdio.h>
int main()
{
char *ptr = "helloworld";
printf(ptr + 4);
return 0;
}
A. oworld
B. world
C. hell
D. hello

7. What will be the output of the C program?

#include<stdio.h>
int main()
{
char *ptr = "2braces";
printf("%c\n",*&*ptr);
return 0;
}
A. Address of 2
B. Compilation Error
C. 2
D. Run time error

8. What will be the output of the C program?

#include<stdio.h>
#include<string.h>
int main(){
register a = 1;
int far *ptr;
ptr = &a;
printf("%u",ptr);
return 0;
}
A. Address of a
B. Run time error
C. Garbage value
D. Compile time error

9. What will be the output of the C program?

#include<stdio.h>
#include<string.h>
int main(){
char a = 30, b = 5;
char *p = &a, *q = &b;
printf("%d", p - q);
return 0;
}
A. 1
B. Run time error
C. Compilation Error
D. 25

10. What will be the output of the C program?

#include<stdio.h>
int main(){
int *ptr, b;
b = sizeof(ptr);
printf("%d" , b);
return 0;
}
A. 2
B. 4
C. Compilation Error
D. Run time error

You might also like