Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to print this in c
00 00 00 00
00 11 00 00
00 00 22 00
00 00 00 33

What I have tried:

i tried nested loop but its not working.
Posted
Updated 22-Apr-20 6:30am
Comments
Patrice T 22-Apr-20 10:00am    
Show your work !

With four print statements. Alternatively you could write a loop that does it the easy way. Look at the data you want to print and think what patterns you can see. That should help you.
 
Share this answer
 
Set up two for loops, one inside the other - the inner one is called a "nested loop" - the outer loop runs y from 0 to 3 inclusive, the inner loop runs x from 0 to 3 inclusive.
In the inner loop, compare x and y
If they are different, print "00"
If they are the same, print them both.
Regardless, print a space
After the inner loop, print a newline.

Try it: it's pretty simple - but this is your homework, so I'll give you no code!
 
Share this answer
 
Quote:
i tried nested loop but its not working.

Show your code and we will help you to fix it.

You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

If you think I am rude to you, remember that you were first to be rude by requesting us to do your homework.
Even the analyze of Solution is part of your homework, you also have to learn do conduct such analyze, it is the job of programmer.
As I said training, practice, trial and error that is how you will learn.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900