please help me...I can't get the correct output...My professor suck's because she's didn't discuss thoroughly the in's and out's of C programming..pl ease help...Here's the problem: I have to write a program using a function that when you input a number, it will add the number from 1 to the number that was input, also you will show how the numbers where squared.
Desired output:
Enter a number: 5
1+4+9+16+25
The sum is: 55
My ouput:
Enter a number: 5
1+4+9+16+25
The sum is: 5869
Thank you very much in advance..here's my code, there's definitely wrong with this
Desired output:
Enter a number: 5
1+4+9+16+25
The sum is: 55
My ouput:
Enter a number: 5
1+4+9+16+25
The sum is: 5869
Thank you very much in advance..here's my code, there's definitely wrong with this
Code:
#include <stdio.h>
int funct(int x);
int functi(int y);
int main()
{
int c, d, num;
clrscr();
printf("\nEnter a number: ");
scanf("%d",&num);
for(c=1;c<=num;c++){
printf("%d+",funct(c));
}
printf("\nThe sum is: %d",functi(d));
getch();
}
int funct(int x)
{
int a;
a=x*x;
return a;
}
int functi(int y)
{
int b;
b=y+b;
return b;
}
Comment