aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C Programming Language Quiz 2
  • what is the best choice to print the value of variable x ...
Multiple choice c

what is the best choice to print the value of variable x where:

int x = 123;

  1. printf("%f",x);

  2. printf("%d",x);

  3. printf("%c",x);

  4. printf("%s",x);

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

The variable x is declared as an int. The correct format specifier for an integer in printf is %d. %f is for float/double, %c is for char, and %s is for strings.

Keep practicing — related questions

  • What will be printed as the result of the operation below: main() { int x=5; printf(“%d,%d,%dn”,x,x< <2,x>>...
  • int x = 0; for ( ; ; ) { if (x++ == 4) break; continue; } printf(x=%dn, x); What will be printed when the s...
  • What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++...
  • What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; print...
  • printf("%d",printf("What this will print"));
  • int x = 0; for (x=1; x<4; x++); printf(x=%dn, x); What will be the output of the sample code given above?
  • Short int x; /* assume x is 16 bits in size */, what is the maximum number that can be printed using printf...
  • What would be the output of the following? main() { int y,x=5; y=++x - ++x; printf("%d%d",x,y); }
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy