(Occurrences of a specified character) Write a method that finds the number of occurrences of a specified character in a string using the following header: public static int count (String str, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character then displays the number of occurrences of the character in the string. Output:
Q: What is the output of the statements?
A: In this question, we are asked to give the output of the following code: a) int main(){ int x;…
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 code? int x = 0; void main()
A: Here have to determine correct option for given c code and gives correct output option.
Q: What is the output of the following code: int main()
A: static variables share common value local variables have same value
Q: Each of the following statements is true or false. And explain why.
A: Option B will be the TRUE Explanation : For all the triangle x there is a square y such that x and y…
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: What is the output of the following code? A = [1,1,2;3,6,9] b = [3, 4] C=A.* b
A: (a) Code will return the error : Matrix dimensions must agree.
Q: - What will be the value of M as a result of the following operations? int M; M=33/5; cout<<M; 06,5…
A: We will run this code in a proper C++ program. Then we will get the output.
Q: When the following code runs, what is printed? for num in range(5, 0, -1): print(num, end='')
A: Given: When the following code runs, what is printed? for num in range(5, 0, -1):print(num, end='')
Q: Q: what is the left side of the following expression: x@y1?
A: XOR ⊕ returns 0 for the same input and 1 for different inputs. Given, x ⊕ y ⊕ 1
Q: Which of the following statements is false?
A: option 3 and 4 statements are False: - For an 8259A controller the RD PIN is used by 8086 to read…
Q: Complete the code as below mentioned. Write all
A: Here, in this question, we are asked to develop a GO code. It is stated that the amount of potatoes…
Q: What are the values of a, b, c, d, and e after the following statements? int a = -2, b = 5, c = 1,…
A: EXPLANATION: The value of x is assigned as e+d-2 which comes out to be as -5+11-2 which is 4. The…
Q: Rewrite the following statements using combined assignment operators: length = length / 2;
A: Given : length = length / 2;
Q: What is the value assigned to x after the following C expression is executed? int a=1, b=5, x; x=…
A: Please find the answer below
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: Which of the following statements is true?
A: Required: Matlab Which of the following statements is true?
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: What is the output of the following int main()
A: Q
Q: Mark the following statements as true or false.
A: All the answers are given below with proper explanation
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: /*Question: what is the output after executed the following Program*/
A: The output after executing the above program is as follows:
Q: What is y after the following switch statement?
A: I have provided C CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------------------
Q: What is the error in the following program? #include void main( )
A: After compiling the above given source code you going to get the compile time error saying :…
Q: ? What is the output of the following code
A: Required: programming What is the output of the following code? given: #include <iostream>…
Q: What are the return values of the following statements in R x<-5 & y<-6
A: Given statements: x<-5 & y<-6 Let's perform addition operation with return value. R…
Q: What does the following code print out?
A: Step 1:- The given program in the java programming language. Given Program:- public class…
Q: The following statement is a prop-
A: Question 1The following statement is a proposition . Lincoln is not the capital of Nebraska.True…
Q: what is the output of the following code:-
A: #include <iostream> using namespace std; int main(){ for(int…
Q: Which of the following statements is true? *
A: Constructor: Constructor is a function which initializes the instance of a class. It also…
Q: What is the difference between the statements continue and break?
A: Given What is the difference between the statements continue and break.
Q: What is the output of the following cod
A: Required: provide the output of the following code ?
Q: State whether the following statement are (true) or (false)
A: Q: Answer given statements using deductions from the paragraph
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 5.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)Python 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.21.7 LAB: Login name (Use python) 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 five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the last name. Ex: If the input is: Michael Jordan 1991 the output is: Your login name: JordaM91 Ex: If the input is: Kanye West 2024 the output is: Your login name: WestK24
- 11.17 (Bucket Sort) Use Python. Show the whole code input and output when done. A bucket sort begins with a one-dimensional array of positive integers to be sorted and a two-dimensional array of integers with rows indexed from 0 to 9 and columns indexed from 0 to n – 1, where n is the number of values to be sorted. Each row of the two-dimensional array is referred to as a bucket. Write a class named BucketSort containing a function called sort that operates as follows: a) Place each value of the one-dimensional array into a row of the bucket array, based on the value’s “ones” (rightmost) digit. For example, 97 is placed in row 7, 3 is placed in row 3, and 100 is placed in row 0. This procedure is called a distribution pass. b) Loop through the bucket array row by row, and copy the values back to the original array. This procedure is called a gathering pass. The new order of the preceding values in the one-dimensional array is 100, 3 and 97. c) Repeat this process for each subsequent…6.17 LAB: Swapping variables Define a method named swapValues that takes an array of four integers as a parameter, swaps array elements at indices 0 and 1, and swaps array elements at indices 2 and 3. Then write a main program that reads four integers from input and stores the integers in an array in positions 0 to 3. The main program should call function swapValues() to swap array's values and print the swapped values on a single line separated with spaces.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 pointers
- w.J write the s11.4.1: Leap year - functions. 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. If the input is 1712, the output is: 1712 is a leap year. If the input is 1913, the output is: 1913 is not a leap year. Your program must define and call a function: Function OutputLeapYear(integer inputYear) returns nothing The function should output whether the input year is a leap year or not. Need program written in the coral language(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!
- 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 yeH5.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)1(a): Implement the following C function : concatenate the lowest byte of each of two integers. The output should have 0's in the two most significant bytes , followed by the least significant byte of the first then second argument . For example , concatLowBytes (0x12345678 , 0xaabbccdd) 0x000078dd . You may use hexidecimal constants of any size. You should not use binary notation , function calls , loops or conditional statements. Examples : concatLowBytes ( 0x00000011 , 0x00000022)=0x00001122 concatLowBytes (0x12345678 , 0xaabbccdd )= 0x000078dd int concatLowBytes (int x, int y){ }