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

Storage Class Part 2

This is a second part of storage class.............................

Extern:

  • Keyword used is extern.
  • Identifiers declares in global scope by default has extern storage class.
  • If the extern variable is declared in local scope then it cannot be initialized with declaration but if it is declared with global scope than it can be initialized with declaration.
  • The extern storage class specifiers is used to  specify that an object is defined with external linkage.
  • Extern variable can not be used in parameter.
Ex.
#include<stdio.h>
int a=20;
main()
{
print("Value of a:%d",a);
}

Output:
Value of a:20


Typedef:

  • typedef is used for syntactic convenience.
  • Used for creating a synonyms or alias for a known type.
  • Does not introduce a new type.
Syntax: typedef datatype   variable name   new name;

Ex.
#include<stdio.h>
main()
{
typedef int pi;
pi x=5,y=10;
printf("x=%d\n",x);
printf("y=%d\n",y);
return 0;
}
 
output:
x=5
y=10


Thanks guys
keep supporting..................




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