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...
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?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
its so hard..can u help me??
Well, start by writing nested loops to print a 5 by 5 matrix of 0s.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)