Trace the number of the error of the following code
Correct answer: D. 4
- A. 1
- B. 3
- C. 2
- D. 4
Explanation
void main (void) // Error 1: It's preferable to use 'int main(void)' instead of 'void main(void)'.{ int x= 10;if (x > 5 && < 15) // Error 2: Incomplete expression after '&&', missing the variable to compare with 15. printf ("x is valid"); // Error 3: Missing semicolon at the end of the statement.elseprintf ("invalid"); // Error 4: Missing semicolon at the end of the statement.}//////int main(void) { int x = 10; if (x > 5 && x < 15) { printf("x is valid"); } else { printf("invalid"); } return 0; // Added return statement
Report an error
The more specific you are, the faster it gets fixed. A source beats an opinion.
Prefer email? [email protected]
About Logical Problems
Logical problems present several conditions about people, objects, events or choices and require their possible arrangements to be tested. They cover constraint-based reasoning, rankings, matching, grouping, scheduling and elimination, with attention to the difference between a complete solution and a possibility that merely satisfies one condition.
Practise Logical Problems
519 free Logical Problems MCQs from Analytical and Logical Reasoning, each with the correct answer and an explanation. Unlimited attempts, no account needed.
Discussion
Stuck on an option, or know a faster way to get there? Ask or explain it here.
No comments yet. Be the first to explain this one.
Exams that ask Analytical and Logical Reasoning questions like this
Analytical and Logical Reasoning is on 27 papers prepared for on TestUstad, and all of them draw the same bank, so this question is worth knowing for every one of them.
More Logical Problems questions
What is a method of database distribution in which one database contains data that are included in another database?
Data integrity constraints are used to:
Which of the following is not a type of user interface
Which of the following is not a valid escape code?
Which part of a function describes the number and type of its arguments, and the return type of the function?
File * is a pointer to?