0
Write a program ..
I wanna make a program that will print the following by using loop 0111 1011 1101 1110
11 ответов
+ 2
hint: The zeros are at the locations where x is equal to y.
+ 2
Have you tried anything yet? I can help you with it if you show some effort.
+ 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
}
}
+ 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.
+ 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...
+ 1
thank you, I promise you I will learn hard
0
but how!!
0
I can not start with no idea I want the first step
0
I will be greatful for you if you help me in writing all the program 😊
0
I will take your advice but tomorrow I have a test
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;
}