aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C Programming Fundamentals
  • What would be the output of the following? main() { int i...
Multiple choice

What would be the output of the following?

main() { int i=strlen("Blue")+strlen("Purple")/strlen("Red")-strlen("Green"); printf("%d",i); }

  1. 0

  2. 3

  3. 2

  4. 1

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

Operator precedence matters: division happens before addition/subtraction. strlen("Blue")=4, strlen("Purple")=6, strlen("Red")=3, strlen("Green")=5. So: 4 + 6/3 - 5 = 4 + 2 - 5 = 1.

Keep practicing — related questions

  • What would be the output of the following? void main() { int a=10,b; b=a++ + ++a; printf("%d %d %d %d",b,a+...
  • What would be the output of the following? main() { int y,x=5; y=++x - ++x; printf("%d%d",x,y); }
  • what will be the output?? int main(int c) c=1; while(1); c++; printf("%d",++c); return 0; }
  • What will be the output of the following: void main() { int i; for(i=1;i<=4;i++) { printf("%d",i); continue...
  • 3.What is the output?main() { int x=5; printf(“%d,%d,%dn”,x,x< <2,x>>2); }
  • What will be the output of the following program? void main() { int val=1234; int* ptr=&val; printf("%d %d"...
  • What will be the output of the following set of codes after execution? void main() { printf(“%d %d %d ”,56,...
  • What would be the output of the following? main() { int val1=1234; int val2=01234; printf(%d %d,val1,val2); }
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy