1,452 views
2 votes
2 votes
main()   {

static char a[3][4] = { "abcd", "efgh", "ijkl"};

putchar(**a);

 }

 

a) compilation error         b) run time error

c)garbage               d) none of these

3 Answers

Best answer
2 votes
2 votes
#include <stdio.h>
int main() {
  static char a[3][4] = {"axcd","efgh","ijkl"};

  // a is a 2D array of char
  // Two times dereference of a : **a == *(*(a+0)+0)
  // gives the first character of the first row

  putchar(**a); // prints a
  putchar(*(*a + 1));  // prints x	

  
}
selected by
1 votes
1 votes
prints the first character of the first element of the array 'a'. So ans is option D
0 votes
0 votes
For putchar(x) to print x, x has to be a character. Otherwise it would print undesirable output,

Here,  **a  gives the first character('a') of first character array("abcd").

Related questions

0 votes
0 votes
1 answer
1
2 votes
2 votes
2 answers
4
atulcse asked Jan 15, 2022
687 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...