Header Ads Widget

Program based on decision control( if ,else and switch)

Here are the some programs based on the decision control statements like if , else , nested if else and switch statement. I  am giving you some program for the practice topic wise .I am also giving you some MCQS questions based on these topics .So after solving these questions your doubts will be clear related to these topic.

Here are some sample questions  and you can download the pdf by clicking on the link

C Programs based on decision control (if and else):-

1.Write a C program to find maximum between two numbers.

2.Write a C program to find maximum between three numbers.

3.Write a C program to check whether a number is negative, positive or zero.

4.Write a C program to check whether a number is divisible by 5 and 11 or not.

5.Write a C program to check whether a number is even or odd.

6.Write a C program to check whether a year is leap year or not.

7.Write a C program to check whether a character is alphabet or not.


C Program based on switch case:-

1.Using switch statement Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following:

Percentage >= 90% : Grade A

Percentage >= 80% : Grade B

Percentage >= 70% : Grade C

Percentage >= 60% : Grade D

Percentage >= 40% : Grade E

Percentage < 40% : Grade F

2.C  Program to find the maximum between two numbers. Using the switch statement

3. C  Program to find the maximum between three numbers. Using the switch statement.

 4.C  Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement.

 5.C  Program to check whether a year is a leap year or not. Using switch statement


MCQs :-

1) Choose a C Conditional Operator from the list.

A) ?:

B) :?

C) :<

D) <:



2) What is the other name for C Language ?: Question Mark Colon Operator.?

A) Comparison Operator

B) If-Else Operator

C) Binary Operator

D) Ternary Operator


3) Choose a syntax for C Ternary Operator from the list.

A) condition ? expression1 : expression2

B) condition : expression1 ? expression2

C) condition ? expression1 < expression2

D) condition < expression1 ? expression2


4) What is the output of the C statement.?

int main()

{

    int a=0;

    a = 5<2 ? 4 : 3;

    printf("%d",a);


    return 0;

}

A) 4

B) 3

C) 5

D) 2


5) What is the output of C Program.?

int main()

{

    int a=0;

    a = printf("4");

    printf("%d",a);


    return 0;

}

A) 04

B) compiler error

C) 40

D) 41


Practice question and program :--



Recommended Post:

Hackerearth Problems:-

Hackerrank Problems:-
Data structure:-

Key points:-

 MCQs:-