Tuesday, 15 September 2015

C PROGRAMMING-- ADDITION USING FUNCTIONS

1. without returning any value.
#include<stdio.h>
#include<conio.h>
void add(int,int);
void main()
{ clrscr();
        int a,b;
printf("enter the numbers=\n");
scanf("%d\n%d",&a,&b);

       add(a,b);
getch();
}
void add(int x,int y)
{ printf("addtion=%d\n",x+y);
}


2.  with returning value
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{ int a,b;
printf("enter the numbers=\n");
scanf("%d\n%d",&a,&b);


printf("addition=%d",add(a,b));


getch();
}
int add(int x,int y)
{ return x+y;
}


No comments:

Post a Comment