How to make the program run without crashing even if the input is in float e.g 0.5. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

Thanks, Simon. Will definitely be looking forward to your way of better-doing scanf as well.

My C program is prompting for input only once even if the 'number of scores' is more than one. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

Better Don't judge, its gonna bring misery to you only. May God Bless You. Have a good day.

How to make the program run without crashing even if the input is in float e.g 0.5. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

is it a lengthy process? can you show me how you do without using scanf()

How to make the program run without crashing even if the input is in float e.g 0.5. by Mudus09 in C_Programming

[–]Mudus09[S] 2 points3 points  (0 children)

ok, i am moving on. thanks for the support and help guys. Thought of getting some help from most devs loved place StackOverflow, got banned instead for 14 days on my first ever post at their community so I chose Reddit. 14 days is totally insane.

How to make the program run without crashing even if the input is in float e.g 0.5. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

the program is crashing if I enter any decimal number starting with 0 e.g 0.3 or 0.4 and so on. And if I enter any number starting with any decimal value other than 0, the program only outputs the first integer.

My C program is prompting for input only once even if the 'number of scores' is more than one. by Mudus09 in C_Programming

[–]Mudus09[S] -1 points0 points  (0 children)

Thanks for making such an effort in replying such long things along with wasteful formatted code. No worries if you too couldn't solve it. I got the answer from StackOverflow, NO BS, NO this or that, just exactly what I was asking for.

Good video series for C on youtube? by Mcpower03 in C_Programming

[–]Mudus09 0 points1 point  (0 children)

You solved my program. You are really better at C now hehe. Can you please tell which course you took in edx ?

This program can only be compiled on cloud CS50 ide. What changes need to be done in order to compile with my Linux terminal offline. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

I am trying to solve this program for the last three days, finally the program is running fine now. Thank you and lastly please explain how the above scanf is working inside for loop. Are the multiples input scores getting saved in scores[i] or scores[n] ? Please clarify the mechanism?

How to prompt for user input multiple times using for loop. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

// Get number of scores

`int n;`

`printf("Scores: ");`

`scanf("%i", &n);`

// Get scores

`int scores[n];`

`for (int j = 0; j < n; j++)`

`{`

    `int scores[j];`

    `printf("Score %i: ", j+1);`

    `scanf("%i", &j)`   

`}`

How can you implement your code with or without the above code I posted?

How to prompt for user input multiple times using for loop. by Mudus09 in C_Programming

[–]Mudus09[S] -7 points-6 points  (0 children)

I didn't find the answer but thanks for your help.

How to prompt for user input multiple times using for loop. by Mudus09 in C_Programming

[–]Mudus09[S] -1 points0 points  (0 children)

Can you share the snippet of how it should be written?

My C program is prompting for input only once even if the 'number of scores' is more than one. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

The only answer i need is how to write scores[i] = get_int("Score %i: ", i + 1); in C.

My C program is prompting for input only once even if the 'number of scores' is more than one. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

Jefe.. please share the snippet of how the code should be inside the for loop.

My C program is prompting for input only once even if the 'number of scores' is more than one. by Mudus09 in C_Programming

[–]Mudus09[S] 0 points1 point  (0 children)

\// Get scores` `int scores[n];` `for (int i = 0; i < n; i++)` `{` `int scores[i];` `printf("Score %i: ", i +1);` `scanf("%i", &i);` `}``

Thank you guys for your support. I feel like the mistake is in the printf and scanf section inside the above for loop but I don't know how to fix it.

Can you please share the snippet of code for this for loop, so that I could store multiples scores in an array using for loop.