0

Write a program ..

I wanna make a program that will print the following by using loop 0111 1011 1101 1110

23rd Apr 2018, 7:14 AM
Abdulla Nasri
Abdulla Nasri - avatar
11 Réponses
+ 2
hint: The zeros are at the locations where x is equal to y.
23rd Apr 2018, 8:00 AM
Alex
Alex - avatar
+ 2
Have you tried anything yet? I can help you with it if you show some effort.
23rd Apr 2018, 8:13 AM
Alex
Alex - avatar
+ 2
You need loops. Use 2 nested for loops. for (int y=0; y<4; y++) { for (int x=0; x<4; x++) { //do something } }
23rd Apr 2018, 8:44 AM
Alex
Alex - avatar
+ 2
Trust me: you'll learn more from it if you try -> fail -> get corrected. Won't make much sense to just give you the answer.
23rd Apr 2018, 9:04 AM
Alex
Alex - avatar
+ 2
And today they told you that you have a test tomorrow? I guess not... Programming can't be learned in 1 day. It seems like you don't even know the difference between a comparison and an assignment operator. Here is the solution: for (int y=0; y<4; y++) { for (int x=0; x<4; x++) { if (x==y) cout << 0; else cout << 1; } cout << endl; } I don't care if you fail your test. As hard as this may sound to you...
23rd Apr 2018, 10:54 AM
Alex
Alex - avatar
+ 1
thank you, I promise you I will learn hard
23rd Apr 2018, 12:15 PM
Abdulla Nasri
Abdulla Nasri - avatar
0
but how!!
23rd Apr 2018, 8:05 AM
Abdulla Nasri
Abdulla Nasri - avatar
0
I can not start with no idea I want the first step
23rd Apr 2018, 8:37 AM
Abdulla Nasri
Abdulla Nasri - avatar
0
I will be greatful for you if you help me in writing all the program 😊
23rd Apr 2018, 9:00 AM
Abdulla Nasri
Abdulla Nasri - avatar
0
I will take your advice but tomorrow I have a test
23rd Apr 2018, 9:15 AM
Abdulla Nasri
Abdulla Nasri - avatar
0
#include <iostream> using namespace std; void main(){ int x, y ; for (x=y=1 ; x<=4 && y<=4 ; x++,y++ ) { if (x=y=1) cout <<x-y; else cout<<x/y; } return 0; }
23rd Apr 2018, 10:30 AM
Abdulla Nasri
Abdulla Nasri - avatar