+ 5
First program.. easy for all of you, but I'm proud of it.. Any suggestions for using arrays?
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!
+ 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.
+ 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;
}
+ 1
thank you so much guys, I really appreciate your tipsđ
+ 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đđ»
+ 1
Arrays can be used in Matrix calculations in Electrical Engineering And statistical analysis.