Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10. Sample Run Enter a number (1 - 10): 7↵ The Roman numeral version of 7 us VII.↵

Respuesta :

Answer:

Below are the program for the above question:

Explanation:

#include <stdio.h>//header file.

int main()//main function.

{

   int value; //variable declaration.

   printf("Enter a number to find its roman value: ");//render a message for the user.

   scanf("%d",&value); //take a value from the user.

   switch(value)//switch case starts

   {

     case 1:

     printf("I");

     break;

     case 2:

     printf("II");

     break;

     case 3:

     printf("III");

     break;

     case 4:

     printf("IV");

     break;

     case 5:

     printf("V");

     break;

     case 6:

     printf("VI");

     break;

     case 7:

     printf("VII");

     break;

     case 8:

     printf("VIII");

     break;

     case 9:

     printf("IX");

     break;

     case 10:

     printf("X");

     break;

   }//switch case ends.

   return 0;//return statement.

}

Output:

  • If the user inputs as 4, then the output is "IV".

Code Explantion :

  • The above code is in c language, in which the scanf function is used to take the inputs from the user.
  • Then the value match from the switch case and display the suitable result.
  • And the user get the roman value from the user.

ACCESS MORE