# O Level Exam

#### Conditional Operator in C

The conditional operator (? :) is a ternary operator. This operator needs 3 operands to perform the operation.

Syntax:

`Variable = <test expression> ? <expression 1> : <expression 2>`

Or

`<test expression> ? <expression 1> : <expression 2>` The conditional operator works as follows:

Test Expression is Condition

Expression 1 is Statement Followed if Condition is True

Expression 2 is Statement Followed if Condition is False

Example 1:

```int num1=10,num2=20,max;max=(num1>num2)?num1:num2;
printf("Max is %d",max);```

The output is:

`max is 20`

Example 2:

`int num=45;(num%2==0)?printf("Number is Even"):printf("Number is Odd");`

The Output is:

`Number is Odd`

#### Programs

Write a program to input number of days from user and display it, week and days format.

For Example

input is : 20 days

then output is:

2 week and 6 days.

Write a program to input number of days from user and display it, Month, Week and Days format. (consider 30days = 1 month)

For Example:

input is : 50 days

output is: 1 month, 2 week and 6 days.

Write a C program which accept a character from user and ASCII Value of that character

Write a program which accept one integer number from user and print it.

Write a C Program to input any Character and Find its ASCII Value

Write a C Program to input dividend, divisor and Compute Quotient and Remainder

Write a C Program to Find the Size of int, float, double and char

Write a C Program to Swap Two Numbers

Write a C program to Swap Numbers Without Using Temporary(3rd) Variables

Write a C Program to input any  number and Check  number is Odd or Even Using the Ternary Operator