179k views
1 vote
Write a procedural programming loop.. Your loop should start variable n with a value of 10 and count down to zero. The loop should terminate when n reaches the value of zero.

User Wheezil
by
5.1k points

1 Answer

3 votes

Answer:

//Here is the for loop in C.

for(n=10;n>0;n--)

{

printf("count =%d \\",n);

}

Step-by-step explanation:

Since C is a procedural programming language.Here if a loop that starts with n=10; It will run till n becomes 0. When n reaches to 0 then loop terminates otherwise it print the count of n.

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{ // variables

int n;

// for loop that runs 10 times

// when n==0 then loop terminates

for(n=10;n>0;n--)

{

cout<<"count ="<<n<<endl;

}

return 0;

}

Output:

count =10

count =9

count =8

count =7

count =6

count =5

count =4

count =3

count =2

count =1

User Sepster
by
5.2k points