Answer:
// program in C++.
// headers
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// Variable
int num;
cout << "Enter a number between 1 and 10: ";
// read input
cin >> num;
// validate input number
while(num<1||num>10)
{
// if input is wrong then print error message
cout<<"Wrong input!!Enter again:";
// read again
cin>>num;
}
// print output
cout << "The Roman numeral for "<<num<<" is:";
// switch
switch (num)
{
case 1:
// if input is 1
cout<<"I"<<endl;
// exit the switch
break;
case 2:
// if input is 2
cout<<"II"<<endl;
// exit the switch
break;
case 3:
// if input is 3
cout<<"III"<<endl;
// exit the switch
break;
case 4:
// if input is 4
cout<<"IV"<<endl;
// exit the switch
break;
case 5:
// if input is 5
cout<<"V"<<endl;
// exit the switch
break;
case 6:
// if input is 6
cout<<"VI"<<endl;
// exit the switch
break;
case 7:
// if input is 7
cout<<"VII"<<endl;
// exit the switch
break;
case 8:
// if input is 8
cout<<"VIII"<<endl;
// exit the switch
break;
case 9:
// if input is 9
cout<<"IX"<<endl;
// exit the switch
break;
case 10:
// if input is 10
cout<<"X"<<endl;
// exit the switch
break;
// default
default:
break;
}
return 0;
}
Explanation:
Read a number from usr and assign it to variable "num". If the input number is less than 1 or greater than 10 then ask again to enter a number until user enter a number between 1-10 only.Then with the help of switch() function print the equivalent Roman number.
Output:
Enter a number between 1 and 10: -5
Wrong input!!Enter again:12
Wrong input!!Enter again:6
The Roman numeral for 6 is:VI
Answer:
Explanation:
The following code is written in Python and it is a very simple function/program that takes in an array of strings as a parameter called names. This array is then passed the built-in sort function which automatically sorts it in ascending alphabetical order. Finally, the print method is called on the names array to print all of its elements out.
def sort_strings(names):
names.sort()
print(names)
Answer:
The program in Python is as follows:
word = input("Word: ")
if len(word) < 5:
print("At least 5 characters")
else:
pal = word[0:5]
word = word[0:4]
word = word[::-1]
pal+=word
print(pal)
Explanation:
This gets the word from the user
word = input("Word: ")
This checks if the length of the word is less than 5.
if len(word) < 5:
If yes, this tells the user that at least 5 characters is needed
print("At least 5 characters")
If otherwise
else:
This extracts the first 5 characters of the word into variable named pal
pal = word[0:5]
This extracts the first 5 characters of the word into variable named word
word = word[0:4]
This reverses variable word
word = word[::-1]
This concatenates pal and word
pal+=word
This prints the generated palindrome
print(pal)
Answer:
c)both a and b
Explanation:
If the tires are under inflated the the rolling resistance increases due to more surface are of tire now touches the ground hence there is more friction.Since the rolling resistance increases the tire will face difficulty in turning hence the steering the tires will become more hard.Since rolling resistance is increased so the engine has to work more to run the car hence it will consume more fuel.
Answer:
Refrigerant leaks detected at compressor crank
Explanation: