aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C Programming - 2
  • The program main() { float b = 0.7; printf(“%d, %f”,b,b);...
Multiple choice

The program main() { float b = 0.7; printf(“%d, %f”,b,b); } prints

  1. a garbage value 0.7

  2. 0 ,0.0

  3. 7, 0.7

  4. an error message

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The printf format string uses %d for a float variable b. This causes undefined behavior, typically resulting in 0 or a garbage value, and %f for the same float prints 0.000000.

Keep practicing — related questions

  • What will be the output of the following set of code after execution? void main() { float m=3.6e38; printf(...
  • What will be the output of the following program: void main() { float val=2.; printf("%.2",val); }
  • What will be the output of the following: void main() { float a=0.7; if(a<0.7) printf("c++"); else printf("...
  • Print the output of this program main() { int k = 5; if (++k < 5 && k++/5 || ++k <= 8); printf("%d\n", k); }
  • What is the output ? main() { int x=2000, *p, y = 200; p = &y; x = x/*p; printf("%d", x); }
  • What will be the output of the given program or find out the error if any? int main() { float x=fun(2,3); p...
  • void main() { int x; x=10, 20, 30; printf("%d", x); }
  • main() { float me = 1.1; double you = 1.1; if(me==you) printf("I Don't Know C"); else printf("I Know C"); }
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy