Question

In: Computer Science

1.Write a loop to print a list of numbers starting at 64 and ending at 339....

1.Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.

2. Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.

Colour Message

Blue “No virus”

Yellow “Needs to be under observation”

Red “Needs to be admitted in COVID ward” 3.

Solutions

Expert Solution

Note: In the question, it not specified the language like c, c++ or java, etc so I write the c++ syntax

Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.

for (int i = 64 ; i<= 339 ; i++)  // Here is for loop which starts from 64
                                    // and runs upto 339
     
      {
          cout<<i<<endl;            // output statement to print the value of i
      }

2. Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.

Colour Message

switch(colour) // Here we make the switch statement and take color as an argument for matching case 
            
    {
      
      case Blue:              // if colour is blue the case blue will be executed
      cout<<"No virus"<<endl; // Here is output statement to print result of colour
      break;                  // Here is break statement to break the switch case after find the match
       
     
      case Yellow:             // if colour is Yellow the case blue will be executed
      cout<<"Needs to be under observation"<<endl; // Here is output statement to print result of colour
      break;                   // Here is break statement to break the switch case after find the match
    
      
      case Red:                 // if colour is red the case blue will be executed

      cout<<"Need to be admitted in COVID ward"<<endl; // Here is output statement to print result of colour

      break;                   // Here is break statement to break the switch case after find the match
     
      default:                 // Here is the default case for wrong input other than the desired input
      break;                   // Here is break statement which break the further operation 
                               // and get you out out of the switch statement
    } 

Note: Justification of each line of syntax wrote in front of that line after the double forward slash

Make sure to hit the like button if you find thid helpful for you THANK YOU AND HAPPY LEARNING!


Related Solutions

Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.(java language)
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax. in java
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a loop to print a list of numbers starting at 64 and ending at 339....
Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
Write a for-loop in MATLAB that generates a list of numbers such that each number is...
Write a for-loop in MATLAB that generates a list of numbers such that each number is the sum of the previous three. Initialize your list of numbers at the values of 0, 0 and 1. In other words, "0" is the first element of the list, "0" is the second element of the list, and "1" is the third element of the list. What is the 20th value in the list?
Please, write a loop to print odd numbers an array a with pointers backwards. You can...
Please, write a loop to print odd numbers an array a with pointers backwards. You can use a variable “size” for array size.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT