Write a C program to input a year and check whether year is leap year or not using conditional/ternary operator ?:
. How to check leap year using conditional operator in C programming.
Example
Input
Input year: 2016
Output
2016 is Leap Year
Write a C program to input a year and check whether year is leap year or not using conditional/ternary operator ?:
. How to check leap year using conditional operator in C programming.
Example
Input
Input year: 2016
Output
2016 is Leap Year
Write a C program to input a number and check whether number is even or odd using Conditional/Ternary operator ?:
. How to check even or odd numbers using conditional operator in C program.
Example
Input
Input num: 10
Output
10 is even.
Problem: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. We need to find the sum of all the multiples of 3 or 5 below 1000. View this problem on Project Euler. Algorithm: The … Read more
Write a C program to input three numbers from user and find maximum between three numbers using conditional/ternary operator ?:
. How to find maximum between three numbers using conditional operator.
Example
Input
Input num1: 10 Input num2: 20 Input num3: 30
Output
Maximum is 30
Write a C program to input two numbers and find maximum between two numbers using conditional/ternary operator ?:
. How to find maximum or minimum between two numbers using conditional operator in C program.
Example
Input
Input first number: 10 Input second number: 20
Output
Maximum: 20
switch case
is a branching statement used to perform action based on available choices, instead of making decisions based on conditions. Using switch case
you can write more clean and optimal code than if else statement.
switch case
only works with integer, character and enumeration constants.
In this exercises we will focus on the use of switch case
statement. We will learn where to implement switch case
statement other than if else
statement.
Write a C program to input two numbers from user and find maximum between two numbers using switch case. How to find maximum or minimum between two numbers using switch case. Logic to find maximum between two numbers using switch case in C programming.
Input first number: 12 Input second number: 40
Output
Maximum: 40
Write a C program to input month number and print total number of days in month using switch...case
. C program to find total number of days in a month using switch...case
. Logic to print number of days in a month using switch...case
in C programming.
Input month number: 3
Output
Total number of days = 31
Write a C program to input week number(1-7) and print day of week name using switch case. C program to find week day name using switch case. How to find day name of week using switch case in C programming.
Input week number(1-7): 2
Output
Tuesday
Write a C program to input an alphabet and check whether it is vowel or consonant using switch case. C program to check vowel or consonant using switch case. Logic to check vowel or consonant using switch case.
Input alphabet: c
Output
'c' is consonant