Top

Discussion

What is the output of this program?

#include 
 struct 
{
 int i;
 float ft;
}decl;
int main(){
    decl.i = 4;
 decl.ft = 7.96623;
 printf("%d %.2f", decl.i, decl.ft);
 return 0;
}

 

  • A.4 7.97
  • B.4 7.96623
  • C.Compilation error
  • D.None of the above

Answer: A

In the above program the float variable ft is intialised to 7.96623, and it rounded of to 7.97 because of %.2f that we have mentioned in printf statement.

No comment is present. Be the first to comment.
Loading…

Post your comment