Q1. Consider the following C++ program which has some syntax mistakes. 1 #include 2 using namespace std 4 const int NUM1 = 5, NUM2; 6 int main () 7 { 8 int a; b; c; 9. char grade; 10 cout << "Enter two integers: "; cin << a << b; 11 12 13 14 cout « endl « "The numbers you entered are <« a « " and " << b << endl; 16 NUM = 10; c * 2 = NUM1 + NUM2 * b - a; 17 18 %3D 19 cout <« "c = " « c < endl; 20 21 = A; grade cout <« "Your grade is " « 'grade' << endl; 22 23 24 return 0; 25 } Identify and explain all the syntax errors. Then correct them. * Please provide line numbers in your answer. H H H1 2 222 2
Q: Please use C++ Programming Write a program in "C" that accepts a string (maximum length 25 char)…
A: Algorithm: Start Read a string Using transform() convert the string to lower case and print the…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: Code: #include <stdio.h>int main(){ //declaring required variables int n,i;…
Q: Identify and correct which statement (s) in the following C++ programs will cause a compiler error?…
A: Question Identify and correct which statement (s) in the following C++ programs will cause a…
Q: 2. 1.Write a program that would collect data from 50 users. The users may enter an integer or real…
A: 2.Create a new data type account that can hold the details of the customer of a bank. Write a C/C++…
Q: Identify and correct which statement (s) in the following C++ programs will cause a compiler error?…
A: Find Your Answer below #include<iostrea>//write iostream#include<iomanip>using namespace…
Q: What will be the output of the following C++ code? #include using namespace std;…
A: Question. What will be the output of the following C++ code? #include <iostream>…
Q: Q /Consider the program below to correct the possible logical errors to produce C program aims to…
A: A list of errors that is previously present was You did not mention the structure name and you…
Q: 3- When the following arithmetic operator supported by C++ language - Assume variable X holds 50 and…
A: Answer: True is the correct answer
Q: Q# 4. write in c programming Write a program that will ask the user to enter Date of Birth (DOB) and…
A: Algorithm: Create a operate that's main operate .Declare 3 variables and store the present day and…
Q: What will be the output of the following C++ code? #include #include using namespace std; int…
A: There are various ways in C++ to concatenate strings. The '+' operator can be used between strings…
Q: 9:00 PM | 9.2KB/s Q: llull 7 O 13% Asynchronous Activity 2_.. Adamson University College of…
A: Code: C++ Programming Language #include <iostream> #include <string> #include…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: required:
Q: Write a C++ statement that assigns the first four characters in a string variable named address to a…
A: Write a C++ statement that assigns the first four characters in a string variable named address to a…
Q: 1 + 2 + 3L Select the correct data type that the above expression evaluates to in C# int long float…
A: C# is the general purpose programming languages. It is used for creating and developing the…
Q: 2. Write C++ declaration statement to accomplish each of the following: Problem C++ Statement…
A: There is the difference between the declaring the variable and initializing the variable When we…
Q: 1. Use a functional decomposition to write a C++ program that asks the user to enter his or her…
A: Below i have given program:
Q: 3. Write a single C++ statement to accomplish each of the following: Compute the sum of three…
A: Write a single C++ statement to accomplish each of the following: a. compute the sum of the three…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: #include <stdio.h> int main() { int num,j=0; printf("\n enter the number"); scanf("%d",…
Q: Asif buys four products detergent, ghee, milk and soap from Punjab Cash & Carry. You have to write a…
A: Declare variables to store quantity and price Calculate discount of each product Print Discount…
Q: Q1. Write a C++ program which initializes the earning of an employee. The program should calculate…
A: NOTE: As per the guidelines, we are allowed to answer only one independent question per post. Kindly…
Q: 2. Use a structure called Time to write a C++ program that asks the user to enter a time value in…
A: STRUCT is a C++ data structure that is created to store together elements of different data types.…
Q: //my first C++ program #include using namespace std; int main() { cout << "Welcome to C++"; return…
A: In the given c++ program, cout is used to print the output on the screen in c++ program.
Q: This program should use a void function to print the integers from 1 to 100 (inclusive) in…
A: The program consists of function declaration and definition. The function declaration tells the…
Q: Find any errors in the following C++ program: #include Using namespace std; Int (main) { cout<<”…
A: We need to find the errors in the given C++ language program. The given C++ program is as follows-…
Q: Q4\A) Use (switch statement) to write a program in C++ to show company structure. If the enter is…
A: Q4) A) Code in c++: #include <iostream> using namespace std; int main() { char oper;…
Q: 3. The C++ statement that displays the values of two float numbers x and y, each in a field length…
A: the function setw is used to set the field width to be used for output operations. It takes…
Q: MAKE SURE IT DISPLAYS THE LARGEST VALUE AND THAT THE RANGE IS INCLUDED AS WELL AS 5 NUMBERS BEING…
A: Here have to determine about c++ code for find largest, smallest average of given number list.
Q: Write a program asks the user to enter a string. It uses the character classification functions to…
A: #include <stdio.h> #include <stdlib.h> int main() { char str[100]; int…
Q: Question 4 4.1 Write the result of the following C++ program. #include #include void main ( )…
A: Let us understand the above flow of program as follows:-q=1sum=0
Q: Computer Science I need to write a program in C that allows the user to play a game of Mystery Word,…
A: The solution to the given problem is below.
Q: What will be the output of the following C++ code? #include #include using namespace std; int…
A: The output will be l Explanation:- In this line char str[] = "Hello World"; the character array are…
Q: What will be the output of the following C++ code? #include using namespace std; enum cat { temp =…
A: Question. What will be the output of the following C++ code? #include <iostream> using…
Q: 3- When the following arithmetic operator supported by C++ language - Assume variable X holds 50 and…
A: True. Variable X holds 50 and variable Y holds 25, then (X%Y) give 0. is true.
Q: 3. Write a C program which will take two real numbers and a character from the keyboard. a. The…
A: #include <stdio.h> int main(){ float num1, num2; char op; printf("Enter operator: ");…
Q: Asif buys four products detergent, ghee, milk and soap from Punjab Cash & Carry. You have to write a…
A: Please find the answer below :
Q: Only Explain How This C++ Program Is working. write a Description/Explanation. Here's The program…
A: GIVEN CODDE #include<iostream>using namespace std; int main(){int…
Q: In C++ please write the code for this problem: A bag of cookies holds 30 cookies. The calorie…
A: According to the information given:- We have to create calories calculator.
Q: Q2: Write a C++ program to compute the value in the "result" variable. For calculation of the result…
A: #include<bits/stdc++.h>using namespace std;int main(){ float a,b,c,r; float result;…
Q: Correct and detailed answer will be Upvoted else downvoted. Thank you! What will be the output of…
A: Question. What will be the output of the following C++ code? #include <iostream>using…
Q: Malcolm Movers charges a base rate of $200 per move plus $150 per hour and $2 per mile. Write a…
A: using System;using System.Collections;using System.Globalization; using static System.Console;…
Q: QUESTION 3 Define the following: i) #include sb Write a C++ program to caleulate user age where the…
A: C ++ is an object-oriented programming (OOP) language that is considered by many to be the best…
Q: 2. A certain CS professor gives five-point quizzes that are graded on the scale 5-A, 4-B, 3-C, 2-D,…
A: Algorithm: Ask the user to input grade Check the corresponding grade using if-else Display the…
Q: How to use C code to write a C program segment that prompts and accepts the age and number of hours…
A:
Q: Q6) Write a C++ program that enters two characters (for example: 'D' and 'S'), then the program…
A: GIVEN:
Q: Q1a) Instructions Consider the following program segment: //inc
A: // header for input output#include <iostream>using namespace std; // for without std int…
Q: c. Refer to the C++ program in Figure 1.1Gad answer Question 1e (1) - (xi). Otinclude tinclude…
A: input radius1 and radius2 it basically calculates the volume of two sphere volume of sphere is =…
Q: Identify and correct which statement (s) in the following C++ programs will cause a compiler error?…
A: Yes, there is a mistake in a statement which is causing a compile time error. Let us correct that…
Q: What is the value of A in the following C++ code snippet? #include #include #include using…
A: Task :- Find out the output for given C++ code. Given char pointer - const char *a =…
Step by step
Solved in 2 steps with 2 images
- Programming 2 - C++ Assignment: Q1: Consider the following statement:string str = "My major is Computer Science, specialized in Artificial Intelligence “a) What is the output of the following C++ statements?1. cout<<str.size()<<endl;2. cout<<str.substr(11,10)<<endl;3. cout<<pos=str.find(',');<<endl;4. cout<<str=str.insert(2," sister ")<<endl;b) Write the required statements to do the following:1. Read the string: “specialized in Artificial Intelligence” into a string variable str42. Print the position of ‘j’ in str3. Modify str to be: “My major is Computer Science.”4. Change the phrase “Artificial Intelligence” to “Cyber Security” Q3: Consider a class named Cars that have the following class members:• Public member: CarModel as string.• Public member: CarPrice as double.• Private member: CarColor as String.• Void function named PrintCarInfo().(a) Write the complete class definition?(b) Create a class object named Mercedes-Benz of the…In C declare a variable of type character.Ask the user for a letter and place it in the declared variable.Write code to check for and output statement stating whether the variable is an upper caseletter, lower case letter, or not a letter (neither of the above).Q1) How to write a C program segment that prompts and accepts the age and number of hours the customer has spent in the “FUNNY Theme Park”. Then, displays the charges based on the rates shown in Figure 2 below : Age Range Rate ( per hour) (RM)0-20 1.0021-50 3.50Above 50 2.00 In your program, you have to make use of THREE(3) different defined constants for the value of rate per hour and declare the necessary variables.
- Solve the problem in C++ (Financial application: compute the future investment value) Write a function that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.23. Use the following function header: double futureInvestmentValue( double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValue(10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user to enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%) and prints a table that displays future value for the years from 1 to 30, as shown below: The amount invested: 1000 Annual interest rate: 9 Years Future Value 1 1093.80 2 1196.41 ... 29 13467.25 30 14730.57Please use C++ Programming Write a program in "C" that accepts a string (maximum length 25 char) from the user. Convert first the user input into lower case by writing your own case conversion function i.e. void to_lower(char dest[], char src[]). Do not use built in function. Then analyze it to display the result in the following manner. Enter some text: UET Peshawar, Pakistan You Entered: uet peshawar, Pakistan Characters: 22 Alpha-numeric Char: 19 Space Char: 2 Other Char: 1PROBLEM SPECIFICATION:Develop a c++ program that will accept two integer numbers (Minimum and Maximum). Theprogram should determine and display the odd and even numbers between the two numbers.Calculate and Display the total of Odd numbers and Even numbers and the number of Odd andeven numbers between the two numbers.Consider the below points: 1. The program should be able to process if the minimum value captured is less than themaximum value captured. The program should determine and display odd and evennumbers between the two numbers in ascending order. 2. The program should be also able to process if the minimum value captured is greaterthan the maximum value captured. The program should determine and display odd andeven numbers between the two numbers in descending order.3. Should be able to handle appropriately when equal values are captured. 4. Include appropriate comments (to demonstrate understanding)
- Hello good afternoon, Use functional decomposition to write a C++ program that asks the user to enter his or herweight and the name of a planet. Use an enumerated type called planetType to represent theplanets and use a switch statement that takes as its condition a planetType variable. The program,via the switch statement, then outputs how much the user would weigh on that planet. Thefollowing table gives the factor by which the weight must be multiplied for each planet.Your program must have the following functions in it: GetUserInput(),ConvertInputToPlanetType(), and OutputWeight() (your switch statement must be inOutputWeight()). I will let you determine what each function’s parameters and return typesshould be. The program will output an error message if the user does not type a correct planetname. The prompt and the error message will make it clear to the user how a planet name mustbe entered.Use proper formatting and appropriate comments in your code. The output must be…Fix the following c++ code : #include<iostream>using namespace std;void Ashraf(int [][],int,int);int main(){int a[2][3];Ashraf(a,2,3);}void Ashraf (int a[ ] [], int R, int C){for(int r=0; r<R; r++){for(int c=0; c<C; c++){a[r][c]=1;cout<<a[r][c]<<"\t";}cout<<endl;}3. Write a program in C to concatenate two String S3 and String S4, to concatenate these strings call a function StrConcate()
- Write the C statements necessary to do each of the following. Do not write complete programs. Unless otherwise indicated, assume variables have been appropriately declared and values assigned. Declare a structure with tag month_data to store the name of a month and its number of days (don't worry about leap year). Define a variable named dec of this type and initialize it to the appropriate values for December. Write a C function that will determine both the square and the cube roots of its first argument, which is a double. Both roots should be made available to the referencing function but NO global variables should be used. Answer each of the following concerning C++ Explain briefly the difference between a class and an object. Explain briefly what is meant by the term operator overloading.Implement in C Programming 7.6.1: LAB: Simple car Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCar variable that performs the following operations: Drives input number of miles forward Drives input number of miles in reverse Honks the horn Reports car status SimpleCar.h contains the struct definition and related function declarations. SimpleCar.c contains related function definitions. Ex: If the input is: 100 4 the output is: beep beep Car has driven: 96 miles main.c #include <stdio.h> #include "SimpleCar.h" int main() { /* Type your code here. */ return 0;} SimpleCar.h #ifndef SIMPLE_CAR_H#define SIMPLE_CAR_H typedef struct SimpleCar_struct { int miles;} SimpleCar; SimpleCar InitCar();SimpleCar Drive(int dist, SimpleCar car);SimpleCar Reverse(int dist, SimpleCar car);int GetOdometer(SimpleCar car);void HonkHorn(SimpleCar car);void Report(SimpleCar car); #endif SimpleCar.c #include…Modify the following C code to get the given output: #include <pthread.h> #include <semaphore.h> #include <stdio.h> /* This program provides a possible solution using mutex and semaphore. use 5 Fsrmers and 5 ShopOwner to demonstrate the solution. */ #define MaxCrops 5 // Maximum crops a Farmer can produce or a Shpoowner can take #define warehouseSize 5 // Size of the warehouse sem_t empty; sem_t full; int in = 0; int out = 0; char crops[warehouseSize]={'R','W','P','S','M'};//indicatig room for different crops char warehouse[warehouseSize]={'N','N','N','N','N'};//initially all the room is empty pthread_mutex_t mutex; void *Farmer(void *far) { /* 1.Farmer harvest crops and put them in perticular room. For example, room 0 for Rice(R). 2.use mutex and semaphore for critical section. 3.print which farmer is keeping which crops in which room inside the critical section. 4.print the whole warehouse buffer outside of the critical section */ }…