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

Preprocessor directives short details

In this post we will discus about what is preprocessor directives ? Only some basic knowledge i am going to share with you and whole summary or chapter on this i will post letter.

         Preprocessor directive:


Preprocessor is a special functionality in language that process the source code before it passes to the compiler. It operates under a control of what is known as preprocessor directive.
some types of directives are given below-
  1. Macro substitution 
  2. File inclusion 
  3. Line directive
  4. Compiler control directive
  5. Pregma control Directive

1. Macro substitution directive:

It is a process where identifier is replace by predefined string composed of one or more tokens a preprocessor accomplishes this task under the direction of  #define token. There are two types of macros-
  • Simple macro substitution
  • Augmented macro substitution

(a) Simple macro substitution :

syntax:
#define macro name  macro description 
It is also called as object like macro.
Ex.
#include<stdio.h>
#define PI  3.14
main()
{
flaot area r=3.8;
area =PI*r*r;
printf("%f",area);
}
now here compiler automatically take the value of PI because that is already predefined and in program anytime you can use this. 

(b) Augmented macro substitution:

Augmented macro substitution known as function like macro. The general forms is-
#define macro name(var1 , var2 , .......,varn)      macro description 


Now the basic knowledge of preprocessor is complete.
Thank you,
separate full part will be post later.
Please comment below if question........

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