LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C Programming
  • Expressions

C Programming

EXPRESSIONS MCQs

Total Questions : 35

Page 1 of 4 pages
Question 1.

Every operator has an Associativity


  1.    Yes
  2.    No
 Discuss Question
Answer is Option A. -> Yes

Yes, Each and every operator has an associativity.

The associativity (or fixity) of an operator is a property that determines how 

operators of the same precedence are grouped in the absence of parentheses. 

Operators may be left-associative, right-associative or non-associative.

Question 2.

Will the expression *p = p be disallowed by the compiler?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

Because, here even though the value of p is accessed twice it is used to modify two 

different objects p and *p

Question 3.

Two different operators would always have different Associativity.


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

No, Two different operators may have same associativity.

Example: 
Arithmetic operators like ++, -- having Right-to-Left associativity.
Relational operators like >, >= also have Left-to-Right associativity.

Question 4.

Are the following two statement same?

1.a <= 20 ? (b = 30): (c = 30);

2.(a <=20) ? b : (c = 30);


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

No, the expressions 1 and 2 are not same. 1. a

Question 5.

Associativity of an operator is either Left to Right or Right to Left.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Yes, the associativity of an operator is either Left to Right or Right to Left.

Question 6.

In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators


  1.    True
  2.    False
 Discuss Question
Answer is Option B. -> False

The equal to = operator has Right-to-Left Associativity. So it assigns b=5 then a=b.

Question 7.

Associativity has no role to play unless the precedence of operator is same.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Associativity is only needed when the operators in an expression have the same 

precedence. Usually + and - have the same precedence.

Consider the expression 7 - 4 + 2. The result could be either (7 - 4) + 2 = 5 or 7 

- (4 + 2) = 1. The former result corresponds to the case when + and - are left-

associative, the latter to when + and - are right-associative.

Usually the addition, subtraction, multiplication, and division operators are left-associative, 

while the exponentiation, assignment and conditional operators are right-associative. To 

prevent cases where operands would be associated with two operators, or no operator at 

all, operators with the same precedence must have the same associativity.

Question 8.



What will be the output of the program?

#include<stdio.h>
int main()
{
int i=2;
int j = i + (1, 2, 3, 4, 5);
printf("%d\n", j);
return 0;
}

  1.    4
  2.    7
  3.    6
  4.    5
 Discuss Question
Answer is Option B. -> 7

Because, comma operator used in the expression i (1, 2, 3, 4, 5). The comma 

operator has left-right associativity. The left operand is always evaluated first, 

and the result of evaluation is discarded before the right operand is evaluated. 

In this expression 5 is the right most operand, hence after evaluating expression 

(1, 2, 3, 4, 5) the result is 5, which on adding to i results into 7.

Question 9.

The expression of the right hand side of || operators doesn't get evaluated if the 

left hand side determines the outcome.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Because, if a is non-zero then b will not be evaluated in the expression (a || b)

Question 10.


What will be the output of the program?



#include<stdio.h>
int main()
{
char ch;
ch = 'A';
printf("The letter is");
printf("%c", ch >= 'A' && ch = 'A' && ch
  1.    The letter is a Now the letter is A
  2.    The letter is A Now the letter is a
  3.    Error
  4.    None of above
 Discuss Question
Answer is Option A. -> The letter is a Now the letter is A

Step 1: char ch; ch = 'A'; here variable ch is declared as an character 

type an initialized to 'A'.

Step 2: printf("The letter is"); It prints "The letter is".

Step 3: printf("%c", ch >= 'A' && ch <= 'Z' ? ch + 'a' - 'A':ch);

The ASCII value of 'A' is 65 and 'a' is 97.

Here

=> ('A' >= 'A' && 'A' <= 'Z') ? (A + 'a' - 'A'):('A')

=> (TRUE && TRUE) ? (65 + 97 - 65) : ('A')

=> (TRUE) ? (97): ('A')

In printf the format specifier is '%c'. Hence prints 97 as 'a'.

Step 4: printf("Now the letter is"); It prints "Now the letter is".

Step 5: printf("%cn", ch >= 'A' && ch <= 'Z' ? ch : ch + 'a' - 'A');

Here => ('A' >= 'A' && 'A' <= 'Z') ? ('A') : (A + 'a' - 'A')

=> (TRUE && TRUE) ? ('A') :(65 + 97 - 65)

=> (TRUE) ? ('A') : (97)

It prints 'A'

Hence the output is

The letter is a
Now the letter is A

  • 1
  • 2
  • 3
  • 4
  • Next →
  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

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

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   The Frequency Of Oscillation At Compared To Earth Will Be

Q.   The Formula In Which Σ(x-x̅)² Is Divided By One Less ....

Q.   If....

Q.   What Is The National Sport Of Canada(in Winter And Summer)?

Q.   A Well-oiled Machinery For The Creation And Diffusion Of Fad....

Q.   Considering All 2-digit Natural Numbers, How Many Values Of ....

Q.   In A Gas Welding Of Mild Steel Using An Oxyacetylene Flame, ....

Q.   Which One Of Following Fuels Is Used By Slow Thermal Nuclear....

Q.   Answer The Questions On The Basis Of The Following Informat....

Q.   Who Discovered The Path Of Circulation Of Blood In The Human....

Q.   __________ Is Produced Using Molasses As The Starting Raw Ma....

Q.   &n....

Q.   `3....

Q.   The Ratio Of Mass Concentration Of Species A To The Total M....

Q.   Which Pesticide Killed Many Other Organisms Instead Of Only ....

Q.   Resolution Of A DVM Is Given By ____________

Q.   Who Has Hinted At The Possible Community Transmission Of The....

Q.   The Ability Of Money To Be Moved Easily Is Called:

Q.   EXORBITANT

Q.   An Inventory, Which Consists Of Partially Worked Goods Is Ca....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password