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............. 

Reading and writing integer number

Now here we describe how to read and write the integer number-

Writing integer number:

printf function is used for format specifier with wd where  w stands for bit and it is optional.
Ex. 
int a=51769;

printf("%d",a);

output=51769

printf("%8d",a);

output=_ _ _51769

here when write 8d mean 8 box or part space create and number start filling from last.

printf("%2d",a);

output=51769

Reason:when w is lesser than data then no effect on output.
printf(%08",a);

output: 00051769

printf("%-8d %d",a,a);

Output:51769_ _ _51769

Reading the integer number:

To use integer number we use scanf,

scanf("format_specifier",arg1,argg2,_ _ _ );
.
The first specifiers is used to read integer no. is %wd where is w is the bit
Ex.:
a=51769 , b=25769

scanf("%2d %2d",&a,&b);

output: In this value of  a will be starting two no. mean a=51 and value of b will not be considered this time value of b will be 76.
.
Thank you,
please comment if any doubt or more explain  on any heading.


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