Izzy A.

asked • 07/13/15

Programming 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

Mahnoor W.

#include<stdio.h>
#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();
}
 
Report

10/04/15

1 Expert Answer

By:

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.