-4
the program must display the following result:
Type a random number between 2 and 20:
7
Exit from the program:
1234567
x123456
xx12345
xxx1235
xxxx123
xxxxx12
xxxxxx1
(NOTE: the value typed by the user has to be between 2 and 20, 7 was typed as an example of what is requested)
#include <stdio.h>
#include <stdlib.h>
void main()
{
int n, c;
printf("digite um número entre 2 e 20: ");
scanf("%d", &n);
for (size_t i = 1; i <= n; i++)
{
//c++;
for (c = 0; c <=n; c++)
printf("x");
printf("%d \n", i);
}
printf("\n");
}
Please clarify your problem or provide additional details in order to highlight exactly what you need. The way it’s written these days it’s hard to tell exactly what you’re asking.
–
If the entrance can be
1234567
, why do you have a message that the number should be between 2 and 20?– hkotsubo
Sorry for the lack of information, this program should receive 1 value of no more than 2 to 20. The value that the user enter a number between 2 and 20. has to be in that range. And then the program must display the predecessor numbers of the number typed up to the number typed. and these values shall be printed as the above example
– Victor Luiz
the numbers 1 - 7 are an example of what should happen if the user type 7. The same thing has to happen if the user type 8, or 12 for example
– Victor Luiz
Simplifying the program should display these output: ----- Type a number: 7--------- Program output: 1234567 x123456 xx12345 xxx1235 xxxx123 xxxxx12 xxxxxx1
– Victor Luiz
this helps @hkotsubo ?
– Victor Luiz
and @Gean Santos ?
– Victor Luiz
I suggest [Edit] the question and put that information there. It is better because in the body of the question you can format, besides having more space for you to elaborate better
– hkotsubo
https://ideone.com/vMrnYy
– hkotsubo
Vlw @hkotsubo vc is a genius
– Victor Luiz
I thank everyone who helped, people you are of wonderful
– Victor Luiz