I don't know where the problem with my program is. I keep getting an error that says the function doesn't take 1 argument. I have two arguments listed for the function everytime I mention it. The error is said to be in line 46. Any help would be great.
Code:
#include <stdio.h> int total(int hi, int count); int main (int) { int n; /*Input by the user*/ int m; /*Input by the user*/ int lo; /*Assigned the lower number*/ int hi; /*Assigned the higher number*/ int count; /*Prompt the user to input 2 numbers*/ printf("This program will add the range of numbers entered."); printf("\n\nEnter the low number and the high number.\n\n"); /*Accept the user input*/ scanf("%d%d", &n, &m); /*Determines the hi and lo*/ lo = (n < m) ? n : m; /*Assigns the lower number to lo*/ hi = (n > m) ? n : m; /*Assigns the higher number to hi*/ count = (hi - lo) + 1; /*Counts the total number of numbers in range*/ /*Call function*/ total(hi, count); printf("\nThe sum of the range of numbers %d and %d is %d.\n\n", lo, hi, total(hi, count)); } #include <stdio.h> int total(int hi, int count) { if (count == 1) return (hi + 1); else return (hi + total(hi - (count - 1))); }
Comment