473,770 Members | 4,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's wrong?

# include <stdio.h>
# include <math.h>
int main()
{ long int x,y;

printf("enter an integer\n");
scanf("%d",&x);

y=x%pow(10,3);

printf("the result is %d",y);

return 0;}

The compiler tell me there is something wrong with the "pow",but I
don't know what's the wrong?
Oct 28 '08 #1
10 2062
questions wrote:
# include <stdio.h>
# include <math.h>
int main()
{ long int x,y;

printf("enter an integer\n");
scanf("%d",&x);

y=x%pow(10,3);
[snip]
The compiler tell me there is something wrong with the "pow",but I
don't know what's the wrong?
pow() returns a floating point (in this case, I guess a double) and x is a
long int. That is not a valid pair of operand types for the % operator.
Best

Kai-Uwe Bux
Oct 28 '08 #2
questions wrote:
# include <stdio.h>
# include <math.h>
int main()
{ long int x,y;

printf("enter an integer\n");
scanf("%d",&x);

y=x%pow(10,3);

printf("the result is %d",y);

return 0;}

The compiler tell me there is something wrong with the "pow",but I
don't know what's the wrong?
my compiler says:

testmod.cpp:8: warning: format ‘%d’ expects type ‘int*’, but argument 2
has type ‘long int*’
testmod.cpp:10: error: invalid operands of types ‘long int’ and ‘double’
to binary ‘operator%’
testmod.cpp:12: warning: format ‘%d’ expects type ‘int’, but argument 2
has type ‘long int’

It looks pretty much clear. Listen to your compiler. It's your friend.

Best wishes,

Zeppe
Oct 28 '08 #3
questions wrote:
y=x%pow(10,3);
What's wrong with 1000?
Oct 28 '08 #4
Juha Nieminen wrote:
questions wrote:
> y=x%pow(10,3);

What's wrong with 1000?
Nit: 1000 does not occur in the above whereas 1000.0 does occur.
Best

Kai-Uwe Bux
Oct 28 '08 #5
Kai-Uwe Bux wrote:
Juha Nieminen wrote:
>questions wrote:
>> y=x%pow(10,3);
What's wrong with 1000?

Nit: 1000 does not occur in the above whereas 1000.0 does occur.
Best

Kai-Uwe Bux
Another nit : Seeing the % sign suggests that the intent is to use 1000
Oct 28 '08 #6
Kai-Uwe Bux wrote:
Juha Nieminen wrote:
>questions wrote:
>> y=x%pow(10,3);
What's wrong with 1000?

Nit: 1000 does not occur in the above whereas 1000.0 does occur.
But 1000 would work, whereas 1000.0 wouldn't.
Oct 28 '08 #7
Juha Nieminen wrote:
Kai-Uwe Bux wrote:
>Juha Nieminen wrote:
>>questions wrote:
y=x%pow(10,3);
What's wrong with 1000?

Nit: 1000 does not occur in the above whereas 1000.0 does occur.

But 1000 would work, whereas 1000.0 wouldn't.
Ah, now I understand your point: you meant to replace pow(10,3) by 1000.
Sorry for the noise.

Kai-Uwe Bux
Oct 28 '08 #8
On 10ÔÂ28ÈÕ, ÏÂÎç7ʱ49·Ö, Kai-Uwe Bux <jkherci...@gmx .netwrote:
questions wrote:
# include <stdio.h>
# include <math.h>
int main()
{ long int x,y;
printf("enter an integer\n");
scanf("%d",&x);
y=x%pow(10,3);
[snip]
The compiler tell me there is something wrong with the "pow",but I
don't know what's the wrong?

pow() returns a floating point (in this case, I guess a double) and x is a
long int. That is not a valid pair of operand types for the % operator.

Best

Kai-Uwe Bux
thanks
Oct 29 '08 #9
On 10ÔÂ28ÈÕ, ÏÂÎç7ʱ56·Ö, Zeppe
<ze...@remove.a ll.this.long.co mment.yahoo.itw rote:
questions wrote:
# include <stdio.h>
# include <math.h>
int main()
{ long int x,y;
printf("enter an integer\n");
scanf("%d",&x);
y=x%pow(10,3);
printf("the result is %d",y);
return 0;}
The compiler tell me there is something wrong with the "pow",but I
don't know what's the wrong?

my compiler says:

testmod.cpp:8: warning: format '%d' expects type 'int*', but argument 2
has type 'long int*'
testmod.cpp:10: error: invalid operands of types 'long int' and 'double'
to binary 'operator%'
testmod.cpp:12: warning: format '%d' expects type 'int', but argument 2
has type 'long int'

It looks pretty much clear. Listen to your compiler. It's your friend.

Best wishes,

Zeppe- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
thanks
Oct 29 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
14846
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
5
2836
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
5895
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
121
10172
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
28
3278
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr(); fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
56
4341
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on C. wat type of questions should be expected? Which part of C language do the staff give more concern? The interviewers have just mentioned that .. i will have interview on C. Also can anyone can help me with sites where i can go thru sample
46
4257
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do believe MSFT should do to improve C#, however. I know that in the "Whidbey" release of VS.NET currently
13
5058
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
2123
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
2147
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when Record (i) is shown and modified, the change will come to Record (i+1). Can anyone provide suggestion? thanks.
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10071
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.