Hello. I am new to this forum as well as an amateur in programming. My lecturer gave me homework where the user should enter the height of the square they want to see. for example:
Height: 4
output
4 8 12 16
8 12 16 4
12 16 8 4
16 12 8 4
this is what I've done so far, i know how to get the 1st row but I don't know how to swap the number for the next rows
Code:
#include <stdio.h>
int main ()
{
int height,row,height1,num,num1;
printf ("=================\n");
printf ("You pick square!\n");
printf ("Enter height you wish to see:\n");
scanf ("%d",&height);
num=height;
num1=height;
for (row=1;row<=height;row++)
{
for (height1=1;height1<=height;height1++)
{
printf ("%d ",num1);
num1=num1+num;
}
num=num+num;
printf ("\n");
}
return 0;
}
I've only cover 5 chapter so far which is sequence,loop,and function.I manage to do the other 3 shape our lecturer give us because the pattern is quite easy,but this,I just can't figure it out
I hope someone can help me and comment on this thank you!