Question

What is the output from the following code? struct   StudentType{ long id; string name; int age;...

What is the output from the following code?

struct   StudentType{
long id;
string name;
int age;
}
StudentType stud1;
stud1.id = 12345;
stud1.name = “Josh”;
stud1.age =20;
StudentType* ptr = & stud1;
ptr->age++;
ptr->name = “John”;
cout<<stud1.name<<” “ <<stud1.age;

Homework Answers

Answer #1

Initially the code generates few errors:

  • The semicolon at the end of the structure is missing.
  • The double quotes for the strings should be properly managed.

After removing the errors and succesfully running the above code:

Output:

John 21

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
what is the output from the following code? int number=10; int* ptr = &number; number+=10; cout<<*ptr;
what is the output from the following code? int number=10; int* ptr = &number; number+=10; cout<<*ptr;
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
How to stop the program from exiting after display detail. When there is food detail, it...
How to stop the program from exiting after display detail. When there is food detail, it will display and exit the program. What can i do to make it not exit the program and back to main menu. #include <iostream> #include <iomanip> #include<string.h> using namespace std; struct food{ int order_id; string food_code,flavor,customer_id; string address,name; int weight,unit_price,qty,contact_number; struct food *next; };    class Foodsystem{ food *head,*temp,*temp2,*end; static int id;    public: Foodsystem(){ head=NULL;end=NULL;} void Place_Order(); void View_food_details(); void Modify_food_details(); void Delete_food_details();...
Briefly explain what is wrong (exactly 1 error) with the following code. int num_cmb = rand()...
Briefly explain what is wrong (exactly 1 error) with the following code. int num_cmb = rand() % 6; // # of combinations int num_pmt = ( num_cmb + 1 ) % 10; // # of permutations cout << num_num_cmb; cout << num_num_pmt; double num_arng, num_drng; // # of arrangements, derangements num_arng = 2.0 / ( 1 + num_cmb - ( 1 + num_cmb ) ); num_drng = 1.5 * num_pmt; cout << num_arng; cout << num_drng;  
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you 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. You must...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the 2 in 2 for $1.99. private double groupPrice; //Part of price, like the $1.99 in 2 for $1.99. private int numberBought; //Total number being purchased. public Purchase () { name = "no name"; groupCount = 0; groupPrice = 0; numberBought = 0; } public Purchase (String name, int groupCount, double groupPrice, int numberBought) { this.name = name; this.groupCount = groupCount; this.groupPrice = groupPrice; this.numberBought...
What is the output? from collections import namedtuple Student = namedtuple('Student' , ['name','age','rollNo']) student1 = Student('Hayden'...
What is the output? from collections import namedtuple Student = namedtuple('Student' , ['name','age','rollNo']) student1 = Student('Hayden' , 26, 6) print print ("Name:", student1.name) print print ("Age:", student1.age) print print ("Roll Number:", student1.rollNo) print Group of answer choices Name: Hayden Age: 26 Roll Number: 6 Hayden 26 6 6 Hayden 26 Age: 6 Roll Number: Hayden Name: 26