1 point
I have to read the string “What is your name?” into a variable x. Which of the following is the appropriate command sequence?
x; cin>>x;
char x; cin<<x;
string x; cin>>x;
char x; cin>>x;
Write a C++ program to sort a given array of integer numbers and also provide a function
to search for a given element in that sorted array using binary search algorithm.
Consider the following lines of Python code.
x = [589,'big',397,'bash']
y = x[2:]
u = x
w = y
w = w[0:]
w[0] = 357
x[2:3] = [487]Write a program which multiplies an N digit number M by a 1 digit number d, where N could be large, e.g. 1000. The input will be given as follows. First, the user gives d, then N and then the digits of M, starting from the least significant to the most significant. The program must print out the digits of the product one at a time, from the least significant to the most significant.
Hint: Mimic the process of manual multiplication. Keep track of the current carry in a variable and update it as you go along.
Write an expression that prints "Special number" if specialNum is 0, -99, or 44.
Fill in the blanks in the following code. The code is written to draw 4 rectangles of heights 20, 30, 40, 50 respectively and widths 20, 15, 10, 5 respectively. The centres of these rectangles are at (1,2)
initCanvas();
double x=20;
double y=20;
repeat(4){
Rectangle r( BLANK-P , BLANK-Q , x, y);
r.imprint();
x = x + BLANK-R ;
y = y + BLANK-S ;
}
What is BLANK-P ?
What is BLANK-Q ?
What is BLANK-R ?
What is BLANK-S ?
Write a program to calculate the SPI(semester performance index) and CPI(Cumulative Performance Index) of a student taking N courses in a semester. Each course has a specified weight, termed as credit and a student secures a letter grade in that course as per the Grading System.
The Grading System is as follows:
Letter Grade Numerical Grade
A 10
B 9
. .
. .
K 0
Note that the numerical grade can be obtained from the letter grade using arithmetic operations on char type data.
Create a simple mashup page that displays both the BBC news (https://www.bbc.com/news) and BBC Pidgin (https://www.bbc.com/pidgin) home pages. Your solution should be in a file p3.html. Note: your solution for this problem does not need to validate.
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below.
Menu/Prompt:
Enter the number that corresponds to your desired unit conversion from the choices below:
[1] Tablespoon (Tbsp) to Teaspoons (Tsp)
[2] Ounces (Oz) to Grams (g)
[3] Cups to Milliliters (ml)
Enter a number: 3
Possible Input/Output (Assume user enters the number 1 as the base unit)
Enter the number of tablespoons:
There are 3 teaspoons in 1 tablespoons
Enter the number of ounces:
There are 28.35 grams in 1 ounces
Enter the number of cups:
There are 236.6 ml in 1 cups
Invalid choice. Please run the program again.
Notes and Hints: