Monday, June 18, 2012

To multiply a number by 10 using a function


/* Program to multiply a number by 10 using a function */

#include<stdio.h>

#include<conio.h>

/* Function Declaration */

int mul_by_10(int num);

void main()

{

  int result,n;

  clrscr();

  printf("Enter the number:");

  scanf("%d",&n);

  printf("\n Number = %d before function call",n);

  result=mul_by_10(n);  /* Function Call */

  printf("\n New Number = %d after function call",result);

  getch();

}

 

/* Function Definition */

int mul_by_10(int num)

{

  num*=10;

  return num;

}

 

OUTPUT

Enter the number:5

 

 Number = 5 before function call

 New Number = 50 after function call

 

No comments:

Post a Comment

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