Posts

Showing posts from April, 2017

Write C program to enter any character and check whether character is alphabet or not using Conditional/Ternary operator

  C   ,   OPERATOR   ,   PROGRAM .   Required knowledge: Basic C programming ,   Conditional operator .   Program: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /**  * C program to check alphabets using Conditional operator  */ #include <stdio.h> int main() {     char ch;            /*      * Reads a character from user      */     printf("Enter any character: ");     scanf("%c", &ch);            printf("It is %s", (((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) ? "ALPHABET" : "NOT APLHABET") );     return 0; } Output Enter any character: ...

Write C program to enter any year and check whether year is leap year or not using conditional/ternary operator.

C program to check leap year using Conditional/Ternary operator   C   ,   OPERATOR   ,   PROGRAM Write a C program to enter any year and check whether year is leap year or not using conditional/ternary operator (?:).     Required knowledge: Basic C programming,   Conditional operator,   Leap year condition   Leap year condition: If the year is   EXACTLY DIVISIBLE by 4   and   NOT DIVISIBLE by 100   then its LEAP YEAR   Else if the yea r is  EXACTLY DIVISIBLE 400  then its LEAP YEAR  Else its a COMMON YEAR  Program: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 /**  * C program to check leap year using conditional operator  */ #include <stdio.h> int   main() {     int   year;         /*   ...

Write C Program to enter any number and check whether number is odd or even using Conditional/Ternary operator.

Write a C program to enter any 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. Checking whether a given number is even or odd using ternary operator in C programming.   Example: Input number: 10 Output: Even number Required knowledge Basic C programming ,   Conditional operator   Even numbers Even numbers   are the positive integers that are exactly divisible by 2. For example: First 5 even numbers are - 2, 4, 6, 8, 10...   Odd numbers Odd numbers   are the positive integers that are not exactly divisible by 2. For example: First 5 odd numbers are - 1, 3, 5, 7, 9...   Program to check even or odd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 /**  * C program to check even or odd number using conditional operator  */ #include ...

C Program to find maximum number between three number using Conditional Operator

C Program to Find Maximum of Three Numbers using Conditional Operator ·                      Write a C program to find maximum of three numbers using conditional operator. ·                      How to find largest of three numbers using ternary operator. Required Knowledge ·                      C printf and scanf functions ·                      Conditional Operator in C Algorithm to find maximum of three numbers using conditional operator Let A, B and C are three numbers. ·                 ...

C Program to find maximum between two numbers using conditional operator

C program to find maximum between two numbers using conditional operator Write a C program to enter 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 first number: 10 Input second number: 20 Output maximum: 20 Required knowledge Basic C programming ,  Conditional operator Program to find maximum using conditional operator 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 /**  * C program to find maximum between two numbers using conditional operator  */ #include <stdio.h> int   main() {     int   num1, num2, max;     /*      * Reads two number from user      */     printf("Enter ...