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
Shalnov [3]
3 years ago
13

Write any three type of looping structure with syntax​

Computers and Technology
1 answer:
schepotkina [342]3 years ago
7 0

Answer:

The correct answer to this question is given below in the explanation section.

Explanation:

There are three types of loops that are used almost in all programming languages today. Loop is used when you want to execute many times the same lines of codes.  These loops are given below:

For-loop

While-loop

Do-while loop

The syntax of these loops is given below. However, it is noted that these syntax are based on C++ language.  :

1-For-loop:

<em>for ( init; condition; increment/decrement ) { </em>

<em>   statement(s); </em>

<em>}</em>

init: this is executed first and only once, this allows to initialize and declare the loop control variable.

Condition: next condition is evaluated, if the condition is true then the loop body will get executed. And, if it gets false, the loop will get terminated.

increment: this will increment/decrement the counter (init) in the loop.

for example: to count number 1 to 10, the for-loop is given below:

<em>int total=0;</em>

<em>for (int i=0; i>10;i++)</em>

<em>{</em>

<em>total=total + i;</em>

<em>to</em>

<em>}</em>

2-While loop:

Repeats a statement or group of statements in the body of a while-loop while a given condition is true. It tests the given condition before executing the loop body.

syntax:

<em>while(condition) { </em>

<em>   statement(s); </em>

<em>}</em>

For example: To count number 0 to 10.

<em>int a = 0;  </em>

<em>int total =0;</em>

<em>   // while loop execution </em>

<em>   while( a < 11 ) { </em>

<em>      total = total + a</em>

<em>      a++; </em>

<em>   }</em>

<em />

3- do-while loop:

Do-while works like a while statement, while it tests the condition at the end of the loop body.

Syntax:

<em>do { </em>

<em>   statement(s); </em>

<em>}  </em>

<em>while( condition );</em>

<em />

For example:

<em>int a = 0;  </em>

<em>int total =0;</em>

<em>   // while loop execution </em>

<em>   do { </em>

<em>      total = total + a</em>

<em>      a++; </em>

<em>   }while( a < 11 )</em>

<em />

You might be interested in
Write an algorithm to sum to values
Elis [28]

Answer:

There is no need to make an algorithm for this simple problem. Just add the two numbers by storing in two different variables as follows:

Let a,b be two numbers.

c=a+b;

print(c);

But, if you want to find the sum of more numbers, you can use any loop like for, while or do-while as follows:

Let a be the variable where the input numbers are stored.

while(f==1)

{

printf(“Enter number”);

scanf(“Take number into the variable a”);

sum=sum+a;

printf(“Do you want to enter more numbers? 1 for yes, 0 for no”);

scanf(“Take the input into the variable f”);

}

print(Sum)

Explanation:

hi there answer is given mar me as brainliest

5 0
3 years ago
Which term means a cryptography mechanism that hides secret communications within various forms of data?.
andrezito [222]

Answer:

anything u have daling

Explanation:

6 0
2 years ago
100 POINTS FOR ANYONE WHO CAN DO THIS!
Nataly [62]

Let's check what can be modified

Before calling def we need adjective and conjunctions stored inside variables

Store them(You may change according to your choice)

\tt adjectives=("foolish","bad","long","hard")

\tt conjunctions=("and","but","for","after")

We have to make optional ,easy way ask the user to do instead of yourself .

\tt con=input("Enter\: yes\: if \:you \:want \:to \:use \:conjunctions:")

\tt adj=input("Enter\:yes\:if\:you\:want\:to\:use\: adjectives:")

If they click then we can proceed else no problem let the program run

\tt def\: conjunctionPhrase():

\quad\tt if\: con=="yes":

\quad\quad\tt return\:random.choice(conjunctions)+"\:"+nounPhrase()

\quad\tt else:

\quad\quad\tt continue

  • You may use pass also

\tt def\: adjectivePhrase():

\quad\tt if\:adj=="yes":

\quad\quad\tt return\:random.choice(adjectives)+"\:"+nounPhrase()

\quad\tt else:

\quad\quad\tt continue

4 0
2 years ago
Which of the following is a best practice regarding the Administrator account?
lara31 [8.8K]

Answer:

B. The account should be given a nondescript account name that cannot be easily guessed.

3 0
3 years ago
The part of the computer that performs the calculations that enable the computer to function and is sometimes referred to as the
VMariaS [17]
CPU, the central processing unit, can take and understand instructions and output a result according to its instructions. A core component of a CPU is the APU, an arithmetic processing unit, this is responsible for all mathematical calculations and comparisons.    <span />
6 0
3 years ago
Read 2 more answers
Other questions:
  • Var cookie = "username=mike2009";
    10·1 answer
  • what is the primary way to access applications in windows 8? a. control panel b. start menu c. desktop tiles d. context menu
    7·1 answer
  • In Python,The sum of the elements in a tuple can be recusively calculated as follows:The sum of the elements in a tuple of size
    5·1 answer
  • Why Embedded operating systems are also known as real-time operating systems (RTOS)?
    15·1 answer
  • What is a ribbon in word
    15·2 answers
  • Uuhdcnkhbbbbhbnbbbbnnnnnnnnnfddjkjfs
    14·1 answer
  • Find what the secret message is. Get Brainliest if you are fast and correct.
    13·2 answers
  • Need answer ASAP.
    8·1 answer
  • Can someone help me with python
    10·1 answer
  • What are the benefits and drawbacks of a desktop utilising virtualisation and a server?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!