Monday, June 18, 2012

To find the mean of two integer numbers using a function


/* Program to find the mean of two integer numbers using a function */

#include<stdio.h>

#include<conio.h>

/* Function Declaration */

int mean(int x,int y);

void main()

{

  int p,q,n;

  clrscr();

  printf("Enter the first number,p=");

  scanf("%d",&p);

  printf("Enter the second number,q=");

  scanf("%d",&q);

  n=mean(p,q);           /* Function Call */

  printf("\n Output: mean=%d",n);

  getch();

}

 

/* Function Definition */

int mean(int x,int y)

{

  int temp;

  temp=(x+y)/2;

  return temp;

}

 

OUTPUT

Enter the first number,p=23

Enter the second number,q=35

 

 Output: mean=29

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.