0

i tried to create a program that would get the sum of the squares but i couldn't get the right output. Could u help me debug? and tell which part of my codes where wrong.PLEASE!
:S

#include<iostream.h>
#include<conio.h>
#include<math.h>
int x,num;
int f(int);
main ()
{

clrscr();
    cout<<"Enter a number: ";
    cin>>num;
    cout<<f(num);
getch ();
return 0;
}
int f(int s)
{
for(x=1;x<=s;x++)
{
int ans2;
 int y;
int ans[10];
ans[y]=pow(x,2);
ans2=ans[y]+ans[y];
cout<<ans2;
y++;
}
return 0;
}
3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by nirav99
0

thanks for the help.
i really appreciate the effort,
but i still couldn't get the right output.

0

I finally got the correct codes.:icon_cheesygrin:
thanks for those who helped....:)

0

i tried to create a program that would get the sum of the squares but i couldn't get the right output. Could u help me debug? and tell which part of my codes where wrong.PLEASE!


firend
hi...
your program is totally correct
but u r not getting ur output properly
so put

cout<<" "<<ans2;
instead of cout<<ans2;

okay...

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.