im trying to multiplicate the a num through 10 elevated by (max -1 -i). As soon as max is the size of array, and i is initialed for (max -1). Im utilizing a because that loop, i--.

You are watching: C++ expression must have integral or unscoped enum type

im using the pow() function, and also therefor had actually to define i together a float, or a double. Perhaps max too, but it doesnt give me an error.

int sum = 0;float j = 0, i;int max;printf("Enter number of digits: ");scanf_s("%d", &max);int *a;a = (int *)malloc(max * sizeof(* a));for (i = 0; ns = 0 ; i--)2 sum = amount + a*pow(10, max -1 -i); j++;When trying to compile, it offers me one error at lines 1 and 2.. Pointing ~ above and saying that expression must have actually integral or unscoped enum type

the (max - 1 -i) b.t.w is rather of one extra variable.. Im trying to minimization them

help?


c
share
boost this concern
follow
inquiry Sep 8 "15 in ~ 2:27
*

DanielDaniel
15422 silver- badges1212 bronze badges
11
| present 6 much more comments

2 answer 2


energetic oldest Votes
3
Exactly as the error blog post says. I must have an integral kind such as int. You can"t use a rise as range index.


re-publishing
enhance this prize
follow
answered Sep 8 "15 at 2:29
*

man KugelmanJohn Kugelman
322k6666 gold badges492492 silver badges544544 bronze badges
7
| display 2 much more comments
1

If you have actually (more or less) complicated expression in one line which does not compile, distrubute it over several lines to give the compiler a possibility to allude you what it does not like:

For instance replace

sum = amount + a*pow(10, max -1 -i);by

sum = sum + a * pow( 10, max -1 -i);After have fixed the bug, eliminate those masive new-lines.


re-superstructure
improve this prize
monitor
answered Sep 8 "15 at 5:15
*

alkalk
67.7k1010 gold badges8686 silver badges229229 bronze badges
add a comment |

your Answer


Thanks because that contributing an answer to ridge Overflow!

Please be sure to answer the question. Carry out details and share her research!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based upon opinion; back them increase with references or an individual experience.

To learn more, watch our tips on writing great answers.

See more: Land At A Run Down Hero Mansion, Fortnite Battle Royale


Draft saved
Draft discarded

Sign increase or log in


sign up utilizing Google
sign up making use of Facebook
authorize up utilizing Email and also Password
send

Post together a guest


name
email Required, yet never shown


Post together a guest


name
email

Required, yet never shown


write-up Your prize Discard

By click “Post her Answer”, friend agree to our terms of service, privacy policy and cookie policy


Not the prize you're looking for? Browse various other questions tagged c or asking your very own question.


The Overflow Blog
Featured top top Meta
Linked
2629
Do I cast the result of malloc?
associated
282
how to specify an enumerated form (enum) in C?
3
C expression must have actually integral or enum type?
0
#31 expression must have actually integral form
7
expression must have actually integral form
3
error: expression must have integral or enum form
1
Why doesn't mine program occupational with float variables, however it does v int variables?
0
Error blog post "Expression must have integral or unscoped enum type"
0
gaining "expression must have integral type" error when using Ternary Operator
warm Network concerns an ext hot concerns

concern feed
subscribe to RSS
concern feed To i ordered it to this RSS feed, copy and also paste this URL right into your RSS reader.


*

lang-c
stack Overflow
assets
firm
stack Exchange Network
site design / logo © 2022 ridge Exchange Inc; user contributions licensed under cc by-sa. Rev2022.1.14.41173


Stack Overflow works finest with JavaScript permitted
*

your privacy

By click “Accept every cookies”, you agree stack Exchange deserve to store cookie on your machine and disclose details in accordance with our Cookie Policy.