0% found this document useful (0 votes)
30 views2 pages

cs101 Ass 02

This document contains information about an assignment for an introduction to computer science course. It includes the semester, course name and code, and assignment number. The code defines a structure called "Car" with fields for name, model, vendor, horsepower, price, and owner ID. It then declares a variable of this type, takes user input to populate the fields, and displays the stored vehicle information.

Uploaded by

Umar Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

cs101 Ass 02

This document contains information about an assignment for an introduction to computer science course. It includes the semester, course name and code, and assignment number. The code defines a structure called "Car" with fields for name, model, vendor, horsepower, price, and owner ID. It then declares a variable of this type, takes user input to populate the fields, and displays the stored vehicle information.

Uploaded by

Umar Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SEMESTER SPRING 2022

ASSIGNMENT-02
CS101( Introduction to Computer )
NAME: Umar Farooq VU ID: bc220204062

Code Solution:

#include <iostream>
#include <string>
using namespace std;

int main() //main function


{
struct Car //defining structure Car
{
string car_name;
int car_model;
string car_vendor;
int car_horse_power;
int car_price;
string car_owner_ID;
};

Car Car1; //declaring variable Car1 of Car data type

cout << "Enter Car Name: "; //Taking inputs from the user
cin >> Car1.car_name;
cout << "Enter Car Model: ";
cin >> Car1.car_model;
cout << "Enter Car Vendor: ";
cin >> Car1.car_vendor;
cout << "Enter Car Horse Power: ";
cin >> Car1.car_horse_power;
cout << "Enter Car Price: ";
cin >> Car1.car_price;
cout << "Enter Car Owner-ID: ";
cin >> Car1.car_owner_ID;
cout << "Values are stored in Car1 variable." << endl << endl << endl;

cout << "The stored vehicle information is:" << endl; //Showing output
on the screen
cout << "Name:\t\t" << Car1.car_name << endl;
cout << "Model:\t\t" << Car1.car_model << endl;
cout << "Vendor:\t\t" << Car1.car_vendor << endl;
cout << "Horse Power:\t" << Car1.car_horse_power << endl;
cout << "Price:\t\t" << Car1.car_price << endl;
cout << "Owner-ID:\t" << Car1.car_owner_ID << endl << endl;

return 0;
}

Output Screenshot

You might also like