Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int I,J,a=7,b; for(I=1;I<=9;I=I+2) { for(b=1,J=a;b<=3;J--,b++) printf("I=%d J=%d\n", I, J); a=a+2; } return 0; }
#include
ReplyDeleteint main(int argc, char const *argv[])
{
int i, j, k = 0;
for (i = 1; i <= 9; i += 2, k += 2)
{
for (j = 7 + k; j >= 5 + k; j--)
{
printf("I=%d J=%d\n", i, j);
}
}
return 0;
}
I think this is easier to understand
#include
ReplyDeleteint main()
{
int I=1,J=7;
while(I!=11)
{
printf("I=%d J=%d\n",I,J);
J=J-1;
printf("I=%d J=%d\n",I,J);
J=J-1;
printf("I=%d J=%d\n",I,J);
I=I+2;
J=J+4;
}
}