Ask Question

What would be the output of the following program?

int main () {

struct message

{ int num;

char mess1[50];

char msg2[50];

} m;

m. num = 1;

strcpy (m. msg1, "We had lot of homework.");

strcpy (m. msg2," Hope it is the last one);

/ * assume that the strucure is located at address 2004*/

printf ("/n%u%u%u/n", &m. num, m. msgi, m3 m2 m. msg2);

printf ("/n%d %s %s", m. num, m. msgi, m. msg2);

return 0;

}

+2
Answers (1)
  1. 10 October, 22:04
    0
    Output: 2004 2008 2058

    Explanation:

    In the first printf command it will print the address of the variables num, msg1, msg2. And in the second printf command it will print the values of the variables num, msg1, msg2. As the address of the structure is 2004 And the size of the integer is 4 byte so size will increase with 4 bytes and the size of character is 1 byte so it will increase by 1*50 = 50 bytes.

    Hence, the output is 2004 2008 2058
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What would be the output of the following program? int main () { struct message { int num; char mess1[50]; char msg2[50]; } m; m. num = 1; ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers