Contents
- 1 If “a” is an array of 5 x 5 dimension, a[2][4] is same as
- 2 What is the output of the following code.
- 3 What is the Name of the pointer int **p; ?
- 4 Comment on the following pointer declaration?
- 5 What is the output of the following program?
- 6 What is the output of the following program?
- 7 What is the output of the following program?
- 8 What is the output of the following program?
- 9 What is the output?
- 10 What is the output of the following program?
- 11 What is the output of the following program?
- 12 Determine output:
If “a” is an array of 5 x 5 dimension, a[2][4] is same as
- **(a+3+4)
- *(a+3)+*(a+4)
- **(a+3)+4
- *(*(a+2)+4)
Ans: Option 4
What is the output of the following code.
void main()
{
int y[2][2] = {{1,2}, {3,4}};
int *p = y[1];
p = p + 1;
printf(“%d\n”,*p);
}
- 4
- 3
- The program does not compile
- Output is unpredictable
Ans: 1
What is the Name of the pointer int **p; ?
- pointer to pointer
- double pointer
- float pointer
- integer pointer
Ans: Option 1
Comment on the following pointer declaration?
int *ptr, p;
- ptr is a pointer to integer, p is not.
- ptr and p, both are pointers to integer.
- ptr is pointer to integer, p may or may not be.
- ptr and p both are not pointers to integer.
Ans: 1
What is the output of the following program?
void main()
{
char y[10]=”abcedefghi”;
char *p = y;
p = p + 9;
printf(“%c\n”,*p);
}
- i
- Program will have runtime error
- Unpredictable
- No visible output
Ans: 1
Click here for C Language Online Training Course Curriculum
What is the output of the following program?
void main()
{
int a[]={23,45,67};
printf(“\n%d”,*a);
a++;
printf(“\n%d”,*a);
return 0;
}
And: Compile time error
What is the output of the following program?
void main()
{
int a[ ]={5,3,3,2,6};
printf(“%d\t%d”,sizeof(a+1),sizeof(a));
}
Ans: 2 10
What is the output of the following program?
void main()
{
char str[]=”abcdef”;
++str;
++*str;
puts(str);
}
Ans: Compile-time error
What is the output?
#include <stdio.h>
void main()
{
char s[3][6]={“Zero”,”one”,”Two”};
printf(“%s”,s[2]);
printf(“%c”,s[2][0]);
}
Ans: Two
What is the output of the following program?
void main()
{
int arr[3][3]={ 10,20,30};
printf(“\n %d”,sizeof(arr[1]));
printf(“\n %d”,sizeof(arr[1][0]));
}
Ans: 6 2
What is the output of the following program?
#include <stdio.h>
void main()
{
char str[]=”Test”;
if((printf(“%s”,str))==4)
printf(“Success”);
else
printf(“Hello”);
}
Ans: Test Success
Determine output:
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(” p “);
else
printf(“nullp”);
if(q)
printf(“q”);
else
printf(” nullq”);
}
- p q
- Depends on the compiler
- x nullq where x can be p or nullp depending on the value of NULL
- nullp nullq
Ans: 4