@melody
frankly speaking, i think most of the people here don't know what your code do. or maybe its just me lol
1 2 3
|
int x;
cout << "Enter the value of x: ";
cin >> x;
|
pretty obvious you declared x here, but after input, you never used it anymore. why?
Y = Y + (float)(N^(count))/ (float)factorial(count);
is the N here supposed to be x? you did not declare N before this, so i'm guessing that you know that you do not need N, but accidentally typed it in?
edit:
one does not usually make declarations within the function brackets, unless its for passing values, as said by @ciphermagi. and global declarations is the easy way out. passing values are more efficient for a program to run.
for example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
int main ()
{
...
char x;
side_function(x);
...
}
int side_function (char y)
{
...
//y process
...
}
|
declarations in the function brackets are known as arguments.
the code above, has a main function, and a side function. notice that main has no arguments. (tip: usually main has no arguments at all) side_function have an argument though. why?
because, in the main function, we are calling side_function, and we are passing the char x to it. side_function accepts the value of x, and stores it in y. note that x variable is only known to main and likewise for y and side_function.
in return, do we ever call main function? nope. therefore, usually there are no arguments in the main.
side_function can then proceed to process y, and produce a result. this is just one of the simple examples available. hope this helps.