• C language

    Reverse The Case Of Input Character

    getchar() is similar to scanf(). islower() is system defined function under ctype.h header file which check if the character is in lowercase or not. toupper() converts the input parameter into equivalent uppercase char. putchar() is similar to printf(). #include<stdio.h> #include<conio.h> #include<ctype.h> // for use system defined function islower() & toupper() void main() { char alphabet; clrscr(); printf("Enter an alphabet : "); putchar('\n'); // to move to next Line alphabet=getchar(); printf("\n\nReverse case of %c is : ",alphabet); if(islower(alphabet)) { putchar(toupper(alphabet)); } else { // must be an uppercase character printf("%c",tolower(alphabet)) ; } getch(); } OutPut Enter an alphabet : s Reverse…

  • C language

    Check If Input Character Is A Vowel Using Switch Case

    The below program is check the entered character, if it is vowel then it will print the entered character is vowel, otherwise it will print that the entered character is not vowel. #include<stdio.h> #include<conio.h> void main() { char ch; clrscr(); printf("Enter A Character : "); scanf("%c", &ch); switch(ch) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("\n\n%c is a Vowel.\n\n", ch); break; default: printf("%c is not a Vowel.\n\n", ch); } getch(); } OutPut Enter A Character : a a is a Vowel. Enter A Character : z…

  • C language

    Switch Case With Break Statement

    switch() can only contain char and int. break is used to exit from switch statement. switch case can be without default case. In switch case char variable is always initialized within ”(single quotes). If there is no break statement then the cases following the matched case other than default will get executed. If there is no any match case then default will be executed. Syntax switch(expression) { case value1: block1; break; case value2: block2; break; case value3: block3; break; case value4: block4; break; default: defaultblock; break; } Example is below :: #include<stdio.h> #include<conio.h> void main() { char grade; clrscr(); printf("Enter your grade:\n");…

  • C language

    else if Ladder In C

    Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression1) { statement block1; } else if(expression2) { statement block2; } else if(expression3 ) { statement block3; } else { default statement; } The expression is tested from the top(of the ladder) to downwards. As soon as a true condition is found, the statement associated with it is executed. Example is shown below :: #include <stdio.h> #include<conio.h> void main( ) { int a; clrscr();…

  • C language

    Nested if…else Statement In C

    Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if( expression ) { if( expression1 ) { statement block1; } else { statement block2; } } else { statement block3; } If the expression is false then block3 will be executed, and if expression is true then again expression1 is evaluated, if it is true then block1 is executed, and if false then block2 will be executed. Example is shown below :: #include<stdio.h>…

  • C language

    if…else Statement In C

    Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression) { //Inside if Statement Are Executed } else { //Inside else Statement Are Executed } //Outside if...else block Statement Are Executed Here, if the expression is true then if block statements are executed and after it directly outside if…else block statements are executed, otherwise else block statements are executed and after it directly outside if…else block statements are executed. It means if expression…

  • C language

    Simple if Statement In C

    Decision making with if statement may be implemented in different forms depending on the complexity of conditions to be tested.The different forms are, Simple if statement if….else statement Nested if….else statement Using else if statement Syntax if(expression) { //Inside Statement Are Executed } //Outside Statement Are Executed Here, If  the expression evaluated as true then inside statements are executed, otherwise outside statements are executed. If the if block has only one statement then there is no need to put curly braces {}, but if the if block has more then one statement then it must put curly braces. Example is…

  • C language

    Use Of puts() Function

    puts() function is used to write a line to the output screen. It means puts() function can print entire sentence with white spaces. #include <stdio.h> #include <conio.h> void main() { char string[40]; clrscr(); printf("Enter your full name :: "); gets(string); printf("\n\nYou entered ") puts(string); getch(); } OutPut Enter your full name :: Suvidha Malaviya You entered Suvidha Malaviya It’s Done. Keep It Up Guys…

  • C language

    Use Of gets() Function

    Some of the important point to note :: scanf() and gets() both are used to take input from the user. scanf() can only take input until it encounters a space. The words after space are ignored by it. It means it takes input of only one word. gets() is used to take a single input at a time but can be used to input a complete sentence with spaces unlike scanf(). It means it gets input from user until user hit enter key. gets() takes only a single line at a time. Example is below #include<stdio.h> #include<conio.h> void main() {…

  • C language

    Find ASCII Value For Character

    Here, we are finding ASCII value of any input character. %c is the format specifier to take character as input. Here, when we use %d instead of %c for character variable then it will print integer ASCII value of character. #include<stdio.h> #include<conio.h> void main() { char character; clrscr(); printf("Enter any character : "); scanf("%c" , &character); printf("\n\nASCII value of %c = %d",character,character); getch(); } OutPut Enter any character : s ASCII value of s = 115