Machine-translated by Google. Questions are authored in English.
Top

Discussion

What will be the output of the program ?

#include <stdio.h>

int main()
{
    char str = "IndiaBIX";
    printf("%s\n", str);
    return 0;
}

 

  • A.Error
  • B.IndiaBIX
  • C.Base address of str
  • D.No output

Answer: A

Correct answer: Error

char str declares a single character, and a string literal cannot be assigned to one - the initialiser is a pointer to an array of characters. The declaration would have to be char str[] = "IndiaBIX"; or char *str = "IndiaBIX";.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.