# 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? 10 2029
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
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
questions wrote:
y=x%pow(10,3);
What's wrong with 1000?
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
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
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.
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
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
On 10ÔÂ28ÈÕ, ÏÂÎç7ʱ56·Ö, Zeppe
<ze...@remove.all.this.long.comment.yahoo.itwrot e:
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
On 10ÔÂ29ÈÕ, ÉÏÎç7ʱ18·Ö, Kai-Uwe Bux <jkherci...@gmx.netwrote:
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
thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: titan0111 |
last post by:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace std;
class snowfall
{
private:
int ft;
|
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...
|
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...
|
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();...
|
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...
|
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...
|
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
|
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=
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |