Thread: problem with program

  1. #1
    Registered User
    Join Date
    Nov 2003

    problem with program

    Im new here and im having a problem with my program:
    Im suppose to ask the user for 3 values; then im suppose to add those up and then find all possible products of those 3 values. I need to have 3 functions: one for the sum, one for the products and one to print out the results. I also have to use header files for these fuctions. Im getting 10 errors and im not sure

    what i have so far:
    This is the main fucntion:

    [CODE]#include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include "sum.h"
    #include "mul.h"
    #include "print.h"

    int i;
    int q[9];

    int sum(int,int,int);

    void mult(int,int,int,int[]);

    void print(int,int,int,int,int[]);

    int main(void){

    int integer1;
    int integer2;
    int integer3;
    int k;

    printf("Enter a value for integer1:");


    printf("Enter a value for integer2:");


    printf("Enter a value for integer3:");


    k=sum(integer1, integer2, integer3,k);


    print(integer1, integer2, integer3, k, q);



    this is the header file for sum:

    int sum(integer1, integer2, integer3){

    int i=0;

    i = (integer1+integer2+integer3);



    this is the header file for mult:

    void mult(integer1, integer2, integer3, q)
    int i;
    int j;
    int counter = 0;
    int y[3];
    y[0] = integer1;
    y[1] = integer2;
    y[2] = integer3;

    for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
    q[counter] = y[i] * y[j];


    this is the header file for print:
    void print(integer1, integer2, integer3, k, q){

    printf("the numbers %d + %d + %d =%d\n", integer1, integer2, integer3,k);

    printf("%d * %d = %d\n",integer1,integer1,q[0]);
    printf("%d * %d = %d\n",integer1,integer2,q[1]);
    printf("%d * %d = %d\n",integer1,integer3,q[2]);
    printf("%d * %d = %d\n",integer2,integer1,q[3]);
    printf("%d * %d = %d\n",integer2,integer2,q[4]);
    printf("%d * %d = %d\n",integer2,integer3,q[5]);
    printf("%d * %d = %d\n",integer3,integer1,q[6]);
    printf("%d * %d = %d\n",integer3,integer2,q[7]);
    printf("%d * %d = %d\n",integer3,integer3,q[8]);




  2. #2
    Registered User
    Join Date
    Jan 2003
    show us the errors at least

    we can't even tell whats in those header files you included.
    there are only 10 people in the world, those who know binary and those who dont

  3. #3
    Registered User
    Join Date
    Nov 2003
    nevermind i was able to figure it out

  4. #4
    Casual Visitor
    Join Date
    Oct 2001
    int sum(int,int,int);
    k=sum(integer1, integer2, integer3,k);
    This is one problem I'd suspect. Your prototype doesn't match your parameter list here. Aside from that, k is not initialized before it's used here I don't believe.

    Like Kurz7 stated, post the errors that your getting.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 11:10 AM
  2. Program Termination Problem
    By dacbo in forum C Programming
    Replies: 3
    Last Post: 01-23-2006, 02:34 AM
  3. Inheritance and Dynamic Memory Program Problem
    By goron350 in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2005, 02:38 PM
  4. Replies: 20
    Last Post: 06-12-2005, 11:53 PM