1. How many values does the following scanf statement expect the user of the program to input:
printf("Please enter three numbers: \n");
scanf ("%i%i%i", &x,&y);
a. 1 value
b. 0 values
c. 2 values
d. 3 values
2. (Points: 4.0)
What is output from the following code segment:
int x = 2, num;
while (x < 6)
{
num = x * x;
printf ("%i\n", num);
x++;
}
3. (Points: 4.0)
How would the last line of the following code segment need to be modified for the average calculation below to be correct? (Note: this is not an entire program just a code segment.) Modify the code in the box below.
int average;
float total = 100, number = 27;
average = total/number;
4. (Points: 4.0)
It is common to confuse the equality operator with the assignment operator because the assignment operator looks like ____ and the equality operator looks like____
5. (Points: 4.0)
Which statement below is equivalent to the following code segment:
if ( ( num % 2) == 0 )
printf ("Even.\n");
else
printf ("Odd.\n");
a. (num % 2) == 0 ? printf ("Even.\n") : printf ("Odd.\n");
b. (num % 2) = 0 ? printf ("Odd.\n") : printf ("Even.\n");
c. (num % 2) == 0 ? printf ("Odd.\n") : printf ("Even.\n");
d. (num % 2) = 0 : printf ("Even.\n") ? printf ("Odd.\n");
6. (Points: 4.0)
Assume the design below. Which conditions must be met in order for this person to get a car. Choose all that apply.
if ( (you complete your degree in 4 years) && (you get a job) ) then
You will get a car.
a. Person must get a job.
b. Person must take the summer off.
c. Person must complete degree in 4 years.
d. Person can complete degree in 3 years.
7. (Points: 4.0)
Based on the values of condition 1 and condition 2 (T = True, F = False), fill in the remainder of the truth table below with T's or F's.
Condition1 Condition2 Cond. 1 && Cond. 2 Cond. 1 || Cond. 2
F F Fill in the Blank 01 Fill in the Blank 02
F T Fill in the Blank 03 Fill in the Blank 04
T F Fill in the Blank 05 Fill in the Blank 06
T T Fill in the Blank 07 Fill in the Blank 08
Fill blanks above with correct T or F values.
8. (Points: 4.0)
Which C statement below causes the program to immediately exit from a loop, but continue processing the remainder of code in the program (if any).
a. break;
b. continue;
c. stop;
d. exit;
9. (Points: 4.0)
Which C statement below causes any statements following it in the body of the loop to be skipped, but allows the next iteration of the loop to be processed.
a. goto;
b. continue;
c. exit;
d. break;
10. (Points: 4.0)
What is output from the following code segment:
for (x = 1; x <= 5; x++)
{
if (x != 3)
break;
printf ("%i ", x);
} /* end for loop */
printf ("Marvelous");
1.
11. (Points: 4.0)
What is output from the following code segment:
for (x = 1; x <= 5; x++)
{
if (x != 3)
continue;
printf ("%i ", x);
} /* end for loop */
printf ("Greetings");
1.
12. (Points: 4.0)
A group of contiguous memory locations related by the fact that they all have the same name and the same data type is knows as:
a. a file.
b. an array.
c. a variable.
d. a function.
13. (Points: 4.0)
What is wrong with the following while loop if the intention is to print out "C is fun! twice? (Hint: it is a syntax error.)
int count = 1;
while (count <= 2);
{
printf ("C is fun!\n");
printf ("%i\n", count);
}
14. (Points: 4.0)
How many elements does array grades[5] have?
a. 4
b. 5
c. 3
d. 6
15. (Points: 4.0)
How do we refer to the second element of the following array:
int grades[3];
a. grades[0]
b. grades[3]
c. grades[2]
d. grades[1]
16. (Points: 4.0)
What is the value of nums[3] after the following code segment is executed?:
int nums[4];
nums[1] = 10;
nums[2] = 11 + nums[1];
nums[3] = nums[1] + nums[2];
Please provide the integer value of what is stored in variable nums[3] at this point in the program.
17. (Points: 4.0)
Which of the following statements initializes the entire array nums[4] to zero? (Choose all that apply, look very closely!):
a. int nums[4] = {0, 0, 0, 0};
b. for (i = 0, i < 4, i++) { nums = 0; }
c. int nums[4] = {0};
d. int nums[ ] = {0,0,0,0};
18. (Points: 4.0)
To declare array my_values to contain a maximum of 10 floating point numbers, the correct declaration would be:
a. float my_values[10];
b. float my_values[] = {1,2,3,4,5,6,7,8,9};
c. float my_values[9];
d. float my_values[11];
19. (Points: 4.0)
What is output from the following code segment?
int num = 1;
while (num = 60). Please make the change right in the code itself.
#include
void main (void)
{
int grade;
printf ("Enter student grade: ");
scanf ("%i", &grade);
if (grade >= 60)
printf ("You passed.\n");
printf ("Good job\n");
else
printf ("You failed\n");
}
24. (Points: 4.0)
Using the following program, what would be output based on the user input shown below. Please place your answer where indicated in the box below.
#include
void main (void)
{
char feel;
printf ("How do you feel (G=Good, S=Sick, T=Tired): ");
scanf ("%c", &feel);
switch (feel)
{
case 'S': printf ("Take 2 asprin.\n");
printf ("Call me in the morning.\n");
break;
case 'T': printf ("Don't stay up late.\n");
printf ("Get some sleep!\n");
break;
case 'G': printf ("I'm glad for you.\n");
break;
default: printf ("**Invalid Feeling**");
break;
}
} /* end main */
Program execution #1:
How do you feel (G=Good, S=Sick, T=Tired): S
(The user entered "S")
Program output would be:
Program execution #2:
How do you feel (G=Good, S=Sick, T=Tired): R
(The user entered "R")
Program output would be:
25. (Points: 4.0)
What is output from the following code segment?
float num = 1.1;
do
{
printf ("%.1f \n", num);
num = num + .2;
} while (num < 2);
Need Solution https://gum.co/Bczbm
printf("Please enter three numbers: \n");
scanf ("%i%i%i", &x,&y);
a. 1 value
b. 0 values
c. 2 values
d. 3 values
2. (Points: 4.0)
What is output from the following code segment:
int x = 2, num;
while (x < 6)
{
num = x * x;
printf ("%i\n", num);
x++;
}
3. (Points: 4.0)
How would the last line of the following code segment need to be modified for the average calculation below to be correct? (Note: this is not an entire program just a code segment.) Modify the code in the box below.
int average;
float total = 100, number = 27;
average = total/number;
4. (Points: 4.0)
It is common to confuse the equality operator with the assignment operator because the assignment operator looks like ____ and the equality operator looks like____
5. (Points: 4.0)
Which statement below is equivalent to the following code segment:
if ( ( num % 2) == 0 )
printf ("Even.\n");
else
printf ("Odd.\n");
a. (num % 2) == 0 ? printf ("Even.\n") : printf ("Odd.\n");
b. (num % 2) = 0 ? printf ("Odd.\n") : printf ("Even.\n");
c. (num % 2) == 0 ? printf ("Odd.\n") : printf ("Even.\n");
d. (num % 2) = 0 : printf ("Even.\n") ? printf ("Odd.\n");
6. (Points: 4.0)
Assume the design below. Which conditions must be met in order for this person to get a car. Choose all that apply.
if ( (you complete your degree in 4 years) && (you get a job) ) then
You will get a car.
a. Person must get a job.
b. Person must take the summer off.
c. Person must complete degree in 4 years.
d. Person can complete degree in 3 years.
7. (Points: 4.0)
Based on the values of condition 1 and condition 2 (T = True, F = False), fill in the remainder of the truth table below with T's or F's.
Condition1 Condition2 Cond. 1 && Cond. 2 Cond. 1 || Cond. 2
F F Fill in the Blank 01 Fill in the Blank 02
F T Fill in the Blank 03 Fill in the Blank 04
T F Fill in the Blank 05 Fill in the Blank 06
T T Fill in the Blank 07 Fill in the Blank 08
Fill blanks above with correct T or F values.
8. (Points: 4.0)
Which C statement below causes the program to immediately exit from a loop, but continue processing the remainder of code in the program (if any).
a. break;
b. continue;
c. stop;
d. exit;
9. (Points: 4.0)
Which C statement below causes any statements following it in the body of the loop to be skipped, but allows the next iteration of the loop to be processed.
a. goto;
b. continue;
c. exit;
d. break;
10. (Points: 4.0)
What is output from the following code segment:
for (x = 1; x <= 5; x++)
{
if (x != 3)
break;
printf ("%i ", x);
} /* end for loop */
printf ("Marvelous");
1.
11. (Points: 4.0)
What is output from the following code segment:
for (x = 1; x <= 5; x++)
{
if (x != 3)
continue;
printf ("%i ", x);
} /* end for loop */
printf ("Greetings");
1.
12. (Points: 4.0)
A group of contiguous memory locations related by the fact that they all have the same name and the same data type is knows as:
a. a file.
b. an array.
c. a variable.
d. a function.
13. (Points: 4.0)
What is wrong with the following while loop if the intention is to print out "C is fun! twice? (Hint: it is a syntax error.)
int count = 1;
while (count <= 2);
{
printf ("C is fun!\n");
printf ("%i\n", count);
}
14. (Points: 4.0)
How many elements does array grades[5] have?
a. 4
b. 5
c. 3
d. 6
15. (Points: 4.0)
How do we refer to the second element of the following array:
int grades[3];
a. grades[0]
b. grades[3]
c. grades[2]
d. grades[1]
16. (Points: 4.0)
What is the value of nums[3] after the following code segment is executed?:
int nums[4];
nums[1] = 10;
nums[2] = 11 + nums[1];
nums[3] = nums[1] + nums[2];
Please provide the integer value of what is stored in variable nums[3] at this point in the program.
17. (Points: 4.0)
Which of the following statements initializes the entire array nums[4] to zero? (Choose all that apply, look very closely!):
a. int nums[4] = {0, 0, 0, 0};
b. for (i = 0, i < 4, i++) { nums = 0; }
c. int nums[4] = {0};
d. int nums[ ] = {0,0,0,0};
18. (Points: 4.0)
To declare array my_values to contain a maximum of 10 floating point numbers, the correct declaration would be:
a. float my_values[10];
b. float my_values[] = {1,2,3,4,5,6,7,8,9};
c. float my_values[9];
d. float my_values[11];
19. (Points: 4.0)
What is output from the following code segment?
int num = 1;
while (num = 60). Please make the change right in the code itself.
#include
void main (void)
{
int grade;
printf ("Enter student grade: ");
scanf ("%i", &grade);
if (grade >= 60)
printf ("You passed.\n");
printf ("Good job\n");
else
printf ("You failed\n");
}
24. (Points: 4.0)
Using the following program, what would be output based on the user input shown below. Please place your answer where indicated in the box below.
#include
void main (void)
{
char feel;
printf ("How do you feel (G=Good, S=Sick, T=Tired): ");
scanf ("%c", &feel);
switch (feel)
{
case 'S': printf ("Take 2 asprin.\n");
printf ("Call me in the morning.\n");
break;
case 'T': printf ("Don't stay up late.\n");
printf ("Get some sleep!\n");
break;
case 'G': printf ("I'm glad for you.\n");
break;
default: printf ("**Invalid Feeling**");
break;
}
} /* end main */
Program execution #1:
How do you feel (G=Good, S=Sick, T=Tired): S
(The user entered "S")
Program output would be:
Program execution #2:
How do you feel (G=Good, S=Sick, T=Tired): R
(The user entered "R")
Program output would be:
25. (Points: 4.0)
What is output from the following code segment?
float num = 1.1;
do
{
printf ("%.1f \n", num);
num = num + .2;
} while (num < 2);
Need Solution https://gum.co/Bczbm