Assume the definition of Exercise 4, which defines the struct fruitType. Write a program that declares a variable of type fruitType, prompts the user to input data about a fruit, and outputs the fruit data.
#include <iostream> #include <string> using namespace std; struct fruitType { string type; string color; }; int main() { fruitType fruit; cout << "Enter type of fruit: "; cin >> fruit.type; cout << "Enter color of fruit: "; cin >> fruit.color; cout << "Type of the fruit is " << fruit.type << " and the color of the fruit is " << fruit.color << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.