Thursday, September 4, 2014

write functions for dividing two numbers, finding larger number, and also prints the ATM menu


Problem

Write a function prototype and definition for the following components:
  • A function that divides two numbers and returns the remainder
  • A function that finds the larger of two numbers and returns the result
  • A function that prints an ATM menu (it receives no parameters and returns no value)
Write main function and call the above function and check if it works as required or not.

Solution - Code

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void divi();
void lrg();
void atm();
main()
{
 divi();
 lrg();
 atm();
 system("pause");
}
void divi()
{
 int r,x,y;
 printf ("Enter two numbers : ");
 scanf ("%d%d",&x,&y);
 r = x%y;
 printf("The remainder : %d\n",r);
 system("pause");
}
void lrg()
{
 int x,y;
 printf("Enter two numbers : ");
 scanf("%d%d",&x,&y);
 if (x > y)
 printf ("%d is greater than %d\n",x,y);
 else
  printf ("%d is greater than %d\n",y,x);
 system("pause");
}
void atm()
{
 printf("1.cash withdrawl\n");
 printf("2. Fast cash\n");
 printf("3. Balance inquiry\n");
 printf("4.Transictiobn receipt\n");
}

Sample Output

functions c language

No comments :

Post a Comment

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

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact