Help!! How to print this using loop & condition starements...
0 1 1 1 1
-1 0 1 1 1
-1 -1 0 1 1
-1 -1 -1 0 1
-1 -1 -1 -1 0
help pls..asap...
This is a discussion on Help!! How to print this using loop & condition starements... within the C Programming forums, part of the General Programming Boards category; Help!! How to print this using loop & condition starements... 0 1 1 1 1 -1 0 1 1 1 ...
Help!! How to print this using loop & condition starements...
0 1 1 1 1
-1 0 1 1 1
-1 -1 0 1 1
-1 -1 -1 0 1
-1 -1 -1 -1 0
help pls..asap...
What have you tried?
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
its so hard..can u help me??
Well, start by writing nested loops to print a 5 by 5 matrix of 0s.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
then??Code:#include <stdio.h> main() { int i, j; for(i = 1; i <= 5; i++) { for(j = 1; j <= 5; j++) printf("%c", '*'); printf("\n"); } }
Right. Now in the body of the inner loop, compare i and j, and based on your comparison (less than, equal to, greater than) print (1, 0, -1).
By the way, you should define main as returning int, and indent your code a little better.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way