#include using namespace std; int main() 2 4 5 E { cout « "Please enter two names \n"; string first; string second; cin >> first » second; 6 7 8 9 10 11 B 12 if (first == second) cout <« "that's the same name twice\n"; if (first < second) cout « first <« " is alphabetically before " <« second «'\n'; 13 B 14 if (first > second) <« second cout « first « " is alphabetically after <«'\n'; 15 return 0; 16
Q: void fun (int& x, double y = 2.8, double z=5.4, char c = 'h') if (isupper (c)) cout << x + y-z; else…
A: explanation: when fun call x=3, y=3.6, z=5.4, c=h ( y not equal to 2.8 because we pass y=3.6 if…
Q: int main() { int i, salary[10], range[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; double gross[10], total[10];…
A: The regular expression (RE) contains the symbol 0 and 1 only. The expression is:…
Q: #include using namespace std; char let; int Final (int &num1, int num2); double Final (double…
A: Given: #include <iostream> using namespace std; char let; int Final (int &num1, int num2);…
Q: What will the following program display? #include using namespace std; int main() { int unus, duo,…
A: GIVEN: What will the following program display? #include using namespace std; int main() { int unus,…
Q: 1 #include 2 using namespace std; int main() 3 4 { 5 int const k=12; 6 int m=67, v=k+m; 7 K=K+2; 8…
A: const: It is a keyword used in c++ to declare a variable as constant means that we can not change it…
Q: C++: Describe how the following call by reference works. Make a comment for each line. void…
A: Call by Reference: Original value is changed in call by reference, since we transfer reference…
Q: Fill in the blanks above C++ code. !!! DO NOT USE ANY WHITESPACE ! #include include #include…
A: Fill ups: #include <cstdlib> using namespace std; int myArray [10]; for(int i = 0; i < 10;…
Q: //Below is the starting code for this homework assignment// #include struct employees {…
A: To take input in the readEmployee function we use the arrow operator to take the input (->) It…
Q: GIVEN (Code): #include using namespace std; void display even(int numbers[], int length){ //Write…
A: #include <iostream>using namespace std;//function that takes an array and displaying even…
Q: // Program 4.5.1 #include using namespace std; int main() { char *Animal[ ] = {…
A: The answers for the above questions are as follows:
Q: //DETERMINE THE RESULT OF THE FOLLOWI #include using namespace std; int main() { int i,prod=1; i=5;…
A: According to the information given:- We have to execute and find out the correct option.
Q: Show the output of the following two programs:
A: Given: Show the output of the following two programs:
Q: #nclude jostcamb yoid main(void) int i: i=5: cauteet in the if state ment'ee=sdand jsid \n", ); saut…
A: 1. Output as Follows: in the if statement i=5 and j=1 Outside of the if Statement i=5 and j=1
Q: #include using namespace std; const int y = 1; int main () ( int static y - 2; int i = 3, j - 4, m…
A: The output along with the explanation is given below:
Q: 5) #include using namespace std; int main() { int arr[] = { 4, 5, 6, 7 }; int* p = (arr + 1); cout…
A: code: //include the necessary header #include<iostream> using namespace std; //main method int…
Q: What will be the output of the following code: #include using namespace std; class Box { private:…
A: Program: #include <iostream> using namespace std; class Box { private: int length;…
Q: 2 #include using namespace std; void func1(int &) ; void func2 (int &, int &) ; void func3 (int,…
A: In func1,func2: Arguments are passed to the function by sending the reference not value. So any…
Q: include #include using namespace std; int main () { vector v (8); for (unsigned i = 0; i < v ();…
A: 1.v.size() 2.v[i] 3.v.size() 4.v[i]
Q: 4.15 LAB: Hailstone sequence Given a positive integer n, the following rules will always create a…
A: Ans: Code: n = int(input())print(n, end='\n')while n > 1: if n % 2 == 0: n = n//2…
Q: Hinclude Hinclude ciomanip> using namespace std; void test(int first, int& second); int main () int…
A: The output is below:
Q: 1 #include using namespace std; int main() 3 4 5 E { 6. cout « "Please enter two names \n"; string…
A: C++
Q: using namespace std; eint div_2(int a){ if(a%2==0){ return 1; return -1; } 4} evoid div_6(int b){ }…
A: Program always start frommain function. main function call div_6(12) and it pass 12 to the function.…
Q: 3) The number of errors in the following code is .. #include using namespace std; int main) int a,…
A: Answer: The correct option of the code is (d) = 0 Code: #include <iostream>using namespace…
Q: 7/Program 4.2 #include #include int main (){ int nilai1; nilail = 4; printf("%d+%d=%d", nilail,…
A: Dear Student 1. First your program will not compile because you did not declare nilai2 variable. if…
Q: include doublevalue (int z) { z*=2; --z; return z;} int main( ) {int a, b; a=16; b=23;…
A: In the above program, aa,bb,f are not declared doublevalue function is returning int value, but…
Q: commas.cpp) Write a program that accepts a 7-9) digit //integer and echoes the number with commas…
A: Given: The need for a problem statement to separate the variations of the last digits and the…
Q: #include struct employees { char name[20]; int ssn[9]; int yearBorn, salary;…
A: #include <stdio.h> struct employees { char name[20]; int ssn[9]; int yearBorn,…
Q: can you complete this code in c++, to create a simple Tic Tac Toe(just simply add rules ) #include…
A: The Tic Tac Toe game is a paper and pencil game in which two players take turns marking a 3 x 3…
Q: #include using namespace std; int x = 10; int main () int x = 20; %3D cout << "x is " << x << endl;…
A: #include <iostream>using namespace std;int x=10;//varaible x declared and initialized in…
Q: void minimum (int i1, int i2) { if (i1 > n >> m; minimum (n, m); return 0; }
A: .file "p.cpp" .text .section .rdata,"dr" _ZStL19piecewise_construct:…
Q: #include using namespace std; int main() int const p = 5; cout << ++p; return 0; a) 5 O b) 6 O c)…
A: Here integer p is declared as a constant variable. That is, once value set, it cannot be changed.
Q: Q.2.A ) what is the output of the following code ? 1 #include 2 using namespace std; 3 int main){ 4…
A: #include<iostream>using namespace std;int main(){for (int i=0; i< 18;i++){ if(i==2)…
Q: %23 include ciostream> using namespace std; int mounU 7 your code goes here int total = 10, sum =…
A: Given: To find and Explanation of the given c++ Code.
Q: Coding Challenge Write a function named aidojo that takes a an integer parameter ʼn and return a…
A: Sample Output Screenshot:
Q: #include #include using namespace std; int main() { // Declare and initialize variables.…
A: Required: A c++ program is given, create a logic using switch statement according to instructions…
Q: #include using namespace std; int rectArea (int len, int wid) { return len * wid; } int main…
A: The given program is to calculate the area of rectangle given length and width of rectangle.
Q: #include using namespace std; int pc(int a, int b) { if (b == 0) return a; return pc(b, a % b); }…
A: The correct answer for the above question is last option => Greatest Common Divisor of a and b.…
Q: What will be the output of given code. #include using namespace std; int add(int a,int b){…
A: Given: What will be the output of given code. #include<iostream>using namespace std; int…
Q: QI: tinclude (a) Write two different techniques to declare and initialize a variable with an…
A: Hey, since there are multiple questions posted, we will answer first question. If you want any…
Q: c++complete and change #include using namespace std; int sumbyrow(int* m, int ncol, int row) {…
A: Note : I am considering that you are facing some logical error in this code which is not…
Q: #include using namespace std; lprototypes should go here - you don't need to write them int main) {…
A: A) &num1,&num2,&num3 B) num1,num2,num3,&lowest,&highest C) average = D)…
Q: a. 40 15 #include using namespace std; b. 50 15 40 30 int main () C. d. 50 30 int arr(4]…
A: Q1. arr [4][3] is a 2 dimensional array of 4 rows and 3 columns. int * a is a pointer pointing to…
Q: Please fix this code for me, I'm stuck . #include #include using namespace std; // the main…
A: The error is because, you have used swet(w). It is not swet(width). It is setw(width) There are…
Q: int_tmain(int argc, _TCHAR* argv[]) { int A=35, B=65; if(A>=40 || B<=75) { cout<<"lf will execute";…
A: The given problem is related to C++ programming and operators in the programming. The requirement is…
Q: #include #include #include using namespace std; int main() { int monthlyUsage[12]; double…
A: Process Explanation : The above C++ code is used for calculating consumption of electricity in each…
Q: fION 15 To assign a double variable d to an int variable x, you writ Ox= d; Ox= (long)d x (int)d3;…
A: This question comes from Programming Language which is a paper of computer science. Let's discuss it…
Q: This program determines if an airline passenger is // eligible for a 25% discount.
A: There are two ways to find eligibility of a passenger for a 25% discount on the basis of age Using…
Q: ?What is the output of the following code #include using namespace std; int fun(int a, int b = 1,…
A: Default parameter value can be assigned using the equals sign If we call the function without an…
Q: (a) int *ptrl=&a, a; int *ptrl, a; (b) ptrl=&a; (c) int *ptrl; int a; ptrl=&a; (d) int *ptr2, a,…
A: “Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: 19.3 LAB: Hailstone sequence Given a positive integer n, the following rules will always create a…
A:
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
What is the output of the following code if the user enters first as John and second as john?
#include<string>
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 5: CheckLetter.cpp) Write a program that adds a checkletter to an eight-digit number. The check letter should becomputed as follows: Break the number up into 4 two-digitnumbers. Add the four numbers together. Find theremainder after division by 26. The check letter is the letterin the alphabet that corresponds to the number justcomputed. (A=0, B=1, C=2, etc.) Print the original numberfollowed by the check letter. Use at least one ffunction thatreturns a value when you write this program.T/F The << operator is overloaded to input data items of fundamental types, strings and pointer values4.23 (Financial application: payroll) Write a program that reads the following information and prints a payroll statement: Employee’s name (e.g., Smith)Number of hours worked in a week (e.g., 10)Hourly pay rate (e.g., 9.75)Federal tax withholding rate (e.g., 20%)State tax withholding rate (e.g., 9%) A sample run is shown below:Enter employee's name: SmithEnter number of hours worked in a week: 10Enter hourly pay rate: 9.75Enter federal tax withholding rate: 0.20Enter state tax withholding rate: 0.09Employee Name: SmithHours Worked: 10.0Pay Rate: $9.75Gross Pay: $97.5Deductions:Federal Withholding (20.0%): $19.5State Withholding (9.0%): $8.77Total Deduction: $28.27Net Pay: $69.22 Requirement: Requirements: Input and output must match the format provided in the exercise sample runs Currency must be displayed properly: You must have a dollar sign ($) and 2 places after the decimal (dollars and cents) You must use printf rather than the goofy trick from earlier chapters Appropriate…
- pls debug this pseudocode // A high school is holding a recycling competition,// and this program allows a user to enter a student's // year in school (1 through 4) and number of cans collected// for recycling. Data is entered continuously until the user// enters 9 for the year.// After headings, output is four lines --// one for each school year class.start Declarations num year num cans num SIZE = 4 num QUIT = 9 num collectedArray[SIZE] = 0, 0, 0 string HEAD1 = "Can Recycling Report" string HEAD2 = "Year Cans Collected" output "Enter year of student or ", QUIT, " to quit " input year while year <> QUIT output "Enter number of cans collected " input cans collectedArray[year] = collectedArray[year] + cans output "Enter year of student or ", QUIT, " to quit " input year endwhile output HEAD1 output HEAD2 year = 1 while year < SIZE output year, collectedArray[year] year = year + 1…Computer Fundamentals and Programming 2 Write a program that determines a student’s grade. The program will accept 3 scores and computes the average score. Determine the grade based on the following rules: - If the average score is equal or greater than 90, the grade is A. - If the average score is greater than or equal to 70 and less than 90, the grade is B. - If the average score is greater than or equal to 50 and less than 70, the grade is C. - If the average score is less than 50, the grade is F. Source Codes and Print Screen of the Output// Airline.cpp - This program determines if an airline passenger is // eligible for a 25% discount. // Harvey Mark, ITSE 1329#include <iostream> #include <string> using namespace std; int main() { string passengerFirstName = ""; // Passenger's first name string passengerLastName = ""; // Passenger's last name int passengerAge = 0; // Passenger's age // This is the work done in the housekeeping() function cout << "Enter passenger's first name: "; cin >> passengerFirstName; cout << "Enter passenger's last name: "; cin >> passengerLastName; cout << "Enter passenger's age: "; cin >> passengerAge; // This is the work done in the detailLoop() function // Test to see if this customer is eligible for a 25% discount if(passengerAge <= 6) { cout << "You are eligable for a discount!\n"; } if(passengerAge >= 65) { cout << "You are eligable for a…
- Anagram words Write a C code that asks users to enter two words, one after the other and checks if these words are anagrams (permutations of the same letters). For instance, the words “smartest” and “mattress” are anagrams. Examplea Run 1: Please enter first word: lookplease enter the second word: coolSorry! “cool” and “look” are not anagrams. Run 2: Please enter first word: masters please enter the second word: smartes Yes! “masters” and “smartes” are anagrams. Hint: If you sort the two words that are anagrams, they will become identical! For instance, “smartest” and “masters” both sort to “aemrsstt” You can use all functions in <string.h> Sorting a string is exactly similar to sorting an array. You just need to know the length of the string and make sure you do not touch the terminating null.19.3 LAB: Hailstone sequence Given a positive integer n, the following rules will always create a sequence that ends with 1, called the hailstone sequence: If n is even, divide it by 2 If n is odd, multiply it by 3 and add 1 (i.e. 3n +1) Continue until n is 1 Write a program that reads an integer as input and prints the hailstone sequence starting with the integer entered. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. The output format can be achieved as follows:print(n, end='\t') Ex: If the input is: 25 the output is: 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Use Python, please.Bulgarian solitaire def bulgarian_solitaire(piles, k): You are given a row of piles of pebbles, all identical, and a positive integer k so that the total number of pebbles in these piles equals k*(k+1)//2, the arithmetic sum formula that equals the sum of positive integers from 1 to k. Almost as if intended as a metaphor for the bleak daily life behind the Iron Curtain, all pebbles are identical and you don't have any choice in your moves. Each move picks up one pebble from each pile (even if doing so makes that pile vanish), and creates a new pile from the resulting handful. For example, starting with[7, 4, 2, 1, 1], the first move turns this into [6, 3, 1, 5]. The next move turns that into [5, 2, 4, 4], which then turns into the five-pile configuration [4, 1, 3, 3, 4], and so on. This function should count how many moves are needed to convert the given initial piles into the goal state where each number from 1 to k appears as the size of exactly one pile, and return that count. These…
- Question 9 nag.Write a program in C# that prompts the user to enter any string phrase and capitalizes the first letter of each word in the string. I need it to be user prompted, please! Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this lineThis is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to print the employee data to console void display(struct employees…Quarterly Sales Create a program in c++ , that gets quarterly sales from a user and calculates the total of all four quarters as well as the average, lowest, and highest quarters. Console The Quarterly Sales program Enter sales for Q1: 12312.57 Enter sales for Q2: 15293.21 Enter sales for Q3: 14920.95 Enter sales for Q4: 23432.21 Total: 65958.94 Average Quarter: 16489.74 Lowest Quarter: 12312.57 Highest Quarter: 23432.21 Specifications Create the pseudocode needed to implement the solution above. Convert your pseudocode to C++ code including the following specifications: Round the average quarter to a maximum of 2 decimal digits. Use a vector to store the sales for each quarter. Use STL algorithms to process the data for the quarters.