1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lostsunrise [7]
1 year ago
7

Write a C++ program to grade the answers to a true-false quiz given to students in a course. The quiz consists of 5 true-false q

uestions. Each correct answer is worth 2 points.
Computers and Technology
1 answer:
Eddi Din [679]1 year ago
7 0

The quiz program is an illustration of loops and conditional statements

  • Loops are used to perform repetition
  • Conditional statements are used to make decisions

<h3>The quiz program</h3>

The quiz program written in C++, where comments are used to explain each action is as follows:

#include <iostream>

using namespace std;

int main(){

   //This prints the instruction

   cout<<"Enter T/t for True; F/f for False\n";

   //This initializes the question

   string questions[5] = { "Q1", "Q2", "Q3", "Q4", "Q5"};

   //This initializes the correct options

   char options[5] = { 'T','T','F','F','T'};

   //This declares the user response

   char opt;

   //This initializes the score to 0

   int score = 0;

   //This loop is repeated 5 times

   for (int i = 0; i < 5; i++){

       //This prints the current question

       cout << i + 1 <<". "<<questions[i]<<"\nAnswer: ";

       //This gets the user response

       cin>>opt;

       //If the user response is correct

       if(toupper(opt) == options[i]){

           //The score is incremented by 2

           score+=2;

       }

   }

   //This prints the total score

   cout<<"Score: "<<score;

   return 0;

}

Read more about loops at:

brainly.com/question/19347842

You might be interested in
We have an internal webserver, used only for testing purposes, at IP address 5.6.7.8 on our internal corporate network. The pack
lukranit [14]

Answer:

Check the explanation

Explanation:

A packet filter firewall is used as a check point between internal corporate network to the outside internet. It blocks all the inbound traffic from the outside hosts trying to initiate a direct TCP connection to the internal corporate webserver. The network design with firewall is shown in the attached image below:

The figures in the attached image below shows an internal corporate network is protected with a packet filter firewall to minimize the inbound traffic from the external network or an internet. Therefore, the packet filter is used as a check point between the network.

The packet filter blocks all attempts by the outside hosts in order to initiate a direct TCP connection to the internal webserver of the internal corporate network.

Going by the second part of the attached image below can can therefore conclude that:

• Rule 1 specifies that, deny any packet with the destination address 5.6.7.8 if the STN flag of TCP header is set.

• Rule 2 specifies that, allow the inbound email traffic from the external source.

• Rule 3 specifies, allows the Outbound TCP traffic from the internal corporate network.

• Rule 4 specifies, allows outbound Email traffic from the internal corporate network to the external network.

• Rule 5 specifies, block any traffic from any source to the any destination.

3 0
3 years ago
Who is the father of computer​
r-ruslan [8.4K]

charles babbage is the father of computer's

3 0
3 years ago
Read 2 more answers
Which of the following is NOT one of the four steps preparing for sales forecast ?
ehidna [41]
Can you post the answers plz
4 0
3 years ago
(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted
denis-greek [22]

Answer:

Check the explanation

Explanation:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX_LIMIT 50

int checkComma(char *input)

{

int flag = 0;

for(int i = 0; i < strlen(input); i++)

{

if(input[i] == ',')

{

flag = 1;

break;

}

}

return flag;

}

int main(void)

{

char input[MAX_LIMIT];

char *words[2];

char delim[] = ", ";

printf("\n");

do

{

printf("Enter input string: ");

fgets(input, MAX_LIMIT, stdin);

size_t ln = strlen(input) - 1;

if (*input && input[ln] == '\n')

input[ln] = '\0';

if(strcmp(input, "q") == 0)

{

printf("Thank you...Exiting\n\n");

exit(1);

}

else

{

if(checkComma(input) == 0)

{

printf("No comma in string.\n\n");

}

else

{

char *ptr = strtok(input, delim);

int count = 0;

while(ptr != NULL)

{

words[count++] = ptr;

ptr = strtok(NULL, delim);

}

printf("First word: %s\n", words[0]);

printf("Second word: %s\n\n", words[1]);

}

}

}while(strcmp(input, "q") != 0);

return 0;

}

Kindly check the attached image below for the output.

4 0
3 years ago
Which invention provided instant communication and information to a massive audience for the first time?
igor_vitrenko [27]
B. Television. It provided <span>instant communication and information to a massive audience for the first time in 1927.

Hope this helps :)</span>
4 0
2 years ago
Read 2 more answers
Other questions:
  • You have a number of digital pictures you recently took on your smartphone. You would like to share these pictures with all of y
    11·1 answer
  • An alien from planet Tao has descended onto Earth.
    12·1 answer
  • How is a correction made to an Electronic health record?
    14·1 answer
  • What's the difference between intranet and extranet ​
    9·1 answer
  • An attacker compromises the Washington Post's web server and proceeds to modify the homepage slightly by inserting a 1x1 pixel i
    12·1 answer
  • A Layer 2 switch configuration places all its physical ports into VLAN 2. The IP addressing plan shows that address 172.16.2.250
    7·1 answer
  • [1] Please find all the candidate keys and the primary key (or composite primary key) Candidate Key: _______________________ Pri
    6·1 answer
  • What is the term for a set of actions carried out on inputs?
    7·1 answer
  • please help me to do this computer homework I beg you all please help me to get the answers please its important please ​
    12·1 answer
  • Short notes on primary key​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!