| | |
error mgs when trying to compute "for loop"
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2004
Posts: 1
Reputation:
Solved Threads: 0
I'm new to C++, and I'm trying to solve a problem to compute an exponent of an integer to a float. The following is the psuedo code:
Declare x as a float
Declare y as an integer
Declare i as an integer
Declare result as a float
Input x //any float
Input y //positive integer
set result = 1 //intial valuue
For i = 1 to y
result = result *x
end for
output result
I have no problem with declaring the variables or reading in the variables. I have problems with my calculations using the "for loop". This is what I have so far:
For (i = 1; y>=0; i++);
{
result = result *x;
End for
}
The program is suppose to allow the user to input the variables (x,y) to solve x^y. I know a number multiplied by itself would give you the exponent, but I'm missing something to allow me to do that.
Thanks in advance for your help.
dkm30
Declare x as a float
Declare y as an integer
Declare i as an integer
Declare result as a float
Input x //any float
Input y //positive integer
set result = 1 //intial valuue
For i = 1 to y
result = result *x
end for
output result
I have no problem with declaring the variables or reading in the variables. I have problems with my calculations using the "for loop". This is what I have so far:
For (i = 1; y>=0; i++);
{
result = result *x;
End for
}
The program is suppose to allow the user to input the variables (x,y) to solve x^y. I know a number multiplied by itself would give you the exponent, but I'm missing something to allow me to do that.
Thanks in advance for your help.
dkm30
![]() |
Similar Threads
- "for loop" (C++)
- XP restart "loop" (Windows NT / 2000 / XP)
- google "keyword" question (Search Engine Optimization)
Other Threads in the C++ Forum
- Previous Thread: help with first and second problem
- Next Thread: Seg Fault
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets





