Monday, February 21, 2011

Functions Program!!

This Program illustrates the use of  'functions'. The first function adds while the second subtracts the given 2 numbers

PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
 {
  int a,b;
  clrscr();
  printf("Enter A:");
  scanf("%d",&a);
  printf("Enter B:");
  scanf("%d",&b);
  sum(a,b);
  diff(a,b);
  getch();
 }

sum(int x,int y)
 {
  int ad;
  ad=x+y;
  printf("Sum=%d",ad);
 }

diff(int x,int y)
 {
  int su;
  su=x-y;
  printf("Difference=%d",su);
 } 


No comments:

Post a Comment