+ 3

If I write b[a[i]] =a[i] I got error in code

Why it cause error

19th Jul 2018, 5:34 AM
Vijay
Vijay - avatar
10 Respuestas
+ 9
'array subscript is not an integer' This message tells you, that value you pass as index must be converted to int type (you pass double)
19th Jul 2018, 5:42 AM
Rull Deef 🐺
Rull Deef 🐺 - avatar
+ 8
Maybe you forgot ';' It is hard to guess until you show full code with this line
19th Jul 2018, 5:38 AM
Rull Deef 🐺
Rull Deef 🐺 - avatar
+ 7
%f
19th Jul 2018, 5:44 AM
Rull Deef 🐺
Rull Deef 🐺 - avatar
+ 5
Yes
19th Jul 2018, 5:45 AM
Rull Deef 🐺
Rull Deef 🐺 - avatar
+ 2
Thanks bro
19th Jul 2018, 5:46 AM
Vijay
Vijay - avatar
19th Jul 2018, 5:39 AM
Vijay
Vijay - avatar
+ 1
If I got a int value I use %d if I got double value what I wanna to use
19th Jul 2018, 5:41 AM
Vijay
Vijay - avatar
+ 1
If I pass double what I have to get bro
19th Jul 2018, 5:43 AM
Vijay
Vijay - avatar
+ 1
Its a float sign is this equal to double also
19th Jul 2018, 5:45 AM
Vijay
Vijay - avatar
+ 1
Hello Mano Vijay, (Note: @ = Line number) Efficiency speaking, why allocate 100 elements for <a> & <b> @7 while you ask for number of elements <n> @15? allocate <a> & <b> as much as <n> input. @10 <b> array contains 100 elements, indexed 0-99, your loop should be for(i=0; i<100; i++) @19 <a> is of double type, use %lf as format in scanf @28 You can't use floating numbers for indexing array. <a> is of double type, b[a[i]] you are pointing to an element in <b> using <a> which is double (floating number). @34 if(b[i]!='s') <b> is of double type, and here you are comparing with char. @36 printf("%d",b[i]); use %lf for printf format
19th Jul 2018, 6:17 AM
Ipang