What is going to be the output of the following program incl

What is going to be the output of the following program: #include int main (void){struct book{int no; float call[2];} b1; b1 ={31, {2.3, 5.93}}; printf (\"--------------------\ \"); printf (\"%d %.2f%.3f\ \", b1.no, b1.call[1], b1.call[2]); return 0;} Output box:

Solution

#include<stdio.h>


int main()
{
   struct book
   {
       int no;
       float call[2];
   }b1={31,{2.3,5.93}};
   printf(\"=================\ \");
   printf(\"%d%.2f%.3f\ \",b1.no,b1.call[1],b1.call[2] );

   return 0;
}

Output:

=================
31 5.93 0.000

==========

Ouput will first print no,which is 31. After that it prints second element of array call which is 5.93(.2f%shows that 2 numbers after decimal point).But after that it trys to print 3rd element of array which is not present.Hence by default it will be 0.000(.3f% hows that 3 numbers after decimal point).

 What is going to be the output of the following program: #include int main (void){struct book{int no; float call[2];} b1; b1 ={31, {2.3, 5.93}}; printf (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site