Question

5. Can I use logical conditions in a SWITCH statement? 6. Draw the information flow diagram...

5. Can I use logical conditions in a SWITCH statement?

6. Draw the information flow diagram (flowchart) for a FOR loop

7. Can the looping variable in a FOR loop be a decimal number such as 2.3 ?

8. Does the looping variable in a FOR loop always have to start from 1 ?

9. Why would someone use a WHILE loop instead of a FOR loop?

10. How can I check the time elapsed to execute a set of statements?

11. What is the difference between BREAK and CONTINUE?

12. How does MATLAB know that a control statement (such as IF-ELSE, FOR, etc) has ended?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans5.Yes. You can use logical conditions in a switch statement.

Ans6.Example of for loop:- for(i=2;i<=10;i=i+2){print(i)}
The flowchart of the for loop is given below.
start I =2 False True ? tuced Iritz (stop


Ans7.Yes. a looping variable in a for loop can be a decimal number such as 2.3

Ans8.No, it can be anything.


Ans9. a for loop runs for a pre-determined number of times.
if we know the number of times we want to run it, then we can use it.
but we only the pre-determined condition, then we should use while loop.
it will run until that condition occurs.



Ans10.in every language there are some predefined functions that you can use
like in c
t=clock()
then after 1 statement
t=clock()-t



Ans11.break and continue are used in loops.
if the condition says break then the program comes out of that loop.
if the condition says continue then program do not do anything else in the loop, it just goes for next iteration.




Ans12.we have to put end after completing if-else , for loop.
for example:
for i in range(0,n):
do something
end







If the answer helped please upvote it means a lot. For any query please comment.

Add a comment
Know the answer?
Add Answer to:
5. Can I use logical conditions in a SWITCH statement? 6. Draw the information flow diagram...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please explain what does each sentence mean and give an example if it’s possible?....

    Can you please explain what does each sentence mean and give an example if it’s possible?. I need to have answers for all of them please Assignment Statements- Input- cin >> Output--cout << endl<"n" Output formatting Arithmetic operators +-'* / % Relational Operators-=-= ++- Logical Operators ! && II Evaluating Expressions of mixed type Evaluating Boolean Expressions Type Conversion, Implicit Coersion Explicit-Type Casting Control Structure: Sequence, decision (branching), looping (repetition) if, if-else, if/else-if/else, nested ifs switch statement conditional statement while...

  • Question{04}: Which statement is true about "if" and "switch" statements? A. they can be used to...

    Question{04}: Which statement is true about "if" and "switch" statements? A. they can be used to control the flow of your code B. they can use combinations of logicals in their expression C. in some situations, they can be used interchangeably D. they can be used to selectively run lines of code based on a condition or expression E. all of the above Answer{04}=''; Reason{04}=''; Question{05}: Which statement is true about the "else" and "otherwise" A. an "else" is not...

  • Answer the following questions so I can double check my work Controls the flow of execution...

    Answer the following questions so I can double check my work Controls the flow of execution based on a condition begin...end try...catch goto if...else 10 points    QUESTION 2 Changes the database context to the specified database. set alter exec use 10 points    QUESTION 3 Exits the innermost WHILE loop. goto quit return break 10 points    QUESTION 4 Controls the flow of execution when an error occurs declare on error goto try...catch continue...error 10 points    QUESTION 5...

  • Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in th...

    using matlab Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in the decimal to octal program Introduction: In file systems on servers (think of websites like Google, Amazon, etc.), permission to access the files come from the octal number system. Given an octal quadruple, permissions are defined for the user, the group, and other as follows: Permission First Digit Second Digit Third Digit Fourth Digit Always 01 (User-u) 0 」(Group-g) | (Other-o) Read (r) Write...

  • How would this switch statement be modified to not use "continue"? This piece of code is...

    How would this switch statement be modified to not use "continue"? This piece of code is part of a larger assignment and that assignment prohibits the use of "continue" for switch statements. How do I modify this code so that it still does what I want it to do, without using "continue"? while (true) { choice = displayMenu(keyboard); switch (choice) { case 'D': case 'd': { courseStudents.displayStudentList();    continue; } case 'A': case 'a': { int id; double stGpa; System.out.println("Enter...

  • I am having trouble on what exactly to write so I can make the script work,...

    I am having trouble on what exactly to write so I can make the script work, can someone show how to properly do it? Use the vi editor to enter the following script (name this file testscript): #!/bin/bash #script to demonstrate : reading arguments from a command line & # interactively from within script # selection (if… then… else…. fi) # iteration (for loop) # USE FILES ENTERED ON THE COMMAND LINE echo The script you are running is $0...

  • Please do a flowchart which will be on the computer not on paper so i can...

    Please do a flowchart which will be on the computer not on paper so i can read it and be able to take screenshot for this c++ code this code for MasterMind //System Libraries #include <iostream> //Input/Output Library #include <cstdlib> #include <ctime> using namespace std; //User Libraries //Global Constants, no Global Variables are allowed //Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc... //Function Prototypes //main int main(int argc, char** argv) { //Set the random number seed srand(time(0)); int randomint = (rand()%5)+1;...

  • Having trouble with the do while/while loop and the switch statement. I got some of the...

    Having trouble with the do while/while loop and the switch statement. I got some of the switch statement but cant get the program to repeat itself like it should.What i have so far for my code is below. Any help is appreciated... i am not sure what I am doing wrong or what i am missing. I am completely lost on the while loop and where and how to use it in this scenario. import java.util.Scanner; public class sampleforchegg {...

  • using sql answer the following i need to double check my answers Question 1 Controls the...

    using sql answer the following i need to double check my answers Question 1 Controls the flow of execution based on a condition begin...end try...catch goto if...else 10 points Question 2 Changes the database context to the specified database. set alter exec use 10 points Question 3 Exits the innermost WHILE loop. goto quit return break 10 points Question 4 Controls the flow of execution when an error occurs declare on error goto try...catch continue...error 10 points Question 5 Declares...

  • Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping...

    Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping constructs (do and while loops) .Boolean expressions, bool and char types. 1. Develop a program that calculates charges for an Internet provider. The cost is determined by the amount of data used and the consumer plan. Package B (basic) is the most affordable if you plan on using < 20GB (20,000MB), however, if you consume more than 20GB (20,000MB) you are charged for each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT