#include <stdio.h>
#include <cs50.h>
int main(void)
{
int n;
do
{
n = get_int("height: ");
}
while(n<1&&n>8);
for (int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
printf("#");
}
printf("\n");
}
}
im writing a program to print a square with hashes,but my while in the Do loop wont work.
i want it to accept values only between 1 and 8 inclusive,but it wont work and wouldnt prompt again if i enter values out of the parameter.but it works if I only put a single parameter in the while loop e.g. n<1
.
please help me,im a beginner.
The answer is very easy and it is not related to the programming only simple math and logic
while(n<1&&n>8)
If
n
is lower than1
it cannot be larger than8
at the same time.