A program that doesn't work
[Dal] Posted messages 6122 Registration date Status Contributor Last intervention -
hello.
I would like to submit my program because it does not work although I do not see the error, could you help me please thank you.
Here is the code :
#include <iostream> #include <cmath> using namespace std; int main () { int a; int b; int resultat; cout<<"enter a number"<<endl; cin>>a; cout<<"enter a second number"<<endl; cin>>b; resultat = pow(a,b); cout << "The power of " << number << " is " << resultat <<endl; reuturn 0; } ***** For easier reading of the code, in the future use the code tags.
4 answers
Hello,
The error is in the last line which contains a typo. reuturn does not exist.
To conquer without peril is to triumph without glory.
Pierre Corneille, Le Cid
Hello, teschan
"number" is not a declared variable either.
These errors are described by the compiler.
Isn't it more efficient to look at the error messages than to post a question "it doesn't work" on a forum?
Here, I declared resultat but it's still not working: here is my source code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a;
int b;
int resultat;
cout<<"enter a number"<<endl;
cin>>a;
cout<<"enter a second number"<<endl;
cin>>b;
resultat = pow(a,b);
return 0;
}
Please respond to me as soon as possible.
Here is what the compiler says when asked to display warnings:
$ g++ -Wall -Wextra 37958782.cpp 37958782.cpp: In function ‘int main()’: 37958782.cpp:10:8: warning: variable ‘resultat’ set but not used [-Wunused-but-set-variable] int resultat; ^~~~~~~~ It tells you that you have assigned something to the variable "resultat" but that you are not using this variable.
If you expect your program to display the result... why are you not displaying it?