Question

Assuming that a user enters 64 as his marks obtained, what is the output of the...

Assuming that a user enters 64 as his marks obtained, what is the output of the following code snippet? int main() { int score = 0; cout << "Enter your score: "; cin >> score; if (score < 40) { cout << "F" << endl; } else if (score < 50) { cout << "D" << endl; } else if (score < 60) { cout << "C" << endl; } else if (score < 70) { cout << "B" << endl; } else if (score < 80) { cout << "B+" << endl; } else { cout << "A" << endl; } return 0; }

a) D b) C c) B d) A

Homework Answers

Answer #1

Answer is option C) B

Here, this program is executing if else if statements for finding out the grade according to user input.

When a user enters 64,

1-> if(score < 40), then it will not be true, so next will be implemented.

2-> else if (score < 50), then it will not be true, so next will be implemented.

3-> else if (score < 60), then it will not be true, so next will be implemented.

4-> else if (score < 70), since, score is 64, so this statement will be true, and hence, cout << "B" will be implemented.

Which will give us output B.

So, answer is C) B

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
When the user enters 2 the following program segment should print the message “You’ve selected to...
When the user enters 2 the following program segment should print the message “You’ve selected to get an A”, however it always prints “You’ve selected to get a C”. Rewrite the code segment to behave properly, i.e., print the proper message: int selection; cout << “Please enter the grade you would like to receive “ << endl; cout << “1 = C, 2 = A”; cin >> selection; if (selection = 1) cout << “You’ve selected to get a C“...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double secondQuizz; double midTerm; double finalTerm; string name; }; int main() { int n; cout<<"enter the number of students"<<endl; cin>>n; struct student students[n]; int i; struct student istudent; for(i=0;i<n;i++) {    cout<<"Student name?"; cin >> istudent.name; cout<<"enter marks in first quizz , second quizz , mid term , final term of student "<<i+1<<endl; cin>>students[i].firstQuizz>>students[i].secondQuizz>>students[i].midTerm>>students[i].finalTerm; } for(i=0;i<n;i++) { double marks=0; double score=students[i].firstQuizz+students[i].secondQuizz+students[i].midTerm+students[i].finalTerm; marks=(students[i].firstQuizz*0.25)+(students[i].secondQuizz*0.25)+(students[i].midTerm*0.25)+(students[i].finalTerm*0.50); double totalArrgegateMarks =...
Consider the following program: #include #include #include using namespace std; int main() { int num1; int...
Consider the following program: #include #include #include using namespace std; int main() { int num1; int num2; cout << fixed << showpoint << setprecision(2); cout << "Enter two integers: "; cin >> num1 >> num2; cout << endl; if (num1 != 0 && num2 != 0) cout << sqrt(abs(num1 + num2) + 0.5) << endl; else if (num1 != 0) cout << floor(num1 + 0.5) << endl; else if (num2 != 0) cout << ceil(num2 + 0.5) << endl; else...
Utilize the code from last week Add a default, full, and copy constructor. Also add a...
Utilize the code from last week Add a default, full, and copy constructor. Also add a constructor that allows you to specify only the name of the video game with no high score or times played specified. Adjust your code to demonstrate use of all 4 constructors and output of the resulting objects. #include <iostream> #include <string> #include <iomanip> using namespace std; class VideoGame { private:     string name;     int highScore;     int numOfPlays; public:     VideoGame() {        ...
im trying to make a program that will use a while loop to repeatedly ask a...
im trying to make a program that will use a while loop to repeatedly ask a user for a test score. Use a counter to exit the loop when the user has entered 10 test scores. The loop is to figure out the total of all the scores and the highest score. it must use a while loop please explain problems in code the bottom code is my work done but does not work. #include <iostream> using namespace std; int...
Write a program that prompts the user to input a string and outputs the string in...
Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use dynamic arrays to store the string.) my code below: /* Your code from Chapter 8, exercise 5 is below. Rewrite the following code to using dynamic arrays. */ #include <iostream> #include <cstring> #include <cctype> using namespace std; int main() { //char str[81]; //creating memory for str array of size 80 using dynamic memory allocation char *str = new char[80]; int len;...
How to stop the program from exiting after display detail. When there is food detail, it...
How to stop the program from exiting after display detail. When there is food detail, it will display and exit the program. What can i do to make it not exit the program and back to main menu. #include <iostream> #include <iomanip> #include<string.h> using namespace std; struct food{ int order_id; string food_code,flavor,customer_id; string address,name; int weight,unit_price,qty,contact_number; struct food *next; };    class Foodsystem{ food *head,*temp,*temp2,*end; static int id;    public: Foodsystem(){ head=NULL;end=NULL;} void Place_Order(); void View_food_details(); void Modify_food_details(); void Delete_food_details();...
C++ Write a program which accepts a numeric test score from the user. It will output...
C++ Write a program which accepts a numeric test score from the user. It will output the letter grade to the user corresponding to the score. Assume no “minus grades” (an A ranges from 90-100, B ranges from 80-89, C ranges from 70-79, D ranges from 60-69 and F is everything else.) Ensure that the score remains in the range of 0 to 100. As an example of the output: Enter your numeric grade and I will tell you your...
How do I break down a user inputted integer to individual digits and store it into...
How do I break down a user inputted integer to individual digits and store it into my array? I have an if statement that compares the spots of the array to check if it is a palindrome, but I need to make it so the user inputted number is broken up individually into the array. Please break it down into steps so I can understand. #include<iostream> using namespace std; int main() {    char array[6];           cout <<...
Write a program that reads a string and outputs the number of lowercase vowels in the...
Write a program that reads a string and outputs the number of lowercase vowels in the string. Your program must contain a function with a parameter of a char variable that returns an int. The function will return a 1 if the char being passed in is a lowercase vowel, and a 0 for any other character. The output for your main program should be: There are XXXX lowercase vowels in string yyyyyyyyyyyyyyyyyyyyyy Where XXXX is the count of lowercase...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT