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

What is initialization ?

Hello friends, I was forget to tell you about initialization so we will cover initialization here.

Initialization:


Variable are created for use in the program hence we need a value to the variable before using the variable.There are two type initialization-
  • Compile time
  • Run time

Compile time:

The initial value of the variable is known before execution of the program before the execution of the program.

Dynamic (run ) initialization:

If refers to run time initialization   initial value of the variable is not known until the program is executed.


Comments:

Comments are special feature of programming it is used to provide discussion to the programmer all user. These comments are only available therefore only available the logic as well as meaning of the variable used.

Single line comment :

It is use to give description that continuous in a single line the symbol use  // 

Multiple line comment :

Multiple line comment meant for describing statement 

The symbol used 

/*----------

  -------------*/

For Ex.:


/* program for
  comment explanation */
main( )
{
printf("Hello to all");
//program ends
}

Wap  a program to input two numbers and swap the content -
#include<stdio.h>
main()
{
int n1,n2,temp;
printf("Enter value of n1 and n2:");
scanf("%d %d ",&n1,&n2);
temp=n1;
n1=n2;
n2=temp;
printf("After swap n1 and n2 is %d %d ",n,n2);
}

Thank you;

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