Practice: Paper 1 Paper 2 Paper 3 Paper 4
#include <stdio.h>
What will be the output of following program?
#include "stdio.h"
int main()
{
char arr[] = { 'A', 'X', 'C', 'Y' };
char *ptr = &arr[0];
*ptr++;
printf("%c",--*ptr);
}
a)C
b)A
c)B
d)W
Ans: d
What will be the output of following program?
#include "stdio.h"
int main()
{
char arr[] = { 'A', 'X', 'C', 'Y' };
char *ptr = &arr[0];
*ptr++;
printf("%c %c ", *++ptr, --*ptr);
}
a)CX
b)XC
c)XA
d)CW
Ans: d
What will be the output of the below code
main ()
{
char* st1="Hello";
char* st2="Hello";
if (st1==st2)
printf("same");
else
printf("different");
}
A.run time error
B.compile time error
C.different
D.same
Ans: D
int main()
{
int a,*b;
*b=10;
printf("%d",*b);
return 0;
}
a) compilation error
b) Runtime error
c) 10
d) linker error
Ans: b
What will be the output of following program?
#include<stdio.h>
int main()
{
const int x=10;
int*p;
p=&x;
*p=20;
printf("%d %d",*p, x);
return 0;
}
Ans: 20 20
#include<stdio.h>
int main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d",*(a+1)+*(ptr-1));
return 0;
}
Ans:7
What will be the output of following program?
#include "stdio.h"
int main()
{
char arr[] = { 'A', 'X', 'C', 'Y' };
char *ptr = &arr[0];
*ptr++;
printf("%c",*ptr);
}
a)C
b)X
c)B
d)A
Ans: b
What will be the output of following program?
#include "stdio.h"
int main()
{
char arr[] = { 'A', 'X', 'C', 'Y' };
char *ptr = &arr[0];
*ptr++;
printf("%c",--*ptr);
}
a)C
b)A
c)B
d)W
Ans: d
What will be the output of following program?
#include "stdio.h"
int main()
{
char arr[] = { 'A', 'X', 'C', 'Y' };
char *ptr = &arr[0];
*ptr++;
printf("%c %c ", *++ptr, --*ptr);
}
a)CX
b)XC
c)XA
d)CW
Ans: d
What will be the output of the below code
main ()
{
char* st1="Hello";
char* st2="Hello";
if (st1==st2)
printf("same");
else
printf("different");
}
A.run time error
B.compile time error
C.different
D.same
Ans: D
No comments:
Post a Comment