Identify and fix the errors in the following code:
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Introduction to Programming with C++
- USE C++ programming language 1) State whether the following declarations are valid or invalid. Give reasons for the invalid declarations and draw memory layout for the valid declarations i)int *ptr = &var;int var = 25; ii)double* dptr1, dptr2;double dvar = 25.2;dptr1 = &dvar;dptr2 = &dvar;arrow_forwardIn c++ only Please create a class multiplication with three overloaded functions to multiply two or three integers or two double literels. Please provide output and code screenshotarrow_forwardI'm working on c++ and I've been given the following instructions to modify a program: Rewrite Program 3 where the following operators are overloaded: >> << + - * == != Also overload the preincrement and postincrement operators ++ which will change the value of the complex number to its cube. I really only need help understanding the last two operators and the pre/postincrement. Here is the program I already have: #include <iostream>using namespace std; //This program uses a class to work with complex numbers // create complex number classclass ComplexNum{ //private variablesprivate: float realNum; float imaginaryNum; //public sectionpublic: //default constructor ComplexNum(float r = 0, float i = 0) :realNum(r), imaginaryNum(i) {}; //sets the complex numbers void setComplex(void) { cout << "Enter the real part: "; cin >> this->realNum; cout << "Enter the imaginary part: "; cin >>…arrow_forward
- C++ Please! Also please don't use functions, arrays, or classes. Just basic c++ please. Password Verifier Write a C++ program to verify that a user’s password meets the following criteria: 1. The password should be at least 6 characters long. 2. The password should contain at least one uppercase and one lowercase letter. 3. The password should have at least one digit. Your program should ask the user for a password and verify that it meets the following criteria. If it doesn’t a message should be displayed telling the user why.arrow_forward*Correct all syntax errors so that the C++ program will compile correctly.* Procided C++ code: #include<iostream>#include<conio.h> Standard namespace declarationusing namespace std; Main Functionint main(){ double myMoney = 1000.50; //this should be printed out Standard Ouput Statement cout"Please be sure to correct all syntax errors in this program"<<endl; cout<<"I have corrected all errors for this program. <<endl; cout<<" The total amount of money available is = "<< <<endl; // Wait For Output Screen Main Function return Statement return 0;} Thank you for your helparrow_forwardPlease do the following and show execution code and output! Write two Haskell functions to calculate ticket prices. Tickets for those ages 12 and under are $8.50, tickets for those between 13 and 65 are $14.50 and those older than 65 are $9.00. The second function should calculate tax – assume tax is 12%. Using function chaining to calculate the total cost. The main function should ask what type of ticket the person wants (child, adult, or senior) and call the functions that you wrote. Show the type signatures of the functions you write.arrow_forward
- Write two Haskell functions to calculate ticket prices. Tickets for those ages 12 and under are $8.50, tickets for those between 13 and 65 are $14.50 and those older than 65 are $9.00. The second function should calculate tax – assume tax is 12%. Using function chaining to calculate the total cost. The main function should ask what type of ticket the person wants (child, adult, or senior) and call the functions that you wrote. Show the type signatures of the functions you write.arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. 13.Complete the following code: #include <iostream>using namespace std;int main(){int a = 10;int b = 20;// Write code here to swap the values currently assigned to variables a and b. cout << “The values of a and b have been swapped.” << endl;}arrow_forwardCOMPUTER PROGRAMMING AND APPLICATIONS PROJECT REQUIREMENTS pls write program C++ , you must fulfil the following requirements: • Appropriate comments (write explanations for important statements) • Appropriate indentations (to make your program readable) • Appropriate variables’ declarations • Input / Output (cin, cout) • Calculation (involve at least three calculations) • I/O Manipulators (e.g.: setw() or setfill() or setprecision() or etc.) • Pre-defined Functions (e.g.: getline(), or gcount(), or ignore() or pow(x,y), or etc.) • User-defined Functions (call by value or call by reference) • Control Structure (e.g.: if-else, nested if) • Loops (e.g.: for, while, do..while, nested loops) • Arrayarrow_forward
- Define the function: int power (int base, int exp) {/*It accepts the arguments for base and exponent and returns power. The algorithm is to repeatedly multiply the value of the base to how many times the value of exponent. Test the function inside main(). Write the complete C program. */} For example: Intput. Result 2 32 5arrow_forwardT/F 2. In Java, only if and if-else expressions are used in selection statements.arrow_forwardWrite a c++ program to display a calendar for a given year. Type of Branches such as switch statements, if-else, and etc. should be used as well. You can't define functions or use Void. Everything should be written inside int main(). Code should be written in this type of format: #include <iostream>using namespace std; int main() { /* Type your code here. */ return 0;} Ask a user to enter the year and the new year's day of the year entered: cout <<"Enter a calendar year to display?"; cout <<" what is the new year's day?"; a leap year is: IF year%4 = 0 AND year%100 != 0 OR year%400 = 0 An example of what the program should display as a result is in the two images attached.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr