(Binary to Octal) Write a function that returns an octal number from a binary number. The function header is as follows: int bin20ctal(const string& binaryString) Write a test program that prompts the user to enter a binary number as a string and displays the corresponding octal value as a string.
Q: The value of BX after executing the following piece of code is : *
A: According to the question, we need to find the value of BX after executing the code: XOR AX, AX ADD…
Q: Which one of the following statements is wrong?
A: Introduction: In this question, we are asked 2 MCQs related to presorting, so its just a sorting…
Q: What is the output of the following segment of code if the value 6 is input by the user when asked…
A: Entered number = 6. so, num = 6 and total = 0. inside switch case case 1:, case 2:, case 3:,…
Q: Complete the following program by writing its functions:
A: We need to define the methods abs(),Prime(),Find(),Power() and Max() as per the given description.
Q: State which of the following are true and which are false. If false, explain why.a) Function fscanf…
A: True.
Q: 3. What would happen if you passed in strings instead of integers in the function you created for…
A: <form> <input type = "button" onclick = 'add_four_nums("1","2","3","4")' value =…
Q: Which of the following programs will NOT cause an error?
A: In Python, functions are declare using def keyword
Q: How do you define a function? How do you invoke a function?
A: Define a function in C++ Defining a function in C++ is known as a function definition. it contains a…
Q: Write a python function that takes a number as a parameter and returns true if the number entered by…
A: def isINT(n): # user define function to check a number is integer or not…
Q: 13- Write a function that takes a positive integer "n" as the function parameter and returns True if…
A: Take a number from user declare a temp variable that is set to False check if the number is greater…
Q: Find the error in the following code and explain how to fix it:
A: The error in the code is in the line : ptr=m; Because ptr is a pointer variable and we cannot assign…
Q: What is printed by the following code segment?
A: The correct is ("cow?now?how?brown?") Option("D") Explanation If the break statement is located…
Q: I need to write the following code taking entera from the user.
A: The answer to thee following question:-
Q: How can we pass argument to a function by reference instead of pass by value?
A: When supplying reference t to the method it will not directly pass the actual reference value of…
Q: What is printed by the above code?
A: #include<iostream> using namespace std; void processing(int, double &, char &); int…
Q: What should be the output from the function below? void display(void) {…
A: Ans: The output from the function below is: void display(void) { int i;…
Q: Rewrite the following statements using combined assignment operators: length = length / 2;
A: Given : length = length / 2;
Q: What the output for the following code?
A:
Q: What is the output of the following code:
A: There is an Compiler error because default arguments are the leftmost arguments. Correction in code…
Q: What the following program does?
A: START: LDA 2050HMOV B,ALDA 2051HCMP BJC OTHERSTA 2052HJMP ENDOTHER: STA 2053HEND: HLT
Q: Q2/Write a program that reads from the user the value of x and apply the function below:
A: Consider the given functions : Note: Since the programming language is not mentioned i used "C"…
Q: What is the purpose of the following statement?
A: A purpose statement, also known as a "position statement," is a sentence that outlines a company's…
Q: Indicate whether the following statement is true or false. * -
A: Lets see the solution.
Q: I get the following errors for the code above
A: In this question we have to fix and re-write the linked list operations in method using python to…
Q: What will be the output for a and b given the below code segment?
A: given: c++ code required: to run the code and provide output and value of a and b.
Q: What is the output from each of the following pseudocode statements?
A:
Q: What does the following declaration mean? int (*ptr)[10];
A: Required: programming
Q: 5- Write a group of statements that carry out the same action of upper and lower functions.
A: Your answer to write group of statement that carry same action of upper and lower function is given…
Q: What is the data type of the following expressions?
A: Here i am writting data type of given expression:…
Q: What’s the output of the following programs?
A: y is initialised to 15 x is initialised to 0 In the loop y gets decremented by 1 and x gets…
Q: The following import statement will rename the name of the function tan to t. from math import tan…
A: I have given an answer in step 2.
Q: What is the Pre-Fix expression for the following infix expression? ((A+B)*C-(D-E))&(F+G)
A: What is the Pre-fix Expression of Infix Expression ((A+B)*C-(D-E))&(F+G)
Q: Which of the following logic expressions is wrong?
A: The Answer is in below Step:-
Q: What is the value stored at variable "x" after executing the following code segment
A: Please find the answer below :
Q: What are the final values of x and y in this code
A: Q: Output of the given code
Q: ch of the following statements is NOT correct?
A: The syntax of a function is void function_name(parameters) ; or data_type function_name(parameters)…
Q: -Write a function: int calculate(int x); In c++, the function returns value of 3*x^3 + 3*x^2 2.
A: We know that in this functionint Calculate (int x);The function returns value of 3*x3+3*x2-2.
Q: What is the output when the following code fragment is
A: First Question: In the cout statement, the expression follows the rules of operator precedence and…
Q: Question 1: Give the output from the following pieces of code: Code Output
A: Question given (1): Some piece of code given, what is the output of them. Solution (1):…
Q: Fill in the blank in the function below such that the function takes in two Card objects and returns…
A: You need to write card_one.suit == card_two.suit where card_one and card_two are the class objects…
Q: What does the following function do? float hypot(float x, float y) { return sqrt(x*x+y*y); }//end of…
A: Given that: Find the result of the given function: float hypot(float x, float y) { return…
Q: following statement:
A: Filled the given statement
Q: ? What is the output of the following code
A: Required: programming What is the output of the following code? given: #include <iostream>…
Q: h. ne Write the main function to do the following a. Return type int
A: 5) #include<stdio.h> //header files #include<conio.h> #include<stdlib.h>…
Q: What do you mean by inline function?
A: Here is the explanation regarding inline function:
Q: How to make a function return multiple values?
A: As per the question statement, We need to list the ways using which we can return multiple values…
Step by step
Solved in 3 steps with 3 images
- 13.16.1: Overload salutation printing. Complete the second PrintSalutation function to print the following given personName "Holly" and customSalutation "Welcome":Welcome, Holly End with a newline. #include <iostream>#include <string>using namespace std; void PrintSalutation(string personName) { cout << "Hello, " << personName << endl;} // Define void PrintSalutation(string personName, string customSalutation)... /* Your solution goes here */ int main() { PrintSalutation("Holly", "Welcome"); PrintSalutation("Sanjiv"); return 0;}10.25 LAB: Quadratic formula Implement the quadratic_formula() function. The function takes 3 arguments, a, b, and c, and computes the two results of the quadratic formula: x1=−b+b2−4ac2a x2=−b−b2−4ac2a The quadratic_formula() function returns the tuple (x1, x2). Ex: When a = 1, b = -5, and c = 6, quadratic_formula() returns (3, 2). Code provided in main.py reads a single input line containing values for a, b, and c, separated by spaces. Each input is converted to a float and passed to the quadratic_formula() function. Ex: If the input is: 2 -3 -77 the output is: Solutions to 2x^2 + -3x + -77 = 0 x1 = 7 x2 = -5.50Python 3.7.4 Given that add, a function that expects two int parameters and returns their sum, and given that two variables, euro_sales and asia_sales, have already been defined: Write a statement that calls add to compute the sum of euro_sales and asia_sales and that associates this value with a variable named eurasia_sales.
- 5.28 LAB: Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string. Ex: If the input is: 6 the output is: 110 Your program must define and call the following two functions. The IntegerToReverseBinary() function should return a string of 1's and 0's representing the integer in binary (in reverse). The ReverseString() function should return a string representing the input string in reverse. string IntegerToReverseBinary(int integerValue)string ReverseString(string userString)8.16 (Searching for Substrings) Write a program that inputs a line of text and a search string from the keyboard. Using function strstr, locate the first occurrence of the search string in the line of text, and assign the location to variable searchPtr of type char *. If the search string is found, print the remainder of the line of text beginning with the search string. Then, use strstr again to Locate the next occurrence of the search string in the line of text. If a second occurrence is found, print the remainder of the line of text beginning with the second occurrence. [Hint: The second call to strstr should contain searchPtr + 1 as its first argument.] Solve without using pointers5.21 In Python: A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 is a leap year. Ex: If the input is: 1913 the output is: 1913 is not a leap year. Your program must define and call the following function. The function should return true if the input year is a leap year and false otherwise.def is_leap_year(user_year)
- 3.27 LAB: Login name Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first six letters of the first name, followed by the first letter of the last name, an underscore (_), and then the last digit of the number (use the % operator). If the first name has less than six letters, then use all letters of the first name. Ex: If the input is: Michael Jordan 1991 the output is: Your login name: MichaeJ_1 Ex: If the input is: Nicole Smith 2024 the output is: Your login name: NicoleS_4(7) Implement the ShortenSpace() function. ShortenSpace() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. ShortenSpace() DOES NOT output the string. Call ShortenSpace() in the PrintMenu() function, and then output the edited string. Ex: Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!7. using c++, If c is a character (e.g. char c = ‘a’), then (int) c is a number between 0 and 255 that represents its ascii value of that character (the ascii value of ‘a’ is 97. Appendix B contains the ascii character set; for example, (int) ‘a’ == 97. Write a function that accepts two characters, c1, and c2, determines whether (int) c1 is greater than (int) c2, and then returns the sum of the ascii values of all the characters between c1 and c2.
- 8.19 (Removing a Particular Word From a Given Line of Text) Write a program that inputs a line of text and a given word. The program should use string library functions strcmp and strcpy to remove all occurrences of the given word from the input line of text. The program should also count the number of words in the given line of text before and after removing the given word using the strtok function. Solve it Without using pointers7.24 LAB: Convert to binary-functions Write a program that takes in a positive integer as input, and outputs a string of 1's and O's representing the integer in binary. For an integer x, the algorithm is As long as x is greater than 0 Output x 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string Ex: If the input is the output is: 110 The program must define and call the following two functions. Define a function named int to reverse_binary() that takes an integer as a parameter and returns a string of 1's and O's representing the integer in binary (in reverse). Define a function named string reverse() that takes an input string as a parameter and returns a string representing the input string in reverse. def int_to_reverse_binary(integer_value) def string reverse(input_string) LAB ACTIVITY 7.24.1: LAB. Convert to binary-functions 0/10 1 # Define your functions here. 2…4.19 C++ Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Done", "done", or "d" for the line of text. Ex: If the input is: Hello there Hey done then the output is: ereht olleH yeH