SarkariBix
SarkariBix
Start typing & press "Enter" or "ESC" to close
  • Home
  • Jobs
  • Results
  • Current Affairs
  • GK
  • Online Test
  • HR Interview
  • BLOG

Which of the following is the correct usage of conditional operators used in C?

  • Home
  • Computer Science & Engineering
  • C Programming Questions and Answers
  • Expressions
  • Discuss - 705
1. 

Which of the following is the correct usage of conditional operators used in C?

[A]. a>b ? c=30 : c=40;
[B]. a>b ? c=30;
[C]. max = a>b ? a>c?a:c:b>c?b:c
[D]. return (a>b)?(a:b)

Answer: Option C

Explanation:

Option A: assignment statements are always return in paranthesis in the case of conditional operator. It should be a>b? (c=30):(c=40);

Option B: it is syntatically wrong.

Option D: syntatically wrong, it should be return(a>b ? a:b);

Option C: it uses nested conditional operator, this is logic for finding greatest number out of three numbers.

Workspace Report
Leave a Comment

Computer Science & Engineering :: C Programming Questions and Answers : More Exercises

  • Declarations and Initializations
  • Expressions
  • Functions
  • Pointers
  • Strings
  • Input / Output
  • Bitwise Operators
  • Const
  • Variable Number of Arguments
  • Library Functions
  • Control Instructions
  • Floating Point Issues
  • C Preprocessor
  • Arrays
  • Structures, Unions, Enums
  • Command Line Arguments
  • Typedef
  • Memory Allocation
  • Complicated Declarations

Questions & Answers

Aptitude Chemical Engineering Civil Engineering Computer Science & Engineering Current Affairs Data Interpretation Electrical & Electronics Engineering Electronics & Communication Engineering General Knowledge Logical Reasoning Mechanical Engineering Non Verbal Reasoning Verbal Ability Verbal Reasoning

Interviews

HR Interview

Jobs

Sarkari Jobs

Results

Rojgar ResultSarkari Result

Admission

Admission 2022

Admit Card

Admit Card 2022

Answer Key

Answer Key 2022
copyright
Privacy Policy
© 2022 SarkariBix. All Rights Reserved.

Report