- 1
Program to calculate the power of the numbers 1 to 5?any body tell me what is mistake this program?
#include <iostream> using namespace std; int main () void main(void) { clrscr( ); double pow=1; int i,num,p; printf("Enter number:"); scanf("%d",&num); printf("\nEnter power:"); scanf("%d",&p); for(i=1;i<=p;i++) { pow*=num; } printf("\nAnswer is %f",pow); getch( ); }
3 Answers
+ 2
You can put C++ in your thread tags instead of '@nothing', your question is relevant to C++.
+ 2
You have mixed two languages c and c++.
One major error is that main can't return void in cpp.
cin is used in place of scanf
cout is used in place of printf
Functions such as clrcsr() and getch() shouldn't be used without proper import or definition.
I would say that you should first of all learn at least some of the basics of cpp.
Then it wouldn't be much difficult for you to answer this question.
Keep coding đ
+ 1
Can you give an example of your input and the expected output. Power of the numbers 1 to 5, what does it mean?