Concept explainers
Consider the following code (and assume it is embedded in a complete and correct
char a[80], b[80];
cout << “Enter sone input:\n”;
cin >> a >> b;
cout << a << ‘–’ << b <<“END OF OUTPUT\n”;
If the dialogue begins as follows, what will be the next line of output?
Enter some input:
The
tine is now.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Absolute Java (6th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Modern Database Management (12th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.arrow_forward(Statistical) In many statistical analysis programs, data values considerably outside the range of the majority of values are simply dropped from consideration. Using this information, write a C++ program that accepts up to 10 floating-point values from a user and determines and displays the average and standard deviation of the input values. All values more than four standard deviations away from the computed average are to be displayed and dropped from any further calculation, and a new average and standard deviation should be computed and displayed.arrow_forward(Numerical) a. The following is an extremely useful programming algorithm for rounding a real number to n decimal places: Step 1: Multiply the number by 10n Step 2: Add 0.5 Step 3: Delete the fractional part of the result Step 4: Divide by 10n For example, using this algorithm to round the number 78.374625 to three decimal places yields: Step1:78.374625103=78374.625 Step2:78374.625+0.5=78375.125 Step3:Retainingtheintegerpart=78375Step4:78375dividedby103=78.375 Using this algorithm, write a C++ function that accepts a user-entered value and returns the result rounded to two decimal places. b. Enter, compile, and run the program written for Exercise 11a.arrow_forward
- (Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A=s(sa)(sb)(sc) where s=(a+b+c)2 Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of sand[s(sa)(sb)(sc)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A=1. The value of A should be returned by the function.arrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forwardAll parts need to be included in the same C file so the new code needs to be added to the existing code and needs to be working code I’m asking for help on part (3a) #include <stdio.h> int printBin(int value); int main(){ int num=10; int tobinary= printBin(num); printf("The number %d converted to binary as %d",num,tobinary); unsigned int x = 1; char *ccc = (char*)&x; if(*ccc){ printf("This is Little endian"); } else{ printf("This is Big endian"); } getchar(); return 0; } int printBin(int value) { if(value<2) return value; return printBin(value / 2) *10 + value % 2; }arrow_forward
- 3. Write the function to evaluate/compute the following, i.e. the value of Pl given by the algorithm, known as Leibniz: Write code on space provide below the problem. You do not need to Run the code... (Approximate π) can be computed using the following formula: π = 4 x 1 and 4 X 1 - 1 3 + Write a program that displays the result of 4 X 1 1 5 - 1 7 1 3 + 1 9 1 1 1 1 + - 5 7 9 11 - 1 11 + 1 13 1 15 + 1 3 + 1 1 5 7 + 1 9 1arrow_forwardComputer Science QuestionIn input you are provided with two words of the same length. Each word contains only lower-case alphabets. A shift operation will remove the first character of a word and add the same character at the end of that word. Your goal is to develop a python program that outputs the number of shift operations required on the second word to maximize the length of the longest common prefix of both the words.Test Case:5ccaddbddccOutput:3arrow_forwardEnter an integer: -29 -29 is negative and odd! // OUTPUT Sample Run #2 We write code to manipulate data, which are provided by the user(s), to produce the required outcome in the most efficient way! CIS 25 Fall 2023 - Homework #1 - Page 5 of 7 CIS 25 C++ Programming Laney College Your Name Information Assignment: Implemented by: Required Submission Date: Actual Submission Date: CIS 25 C++ Programming Laney College Your Name Enter an integer: -294258 -294257 is negative and even! // OUTPUT Sample Run #3 We write code to manipulate data, which are provided by the user(s), to produce the required outcome in the most efficient way! Information -- Assignment: Implemented by: Required Submission Date: Actual Submission Date: HW #1 Exercise #1 Your Name 2023/09/18 JJ- CIS 25 - C++ Programming Laney College Your Name HW #1 Exercise #1 Your Name 2023/09/18 Enter an integer: 41294258 41294258 is positive and even! // OUTPUT Sample Run #4 We write code to manipulate data, which are provided by…arrow_forward
- Part 2 – The Triangle Write a complete C program that uses the * character to draw a triangle of a given number of rows. The program first prompts the user to enter the number of rows in the triangle. Your program may assume that the input is a valid integer from 1 to 20 (inclusive). Here are some sample outputs from the execution of the program. The output of your program should match the sample output. Sample output 1: Enter the number of rows in the triangle: 1 * Sample output 2: Enter the number of rows in the triangle: 2 * *** Sample output 3: Enter the number of rows in the triangle: 3 * * ***** Sample output 4: 2 Enter the number of rows in the triangle: 10 * * * * * * * * * * * ******************* Hint: You may find it helpful to draw the required output on a piece of graph paper before writing your program.arrow_forward: Write a program in C++ to input attendance as 0 (for absent) and 1 (for present) for 25 students in 32 lectures and store it in a 2-D array. After the input, write loops for calculating and displaying the index numbers of the students who has short attendance (i.e. less than 75%). Please enter attendance of all 25 students for given lecture (total 32 lectures): Enter attendance of Lecture “1” Student 1: <user enters 0 or 1> Student 2: <user enters 0 or 1> and so on….arrow_forward*You need to have at least one user define function *Language: C programming Write a program in C to print a diamond using *. Ask the use to input the height of the pyramid. Using the height given by the user (data validity needed), use nested loops to draw the pyramid. Input: Key in the height: 9 Output: * ** *** **** ***** **** *** ** *arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning