Write a C++ Program
In C++, struct is a reserved word. Define 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.
You must insert the following comments at the beginning of your program and write our commands in the middle:
Write a C++ Program:
/*
// Name: Your Name
// ID: Your ID
*/
#include <iostream>
#include <string>
using namespace std;
struct fruitType
{
…
…
YOUR CODE HERE
…
…
}
int main()
{
fruitType fruit;
…
…
YOUR CODE HERE
…
…
return 0;
}
Here is code:
#include <iostream>
using namespace std;
struct fruitType
{
string name;
};
void displayArray(fruitType f[], int count)
{
// display the data entered
for (int i = 0; i < count; i++)
{
cout << "name : " << f[i].name << endl;
}
}
int main()
{
int size = 5; // size of struct
struct fruitType f[size];
// loop and read the fruit names
for (int i = 0; i < size; i++)
{
cout << "Enter fruit name : ";
cin >> f[i].name;
}
// display the data entered
displayArray(f, size);
return 0;
}
Output:

Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write...
Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE
Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() { char ch; … … ...
Program in C Language : Define a struct computerType to store the following data about a computer: Manufacturer (50 character string), model type (50 character string), processor type (10 character string), ram (int) in GB, hard drive size (int) in GB, year when the computer was built (int), and the price (double). Write a program that declares a variable of type computerType, prompts the user to the input data for the struct, and then outputs all the computer's data from...
Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...
Find the problems with this program #include <iostream> using namespace std; struct Student { string name; int grade; } int main() { struct Student mary; Mary:name = "Mary"; Mary:grade = 100; cout << mary:name " got a " << mary:grade << endl; return 0; }
#include <iostream> #include<string> #include<vector> using namespace std; struct patient { string name; char Gender; int d,m,y; string nationality; int civilID; int phoneNumber; string TypeOfInsurance; }; Activities I. Declare a variable from the struct Patient called pat. II. Fill out the information of pat by reading them from the input. III. Declare a pointer of type Patient called pat_ptr and assign the address of pat to it. IV. Change the value of name field of pat by accessing it through pat_ptr....
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...
C++ // This program prints the proverb // "Now is the time for all good men to come to the aid of their party" // in a function (procedure) called writeProverb that is called by the main function // PLACE YOUR NAME HERE #include <iostream> using namespace std; void writeProverb(); // This is the prototype for the writeProverb function int main() { // Fill in the code to call the writeProverb function return 0; } //********************************************************************* // writeProverb // //...
/* I'm trying to write this program here but my problem is getting the program to save the user input to "int data" but cannot because it is part of the struct. What do I have to do in order to get this to work? (Language is C++) Write a program that prompts the user to enter numbers on the screen and keep adding those numbers to a linked list. The program stops when user enters -999. Hint: Use a...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...