+ 2
How do I correct my code?
I just started learning arrays in c language...so I'm kind of experimenting. I tried making a code that searches for the first number of an array. What do you think is wrong? Please help. https://code.sololearn.com/cttLKrL04g53/?ref=app
2 RĂ©ponses
+ 1
Iâm not sure if Iâm understanding you, in your code you have 2 variables: n and first, but after scanning you are not using ânâ at all.
First is also an integer variable but you wrote it like (10 17 45 92..) So it makes me think that youâre trying to use it as an array right?
If you want First to be an array of integers you should declare it as
int first[number of elements] = {10, 17, 45, 92, 56âŠ. The rest of the numbers}
If you only want the first element of the array you could do printf(âFirst digit = %dâ, first[0])
If you want to search value of n inside the first array then you should think how to change your while loop :p
+ 1
Guillem Padilla oh. I understand it already. Thanks!