in c#
1- What is the output for total after the following segment of
code executes?
int num = 3, total = 0;
switch (num)
{
case
1:
case
2:
total
= 5;
break;
case
3:
total
= 10;
break;
case
4:
total
= total + 3;
break;
case
8:
total
= total + 6;
break;
default:
total
= total + 4;
break;
}
WriteLine("The value of total is " + total);
The value displayed for total would be . If num had been
initialized to 100, would be displayed. If num was
initialized to 1, would be displayed.
2-
Given the switch statement, which of the following would be the
first if statement to replace the first test in the switch?
switch (control)
{
case
11 :
WriteLine("eleven");
break;
case
12 :
WriteLine("twelve");
break;
case
16 :
WriteLine("sixteen");
break;
}
A.if (case = 11)
B.if (case == 11)
C.if (control == 11)
D.if (switch == 11)
E.none of the above
3- Assuming the following declarations:
int a is 5,
b is 6,
c is 8;
which of the result (true or false) of each of the expressions.
Identify the result of each of the expressions.
a. (1 + a) != b; _______________
b. a >= 0; _________________
c. a <= (b * 2); ______________
4-
Assuming the following declarations:
int a is 5,
b is 6,
c is 8;
which of the result (true or false) of each of the expressions.
Identify the result of each of the expressions.
a. a == 5; ____________
b. 7 <= (a + 2); ____________
c. c <= 4; ____________
5- If you were to write switch statements to perform the
following evaluation, what selector would be placed inside the
parenthesis for each of the following scenarios?
switch ( ? )
a. __________ Testing string stateName for FL, GA, or MS. Storing 1
in cnt for FL, 2 for GA, 3 for MS
b. ____________ Testing cnt for 1, 5 or 7. Storing 100 in value1
when cnt is 1, storing 10 in value1 when cnt is 5 and storing 1 in
value1 when cnt is 7
c. _____________ When middleInitial is equal to the character z, a
message should be displayed stating “You’re one in a thousand”;
otherwise, check to see if it is equal to the character ‘a’. When
it is equal to the character a, display the message “You have the
most common initial”. If it’s not equal to ‘a’ or ‘z’ the message
should read “Just another initial”.
Answer:---------
in c# 1- What is the output for total after the following segment of code executes?...
What is the value of result after the following code executes? int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...
1. What would be the output of the following lines of code: int num = 2; switch(num){ case 1: cout << "1"; case 2: cout << "2"; case 3: cout << "3"; case 4: cout << "4"; } 2. What would be the output of the following code: char op = '*'; switch(op){ case '+': cout << "Addition"; break; case '-': cout << "Subtraction"; break; case '/': cout << "Division"; break; default: cout << "Invalid"; } 3. What would be...
C# What is the output of the code segment below? int valueA = 20; int valueB = 5; int valueC = 8; int result = 1; if (valueA > valueB) result = valueA - valueB; else if (valueA > valueC) result = result + valueB; WriteLine(“{0} is the answer”, result);
should be in C language
What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
For this code after case 0, I need it to ask the user if they would like to see the menu again and some type of if statement or loop to ask them yes or no and if yes print again and if no end program. So it would ask if they would like to see the menu again then ask what their choice is. If yes print menu and if no end program. import java.util.InputMismatchException; import java.util.*; import java.io.*;...
QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...
C++ Program What is the output of the following code fragment?(beta is of type int.) beta = 5; do { switch (beta) { case 1: cout <<'R'; break; case 2: cout case 4: cout << 'O'; break; case 5: cout << 'L'; } beta--; }while (beta>1); cout <<'X';
In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task. Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop int cnt = 1; do { cnt += 3; } while (cnt < 25); cout << cnt; It runs ________ times ...
What is the value of GPA when grade is 'B' in the following code segment? int GPA=0; switch (grade) { case 'A': case 'a': GPA = GPA + 1; case 'B': case 'b': GPA = GPA + 1; case 'C': case 'c': GPA = GPA + 1; case 'D': case 'd': GPA = GPA + 1; } 4 3 2 1 None of the above #2. Branching - switch statements... Extra info/hint? It's free What is the value of GPA when...