in Programming in C edited by
381 views
1 vote
1 vote

What is the output of the following $\text{C}$ program?

    #include<stdio.h>
    int main(void){
    char s1[] = “Hello”;
    char s2[] = “World!”;
    s1 = s2;
    printf(“%s”,s1);
    }
  1.  “World!”
  2. “HelloWorld!”
  3. “Compilation error”
  4. “Hello”
in Programming in C edited by
by
381 views

2 Answers

0 votes
0 votes

Ans : C

Reason:-

∴ In C, the main function serves as the entry point for the program. According to the C standard, the main function should have a return type of int, indicating the exit status of the program. Therefore, it should be declared as int main(void) and not void main(). Using void main() is not standard and may cause a compiler error.

0 votes
0 votes

Option : C

You cannot assign anything to array datatype without specifying indices. So, it's a compilation error.

Answer:

Related questions