Question discussion

What is the output of the following C program?#include #include int main() { char a[20] = "Hi"; strcat(a, " Edu"); printf("%d %s", (int)str…

1942Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
#include <string.h>
int main() {
    char a[20] = "Hi";
    strcat(a, " Edu");
    printf("%d %s", (int)strlen(a), a);
    return 0;
}
  • A6 Hi Edu
  • B4 Hi Edu
  • C6 Edu
  • D20 Hi Edu
Correct answer: A

Explanation

strcat appends " Edu" to "Hi", giving "Hi Edu", whose length is 6 characters.

Discussion 0

Nobody has replied yet. Start the discussion!