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++ (Looseleaf) - With Access
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)
- NEED CODING IN PYTHON OR JAVASCRIPT BUT NOT C++ consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The…arrow_forward5.22 In Python: Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order.def swap_values(user_val1, user_val2)arrow_forwardConsider the following C program.# include < stdio.h >int main(){char s3;float s2;int s1;scanf("%d %f %c", &s1, &s2, &s3);printf("%d %f %c", s1, s2, s3);return 0;}If the user enters the input values 5 H 1.2 for s1, s2, and s3 respectively. Which of the following values are read correctly and stored into the variables by the scanf function correctly? Choose an answer A H B 5 H 1.2 C 1.2 D 5arrow_forward
- Problem Statement: Consider an input string PAL of letters ‘P’, ‘A’, and ‘L’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called PAL_TAB. The number of each of these letters is unknown. We have a function, called SWAP(PAL, i, j), which places the ith letter in the jth entry of string PAL and the jth letter in the ith entry of PAL. Note that SWAP(PAL, i, j) is defined for all integers i and j between 0 and length(PAL) – 1, where length(PAL) is the number of letters of PAL. 1. Using our algorithmic language, write an algorithm, called Sort_PAL, which sorts the letters in the array PAL_TAB in a way that all P’s appear first, followed by all A’s, and followed by all L’s. The algorithm Sort_PAL should have one parameter: The array PAL_TAB. Also, your solution is correct only if the four constraints below are satisfied: - Constraint 1: Each letter (‘A’, ‘L’, or ‘P’) is evaluated only once. - Constraint 2: The function SWAP(PAL, i, j) is…arrow_forwardInstructions Consider the provided C++ code in the main.cpp file: The function func2 has three parameters of type int, int, and double, say a, b, and c, respectively. Write the definition of func2 so that its action is as follows: Prompt the user to input two integers and store the numbers in a and b, respectively. If both of the numbers are nonzero: If a >= b, the value assigned to c is a to the power b, that is, aᵇ. If a < b, the value assigned to c is b to the power a, that is, bᵃ. If a is nonzero and b is zero, the value assigned to c is the square root of the absolute value of a. If b is nonzero and a is zero, the value assigned to c is the square root of the absolute value of b. Otherwise, the value assigned to c is 0. The values of a, b, and c are passed back to the calling environment. After completing the definition of the func2 and writing its function prototype, run your program. Code Given: #include <iostream> #include <cmath> #include <iomanip>…arrow_forward6. use c ++ to Write a function sumDigits, that accepts a positive integer n and returns the sum of the digits in that integer; thus, sumDigits(34) would return 7 (e.g., 3+4). Use the techniques from the roman numeral problem to extract the digits.arrow_forward
- Assume that your program has the following function for handling signals defined: void bailout (int num) { write (STDERR_FILENO, "Oops\n", 5); exit (0); } Write the code (you don't have to write a full function...just the relevant lines of code) to invoke this function when a segmentation fault occurs.arrow_forward// Ex 6.1 // // Write a function prototype for a function called "next" // which takes no parameters and returns no result. // Write your code for Ex 6.1 above this line. // Ex 6.2 // // Write a function called "print_rand" which returns no result // and takes, as a single argument, a pointer to an unsigned 32-bit // integer. // // The function should inspect the least significant two bits // of the integer pointed to by the argument, and depending on // the value of the bits, execute one of the following function // calls: // // 0b00: putchar('1'); // 0b01: putchar('2'); // 0b10: putchar('3'); // 0b11: putchar('4'); // // Once you have written this function uncomment the second printf() // statement in main() such that its operation can be tested. // Write your code for Ex 6.2 above this line. // Ex 6.3 // // Complete below the implementation for the function next(). // // next() should: // 1) Right shift the bits in "state" by 1 bit position. // 2) If the bit…arrow_forward1.Write program to iteratively compute Fibonacci numbers (named after an Italian mathematician).Some Fibonacci numbers are 1, 1, 2, 3, 5, 8, ... where the next number is found by summing the preceding two numbers. Your program will read in a number, like 7, report the first 7 numbers. in this case1,1,2,3,5,8,13. Your program is not assured of receiving good data, thus if -2 is received as the number of numbers, then an error should be reported.arrow_forward
- The topic is Booth's algorithm - Explain this C programming code - i have a seminar. //header files #include #include #include int a=0,b=0,c=0,a1=0,b1=0,com[5]={1,0,0,0,0}; int anum[5]={0},anumcp[5] ={0},bnum[5]={0}; int acomp[5]={0},bcomp[5]={0},pro[5]={0},res[5]={0}; // binary function void binary(){ a1 = fabs(a); b1 = fabs(b); int r, r2, i, temp; //for loop for binary for(i = 0; i < 5; i++){ r = a1 % 2; a1 = a1 / 2; r2 = b1 % 2; b1 = b1 / 2; anum[i] = r; anumcp[i] = r; bnum[i] = r2; if(r2 == 0){ bcomp[i] = 1; } if(r == 0){ acomp[i] =1; } } //2's complimanting part for the program c = 0; for( i = 0; i < 5; i++){ res[i] = com[i]+ bcomp[i] + c; if(res[i]>=2){ c = 1; } else c = 0; res[i] =…arrow_forwardI need a memory diagram of this C++ function: ***CODE*** #include using namespace std; int f2(int r, int& s) { r /= 2; s *= 3; int temp = r + s + 20; return temp; } int f1(int& p) { int q = 5; p = 95; int temp = f2(p, q); return temp; } struct s1 { string fname; int grade; s1() : fname(""), grade(0) {} }; int main() { int a = 7; int b = f1(a); s1* summa_cum_laude = new s1(); s1* magna_cum_laude = new s1(); summa_cum_laude->fname = "Roxanne"; summa_cum_laude->grade = a; magna_cum_laude->fname = "Rock"; magna_cum_laude->grade = b; cout << (*summa_cum_laude).fname << "'s grade: " << (*summa_cum_laude).grade << endl; cout << (*magna_cum_laude).fname << "'s grade: " << (*magna_cum_laude).grade << endl; delete summa_cum_laude; magna_cum_laude = nullptr; }arrow_forward1-The function sum_n_avg computes the sum and the average of three input arguments and relays its results through two output parameters.a)Write a prototype for a function sum_n_avg that accepts three double-type input parameters and returns two output parameters through reference.b)Write the function definition for function sum_n_avg. The function definition is where the actual computations are performed.c)Write a function call in main () for sum_n_avg. The function call can look like below:{double one, two, three, sum_of_3, avg_of_3;printf("Enter three numbers> ");scanf("%lf%lf%lf", &one, &two, &three);sum_n_avg(__________________________________);. . .}2- Write a function definition for a function named final_grade that has a typeint input parameter called points and returns through an output parameter gradePtr the appropriate letter grade using a straight scale (90–100 is an A, 80–89 is a B, and so on). Return through a second output parameter (missedPtr) an…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr