I am learning C and just for practice I am trying to create a table.
1) Must scanf always be right after a printf to work?
2) Instead of &MyArray[x][y],&MyArray[x][y+1], &MyArray[x][y+2] I wish to use a loop so that my values are saved into the correct columns which are from 0 to N. Can that be done?
#include <stdio.h>
#define N 3
main()
{
int MyArray[N][N];
int x=0,y=0;
for (x=0; x<N; x++)
{printf("Enter %d numbers for row %d: ", N, x);
scanf("%d %d %d", &MyArray[x][y],&MyArray[x][y+1], &MyArray[x][y+2] );}
1) Must scanf always be right after a printf to work?
2) Instead of &MyArray[x][y],&MyArray[x][y+1], &MyArray[x][y+2] I wish to use a loop so that my values are saved into the correct columns which are from 0 to N. Can that be done?
#include <stdio.h>
#define N 3
main()
{
int MyArray[N][N];
int x=0,y=0;
for (x=0; x<N; x++)
{printf("Enter %d numbers for row %d: ", N, x);
scanf("%d %d %d", &MyArray[x][y],&MyArray[x][y+1], &MyArray[x][y+2] );}