VOOZH about

URL: https://www.geeksforgeeks.org/c/output-c-programs-set-45/

⇱ Output of C programs | Set 45 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 45

Last Updated : 18 Sep, 2018
1. What will be the output of following program? Options: (a)equal (b)greater than (c)less than (d)compiler error (e)none of the above
Answer: (d)Compiler error
Explanation: Here 'x' is a static variable and 'i' is an auto variable. Auto variables are run time entities, compared to static, which are load time entities. Run time variables cannot be initialized with load time variables. 2. What will be the output of following program? Options: (a)i am good (b)i (c)good (d)iamgood (e)Compiler error
Answer: (d)iamgood
Explanation: In C, string constant "ab" is same as "a" "b". 3. What will be the output of following program? Options: (a)7 7 (b)8 8 (c)8 7 (d)7 8 (e)None of the above
Answer: (c)8 7
Explanation: strlen returns length of string without counting the null character, whereas sizeof also includes the null character when counting size of string. 4. What will be the output of following program? Options: (a)Aqua (b)AquaGreenOther (c)AquaGreen (d)Red (e)none of the above
Answer: (b)AquaGreenOther
Explanation: There are no break statements in switch case, so all statements after case 2, including the default statement, will be executed. 5. What will be the output of following program?
Options: (a)i know c (b)i know c++ (c)cisgoodi know c (d)cisgoodi know c++ (e)compiler error
Answer: (c)cisgoodi know c
Explanation: The return type of printf is integer, that is the number of characters including blank spaces. So, here in if condition, printf evaluates to 7, which is non-negative. Thus follows the true condition.
Comment
Article Tags:
Article Tags: