c language questions

(5)Find the correct output

void main()

{

char a[4]=”rama”;

char b[]=”shyama”;

printf(“%d %d”, sizeof(a),sizeof( b)) ;

}

(a) 4 7

(b) 5 6

(c) 5 7

(d) 4 6

(6)Find the correct output

void main()

{

int a[]={‘a’,’b’,’c’};

printf(“%d”, sizeof(a));

}

(a)3

(b)4

(c)can’t be initialized

(d)None of these

(7)Find the correct output

void main()

{

char a[]=”rama”;

char b[]=a;

printf (“%d %s”, sizeof (b),b);

}

(a)5 rama

(b)4 rama

(c)5 r

(d)None of these

(8)It is said that the array uses “zero-based addressing” because

(a)Array size must be an integer greater than 0

(b)The array subscript must always start at 0

(c)Array declaration reserves memory during compilation

(d)None of these

(9)Find the correct output

void main()

{

char a[]=”manish”;

char b[10]=”manish\0”;

if(strcmp(a,b))

printf(“Not equal”);

else

printf(“Both are equal”);

}

(a)Not equal

(b)Both are equal

(c)Array of different size can not be compared

(d)None of these

No comments: