Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

Passing Values Homework Help

So far the Functions we have discussed are Void Type. These Functions just display a message. Sometimes, we pass some values to the Function as argument and it returns a value which is used by the main or any other Function.

The following example will illustrate this:

{`#include <stdio.h>
  #include <conio.h>
  int add(int x, int y);
  int sub(int x, int y);
  int mult(int x, int y);
  void main()
  {
  //int a, b, result;
  printf("Enter two integers: ");
  scanf("%d %d",&a,&b);
  result = add(a,b);
  printf("\nThe sum of two numbers is : %d",result);
  result = sub(a,b);
  printf("\nThe difference of two numbers is : %d",result);
  result = mult(a,b);
  printf("\nThe product of two numbers is : %d",result);
  getch();
  }

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

int sub(int x, int y)
{
  int result ;
  result = x - y ;
  return result ;
  }

int mult(int x, int y)
{
  int result ;
  result = x * y ;<
  return result ;
  }`}

Passing Values Homework Help

Topics in C Programming

Copyright © 2009-2023 UrgentHomework.com, All right reserved.