Friday, 28 October 2011

User defined Function in C

/* There are 4 types of functions a programmer can make
1: No Arguments No Returning type function
2: No Arguments but Returning type fuction
3: Argument but  No Returning type function
4: Arguments and Returning types function

A simple program to understand the No Argument and No Returning type function.....
1: No Arguments No Returning Type function  */



#include<stdio.h>
#include<conio.h>
void sum();      /* Function declaration  part and type of the function is void i.e. no returning type */
void main()
{
clrscr();
sum();   // Calling of the function  //
getch();
}


// Definition of the function //
void sum()
{
int a,b,s=0;
printf("Enter the numbers: ");
scanf("%d %d",&a,&b);
s=a+b;
printf("The sum of the numbers= %d",s);
}

No comments:

Post a Comment