473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Primary Expression Error

Please help I don't know what I am doing wrong.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <math.h>
  3. #include <conio.h>
  4. #include <string.h>
  5. #include <iomanip>
  6.  
  7. using namespace std;
  8.  
  9. double powerOf(double x, int n)
  10. {
  11. n++;
  12. return pow(x,n);
  13. }
  14.  
  15. int main()
  16. {
  17. int n=0;
  18. double x=0;
  19. cout<<"Enter the value you want to know the first ten powers for: ";
  20. cin>>x;
  21. for (int i=10;i>0;i--)
  22. {
  23. powerOf(int n, double x);
  24. }
  25. getch();
  26. return 0;
  27. }
  28.  
Dec 2 '08 #1
2 1783
boxfish
469 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. powerOf(int n, double x);
When you call the function, you don't need to specify the types of the arguments. Also, I think you are passing the arguments in the wrong order. Order matters. You can use
Expand|Select|Wrap|Line Numbers
  1. powerOf(x, n);
but you probably meant to pass it the counter variable in your for loop, i:
Expand|Select|Wrap|Line Numbers
  1. powerOf(x, i);
The variable you pass it can have a different name than the function's parameter, so it's okay to pass i for n.
And since the function returns a value, you probably meant to do something with the value, like print it:
Expand|Select|Wrap|Line Numbers
  1. cout << powerOf(x, i) << endl;
I hope this is helpful.
Dec 2 '08 #2
Thanks a lot boxfish it helped :)
Dec 2 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jay | last post by:
hi, Question on Load/import command. consider a sample table create table table_name ( col1 timestamp not null default current timestamp, col2 int, col3 int, col4 int, primary key(col1) );...
4
by: misscrf | last post by:
Ok I have 2 issues. 1) I have a main candidate form with 2 subforms on a tab control: http://www.geocities.com/misscrf/images/contactcontinouscheckbox.jpg I have been encouraged to add these...
3
by: sandy | last post by:
I cannot figure this out. I have the following code: <code> Private: /****************************************************************************** CreateList
4
by: me001 | last post by:
does anyone know hwo i could fix this problem? the error message reads that setName(newFirstname, newLastname); expected primary-expression before ']' token thanks!
3
by: curious2007 | last post by:
Hello, I have the following code: #include <list> #include <iostream> using namespace std; template <class V, class AI, class I, class S> AssocArray<V, AI, I, S>& AssocArray<V, AI, I,...
6
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
4
by: sanctus | last post by:
Is there a typical mistake which generates the error: " error: expected primary-expression before ‘)’ token" because I fail to see why I get this problem and the code is too big to post it here....
8
by: MLZ242 | last post by:
I'm supposed to write a program that is going to calculate absolute value of given number(and print appropriate message) but I'm having tough time with the statements(expected primary-expression...
2
by: emp | last post by:
I have the following class, the primary-expression error takes place in the constructor before "{" token where the maskval array gets initialized. any help would be appreciated emp1953 ...
10
by: tnwagn | last post by:
I have been working on a program and have been unable to resolve these compile issues. g++ main.cpp -o project5.exe main.cpp: In function 'int deal()': main.cpp:20: error: expected...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.