Answer:
1st question:
Use the variables k, d, and s so that they can read three different values from standard input an integer, a float, and a string respectively. On one line, print these variables in reverse order with exactly one space in between each. On a second line, print them in the original order with one space in between them.
Solution:
In Python:
k = input() #prompts user to input value of k i.e. integer value
d = input() #prompts user to input value of d i.e. float value
s = input() #prompts user to input value of s i.e. a string
print (s, d, k) #displays these variable values in reverse order
print (k, d, s)#displays these variable values in original order
In C++:
#include <iostream> // to use input output functions
using namespace std; //to identify objects like cin cout
int main() { //start of main function
int k; //declare int type variable to store an integer value
float d; // declare float type variable to store a float value
string s; // declare string type variable to store an integer value
cin >> k >> d >> s; //reads the value of k, d and s
cout << s << " " << d << " " << k << endl; //displays these variables values in reverse order
cout << k << " " << d << " " << s << endl; } // displays these variable values in original order
Explanation:
2nd question:
You would like the user of a program to enter a customer’s last name. Write a statement that asks user "Last Name:" and assigns input to a string variable called last_name.
Solution:
In Python:
last_name = input("Last Name:")
# input function is used to accept input from user and assign the input value to last_name variable
In C++:
string last_name; //declares a string type variable named last_name
cout<<"Last Name: "; // prompts user to enter last name by displaying this message Last Name:
cin>>last_name; // reads and assigns the input value to string variable last_name
The programs alongwith their outputs are attached.