W e b t u t o r i a l s

Programing Approach

Algorithm, Flow Chart

Define C

Define Programming

C - Syntax

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

Control Structure

Control Structure - if

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Constant Variable

C - Escape Sequence

C - Arrays 1D, 2D

C - Sorting

ASCII Value

Character I/O Function

C - Strings

Ex: Strings

Array of Strings

C - Math Functions

C - Functions

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

Typedef File Handling

Command Line Argument

MCQ

Types of function In C

In C, when function is called with arguments, there are 2 ways to pass the arguments, i.e call by value & call by reference.

1. Call by value : When a function is called and value of a variable is passed via argument it is known as call-by-value. In this case, any changes made inside the function have no effect on the other functions.

2. Call by Reference : When a function is called and address of a variable is passed via argument it is known as call-by-reference. In this case, changes will reflect in the other functions.

Example 1: Call-by-value.

#include<stdio.h>
#include<conio.h>
//call by value
void fun(int); //function declaration
void main()
{
 int a=10;
 clrscr();
 fun(a);  //function call
 printf("\nValue of A outside function is = %d",a);
 getch();
}
void fun(int a) //function defination
{
  a=20;
  printf("\nValue of A in function is %d",a);
}

Output:

Value of A in function is 20

Value of A outside function is 10

Value change inside function will NOT reflect in main function.

Example 2: Call-by-reference.

#include<stdio.h>
#include<conio.h>
//call by reference
void fun(int *); //function declaration
void main()
{
 int a=10;
 clrscr();
 fun(&a);  //function call
 printf("\nValue of A outside function is = %d",a);
 getch();
}
void fun(int *a) //function defination
{
  *a=20;
  printf("\nValue of A in function is %d",*a);
}

Output:

Value of A in function is 20

Value of A outside function is 20

Value change inside function will reflect in main function.

Recursion function

Recursion function call itself up to the condition is not satisfied. In recursion function we cannot use any loop only if condition is used.

Questions on Recursion:
1. Find factorial.
2. Find Greatest Common Divisor
3. WAP to calculate x power n

Updated: 15-Dec-18