See a problem in else if statement

Dangling else problem

Image
Hello, This problem comes when we use else if statement and do some mistake more describe is given below......... Dangling else problem: One of the major problem with nested if is dangling else problem. The problem arises when both outer if statement inner if statement might pair with common else statement. Thus the compiler is not able to judge to pair the else with which statement. The solution to this problem is given by the compiler that it pairs else with the recent if thus sometimes giving wrong result.                                           Hence the programmer should put early bracket wherever required. This post is may very short because my only aim was to describe this problem. Thank you, Keep supporting............. 

use of getchar and putchar

Hello guys today i will tell you in this post , use of putchar and getchar............

                         C programming

Input and output functions:

Generally we use printf and scanf as input output functions respectively  but there are various functions available for input and output.

Input and output for character:

Reading a character:

In general scanf function is can be used to input a character but instead of that we can use getchar function.
syntax: variable name=getchar();
                 There are some functions that are used to test a character based on some requirement -

  1. isdigit (ch): It returns a non zero when character digit is digit otherwise returns a 0 value.                                                     
  2. isalpha:It returns a non 0 value if  character is alphabet otherwise returns 0 value.                                                     
  3. islower(ch):It returns a non 0 when character is in lower case alphabet otherwise returns 0 value.                                                                                                                                                     
  4. isupper(ch):It returns a non 0 value if the character is in upper case character otherwise returns 0 value.

 Writing a character :

Putchar function is used to display the program or screen in place of printf. It is only used for character. Generally form is this-
syntax: putchar(var-name);

this is more type for take input and display output to user we can also use getchar and putchar in place of scanf and printf.



Thankyou,
If any doubt please comment below.......

Comments

Popular posts from this blog

Libraray Fine Hackerrank solution in C || Balanced Brackets Hackerrank solution in C

Permutations of Strings hackerrank solution in C || Permutations of Strings

Introduction to C part 2