Like a good programmer I guess I’m trying to be lazy and make the program make anything but I’m starting to think this can’t be done this way so here it goes…
I have 27 variables a1,a2,a3,a4,a5,a6,a7,a8,a9,b1,b2,b3,etc,c1,c2,c3,etc…
I want the user to give me the numbers for each but I don’t want to do it manually I want to do it with a for something like this:
for(i=0;i<=0;i++)
{
char a= 'a'+i;
char b= 'b'+i;
char c= 'c'+i;
printf("give me 1st number in square\n");
scanf("%d",a);
printf("give me 2nd number in square\n");
scanf("%d",b);
printf("give me 3rd number in square\n");
scanf("%d",c);
}
Any idea how to make this? if there’s a way I would really appreciate you can tell me thank you very much XD
Yeah also if you can’t understand or want me to explain better tell me and I will try my best to remake this.
This is what arrays are for. Instead of having variables like
a1,a2,a3,b1,b2,b3, etc., just have two arrays:Then you can access the variables with expressions like
a[i], whereiis any integer (provided you don’t try to access outside the array bounds, of course).