Concept explainers
Explanation of Solution
Output of the Given Program:
//Include the required header files
#include <iostream>
#include <iomanip>
using namespace std;
//Main Function
int main()
{
//Declare the required variables
int unus, duo, tres;
//Initialize the variables
unus = duo = tres = 5;
//Add 4 to 5 and store it in a variable
unus += 4;
//Multiply 2 to 5 and store it in a variable
duo *= 2;
//Subtract 4 from 5 and store it in a variable
tres -= 4;
//Divide unus value by 3 and store it in a variable
unus /= 3;
//Add duo value to tres and store it in a variable
duo += tres;
//Print the value
cout << unus << endl;
//Print the value
cout << duo << endl;
//Print the value
cout << tres << endl;
//Return the statement
return 0;
}
Explanation:
- Include the required header files
- Give the “main ()” function
- Declare the variables “unus”, “duo”, and “tres”.
- Initialize those variables to 5...
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
- C++ #include <iostream>using namespace std; //creating struct to hold //student name,age and letter gradestruct student{ //data members string name; int age; char grade;};int main(){ //declaring object for the struct student *k = new student; //filling it with data k->name = "Kate"; k->age=24; k->grade='B'; ///then printing student data cout<<"Name:"<<k->name<<endl; cout<<"Age:"<<k->age<<endl; cout<<"Grade:"<<k->grade<<endl; return 0;}arrow_forwardY3arrow_forwardFill in the blanksarrow_forward
- LOVELY PROFESSIONAL UNIVERSITY Academic Task No. 1 School : of Computer Science and Engineering Name of the faculty member_Ms. Gauri Mathur_ Course Code: CSE202 Faculty of: Technology and Sciences Course Title: Object Oriented Programming Program: Max. Marks: 30 Term: Is Rubric Applicable: No Date of Allotment: 26/02/2021 Date of Submission: 09/03/2021 Important Guidelines: 1. All questions in this Academic Task are compulsory. 2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except hand written/drawn will not be accepted/considered as valid submission(s) under any circumstances. 3. Every attempted sheet/page should carry clear details of student such as Name, Registration number, Roll number, Question number and Page number. The page numbers should be written clearly on the bottom of every attempted sheet in a prescribed format as: for…arrow_forward#include<bits/stdc++.h>using namespace std; // Class representing music dataclass Song {public:string musicName, musicDescription;};// Function to take input for music descriptionSong addDescription(){Song s1;cout<<"Enter the Music name : ";cin>>s1.musicName;cout<<"Enter the Music description : ";cin>>s1.musicDescription;return s1;} // Function to write music object details into a txt filevoid storeInfoToDatabase(Song s){ofstream fileObject;// Opening the file in append modefileObject.open("Database.txt", ios::app);fileObject << s.musicName;fileObject << " ";fileObject << s.musicDescription;fileObject << "\n";} // Driver Functionint main(){Song s = addDescription();storeInfoToDatabase(s);cout<<"Data written into file succesfully...";return 0;}arrow_forwardNonearrow_forward
- #include using namespace std3; int main() { int s-4; int d-s++; cout<arrow_forwardQ No 3. #include <string> using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if (initialBalance > 0) { balance = initialBalance; } } void deposit(int depositAmount) { if (depositAmount > 0) { balance = balance + depositAmount; } } int getBalance() const { return balance; } void setName(string accountName) { name = accountName; } string getName() const { return name; } private: string name; int balance; }; Rewrite the following code in correct form. a) Assume the following prototype of destructor is declared in class Time: void ~Time(int); b) Assume the following prototype of constructor is declared in class Employee: int Employee(string, string);…arrow_forward#include <iostream>#include <string>#include <iomanip>using namespace std;// structurestruct Hat{string brand;string color;float price;};// Customer structurestruct Customer{string fullName ;int age ;Hat hat; // Hat structure (nested in Customer)};int main(){// declare 5 variables of CustomerCustomer customer_1,customer_2,customer_3,customer_4,customer_5;cout<<"Welcome to Hats For U!\n";cout<<"Customer 1\n";cout<<"Enter customer's Full Name: ";getline(cin,customer_1.fullName);cout<<"Enter customer's age: ";cin>>customer_1.age;cout<<"Enter the brand of hat: ";cin>>customer_1.hat.brand;cout<<"Enter the hat color: ";cin>>customer_1.hat.color;cout<<"Enter the hat price(RM): ";cin>>customer_1.hat.price; cout<<"Hat 2\n";cout<<"Enter customer's Full Name: ";getline(cin,customer_2.fullName);getline(cin,customer_2.fullName);cout<<"Enter customer's age:…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education