Izzy A.
asked 07/13/15Programming with C
Write a program that print symbol ‘X’ based on input value in the range of 1 to 5. If user enter out of range, the program will keep loop until the right value is enter.
Example:
User input 7
The program will ask for right range of value
User input 3
Output
X X X
Example:
User input 7
The program will ask for right range of value
User input 3
Output
X X X
More
1 Expert Answer
Bivas B. answered 07/22/15
Tutor
5.0
(256)
100% helpful and committed tutor working for your success.
Hi Izzy, writing the program yourself would be better for you than me giving you the solution. So, I'll give you a hint. Use a do-while loop for the range checking. use a for loop for printing the X
Hope that helps
Bivas
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Mahnoor W.
#include<conio.h>
int main()
{
int n;
do{ printf("\nenter numbers ranges from 1 to 5\n");
scanf("%d",&n);
switch(n)
{ case 1:
printf("x");
break;
case 2:
printf("xx");
break;
case 3:
printf("xxx");
break;
case 4:
printf("xxxx");
break;
case 5:
printf("xxxxx");
break;
default:
printf("\ninvalid number.. press y to continue");
}}
while(getche()=='y');
getche();
}
10/04/15