Write a C program with 4 functions in main
1 int intSum(intx, int y)
accept 2 ints as parameters
adds the 2 # up
returns the sum
2. int intdiff(intx, inty)
accepts 2 # as param.
subtracts them
returns with diff.
3 int intProd(intx, int y)
accepts 2 #
muiltplies them
returns product
4 double Quot(int x, int Y)
accepts 2 #
divides them
returns quot/ with remainer as decimel.
should spit out
the sum of the 2 mnumbers is
the difference of 2 numbers is
the product of 2 numbers is
the quotient of 2 numbers is

*  Name:           template
*  Author:         Francis Waldron     
*  Date due:       25/09/06
*  Description:    basic C++ programming 

*     libraries
#include <iostream>            // needed for Cin and Cout
using namespace std;

*     defines
#define  PI  3.14159

*     function prototype

*      global variables

int main()
    int numX;
    int numY;
    int z;
    cout << " enter first number:  \n";
    cin >>numX;
    cout << " enter second number:  \n";
    cin >> numY; 
    z = intSum(x,y)
    cout << " The sum of two numbers is" << z << "\n";
    z = intDiff(x,y);
    cout << " The difference of the two numbers is" << z <<"\n";
    z = intProd(x,y);
    cout << "The Product of two numbers is"<< z <<"\n";
    z = inQuot(x,y)
    cout << " The quoent of two numbers is"<< z <<"\n";
int intSum( int x, int y)
    int s=0;
    s = x + y;
    return s;
int inDiff(int x, int Y)
    int d = 0; 
    d = x - y;
    return d;
int inProd(int x, int y)
    int p = 0;
    p = x * y; 
    return p;
double Quot(int x, int y)
       double q = 0;
       q = x % y;
       return q;
     return 0;
10 Years
Discussion Span
Last Post by WaltP

I don't see a question, nor code. Please read the post at the top of the forum about homework...


int main()

Typo, it should be a {

z = intSum(x,y)

You didn't declare x nor y, I think you want to send numX and numY. ( intSum(numX, numY); )
Same with the other 3 functions.

You need to declare the functions before you use them.

put this:
int intSum( int , int );
int intDiff(int , int );
int inProd(int , int );
double Quot(int , int );

Above main().

And there are a lot of typ-errors in your code. Please note that C is CASE-sensitive. Also look for missing semi-colons ( ; ). If you call your function Quot(), don't call it with inQuot or intQuot.

return 0;

This should be in Main(). This doesn't do anything right now. I have a working code for you, but first try to correct it your self.

regards Niek


Code is saved as an attached file to the post. See it?

Yeah, but I don't open attachments.... I practice safe computing ;)
But there still wasn't a question, nor an explanation of what was wrong.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.