Ask Question
19 September, 04:32

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;

}

+1
Answers (1)
  1. 19 September, 08:22
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers