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

Rule of function declaration and type of variable

Hello guys , today in this my post i will tell you some basic rule of  function declaration and how many types of variable we use in function .

Rule of function variable:

  1. Find declaration needs to be ended using semicolon.
  2. Return type is optional.
  3. Type of  parameter & number of parameter are combings called parameter list. The parameter C in the list may or may not have parameter name.
  4. No parameter can have some names even parameter name and function name cannot be same.
  5. A function need not be declared if it is defined before it is called.
Ex. Void add ( int , int )
The above declaration declare a function name and with two parameter of type of int and return type of void ( function does not return ).
 Function header is same as function declare but without a semicolon,It consist of return type , function name , parameter type and no. of parameter.

Variable:


There are two types of variable in function-
  • Local variable
  • Global variable

Local variable:

 It is a variable that is defined inside a function and can not be used outside that function.

Global variable:

It is a variable that are declare  outside any function and where values can be used in any function without posting it to any function.

Parameter:

Parameter are used to pass values to called function and are also use to receive values from calling function.There are three type of parameter 
  • Formal parameter 
  • Actual parameter

Actual parameter:

Actual parameter are those parameter which have the original copy of parameters. The parameter passed in the function call are called actual parameter.Scope of actual parameter are only with in called function.

Formal parameter:

Formal parameter are those parameter which have duplicate copy of parameter.The parameter in function header as called formal parameter ( scope is within called function).


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