+ 5

First program.. easy for all of you, but I'm proud of it.. Any suggestions for using arrays?

https://code.sololearn.com/ckKpZIH4fIVS/?ref=app

13th Aug 2019, 1:46 AM
Samuele
Samuele - avatar
6 Answers
+ 32
Sonic is right, that's a good start. Not perfect, of course, but it doesn't have to be. It's your first program after all. Keep on practicing and eventually you will code better. About arrays: I don't think a simple code like this really needs an array. Well, *THEORETICALLY* you could have an array containing numbers 1 through 10, for multiplying them by "y". It's called a pattern. But you would still need a for loop to do the same task. So that's why it is NOT needed. I sure you later you WILL find good use for array yourself. Good luck!
13th Aug 2019, 7:00 PM
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩 - avatar
+ 7
Good first program. As for arrays, you could maybe store the multiplication tables in arrays and refer items when later requested by the user perhaps? Just to get an idea about arrays.
13th Aug 2019, 2:48 AM
Sonic
Sonic - avatar
+ 4
just giving some tips to improve your programming. avoid unnecessary whitespaces and use them only to keep your codes organized use proper indentations to make a cleaner code (this will be useful if you work on bigger programs but it is recommended to have good coding practices as a habit) i saw lots of coders with extremely messy code, this would only make reading and structuring your own codes much harder and people would have a hard time understanding your codes. here is a cleaner version of the code #include <stdio.h> int main() { int y; scanf("%d",&y); for (int k=0;k<11;k++) printf("%d * %d= %d \n", y, k, y*k); return 0; }
13th Aug 2019, 7:15 AM
Shen Bapiro
Shen Bapiro - avatar
+ 1
thank you so much guys, I really appreciate your tips🙏
13th Aug 2019, 8:11 AM
Samuele
Samuele - avatar
+ 1
you're right Vitya, this code is too simple and an array is not requiredđŸ‘đŸ» The idea you mentioned is a good one though (as you said, theoretically). Thank you so much btw. I hope I can get half as good as you.. one dayđŸ™đŸ»
13th Aug 2019, 7:18 PM
Samuele
Samuele - avatar
+ 1
Arrays can be used in Matrix calculations in Electrical Engineering And statistical analysis.
16th Aug 2019, 2:44 PM
Lloyd L Conley
Lloyd L Conley - avatar