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
10

Write a loop to print 10 to 90 inclusive (this means it should include both the

Computers and Technology
1 answer:
Semmy [17]3 years ago
8 0

Answer:

The loop in cpp language is as follows.

for(int n=10; n<=90; n++)

{

cout<<n<<" ";

count = count+1;

if(count==10)

{

cout<<""<<endl;

count=0;

}

}

Explanation:

1. The expected output is obtained using for loop.

2. The loop variable, n is initialized to the starting value of 10.

3. The variable n is incremented by 1 at a time, until n reaches the final value of 90.

4. Every value of n beginning from 10 is displayed folllowed by a space.

5. When 10 numbers are printed, a new line is inserted so that every line shows only 10 numbers.

6. This is achieved by using an integer variable, count.

7. The variable count is initialized to 0.

8. After every number is displayed, count is incremented by 1.

9. When the value of count reaches 10, a new line is inserted and the variable count is initialized to 0 again. This is done inside if statement.

10. The program using the above loop is shown below along with the output.

PROGRAM

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   int count=0;

   for(int n=10; n<=90; n++)

   {

       cout<<n<<" ";

       count = count+1;

       if(count==10)

       {

           cout<<""<<endl;

           count=0;

       }

       

   }

   return 0;

}  

OUTPUT

10 11 12 13 14 15 16 17 18 19  

20 21 22 23 24 25 26 27 28 29  

30 31 32 33 34 35 36 37 38 39  

40 41 42 43 44 45 46 47 48 49  

50 51 52 53 54 55 56 57 58 59  

60 61 62 63 64 65 66 67 68 69  

70 71 72 73 74 75 76 77 78 79  

80 81 82 83 84 85 86 87 88 89  

90

1. In the above program, the variable count is initialized inside main() but outside for loop.

2. The program ends with a return statement since main() has return type of integer.

3. In cpp language, use of class is not mandatory.

You might be interested in
) What is the ""Phantom Inspector""? (
matrenka [14]

Answer:

 Phantom inspection is the process of finding various defects in the documents according to the . Basically, it is a group of meeting that usually provide the synergy effects and the maximum defects can easily be detected. This entire process is known as phantom inspector.  

It is also made some assumptions regarding the inspection that is made by one and more than one individual.

This process are usually done by inspecting the each operation output with the given output requirements.

4 0
2 years ago
A____consists of many users and their information.​
grin007 [14]

<u>Active Directory</u> consist of many users and their information.

7 0
1 year ago
Read 2 more answers
Implement the function fileSum. fileSum is passed in a name of a file. This function should open the file, sum all of the intege
maria [59]

Answer:

/*C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program */

//header files

#include <fstream>

#include<string>

#include <iostream>

#include <cstdlib> //needed for exit function

using namespace std;

//function prototype

int fileSum(string filename);

int main()

{

string filename;

cout << "Enter the name of the input file: ";

cin >> filename;

cout << "Sum: " << fileSum(filename) << endl;

system("pause");

return 0;

}

/*The function fileSum that takes the string filename and

count the sum of the values and returns the sum of the values*/

int fileSum(string filename)

{

//Create a ifstream object

ifstream fin;

//Open a file

fin.open(filename);

//Initialize sum to zero

int sum=0;

//Check if file exist

if(!fin)

{

cout<<"File does not exist ."<<endl;

system("pause");

exit(1);

}

else

{

int value;

//read file until end of file exist

while(fin>>value)

{

sum+=value;

}

}

return sum;

}//end of the fileSum

Explanation:

This is a C++ program that prompts user to enter the name of input file(input.txt in this example) and print the sum of the values in the file to console. If file dosnot exist, then close the program.

Check attachment for sample output screenshot.

5 0
3 years ago
Hardware failure, power outages, and DOS attacks will affect:
const2013 [10]

Answer:

The answer should be data availability

6 0
3 years ago
What should htc's os strategy be? should it stick with windows mobile and android? should htc build its own platform? add/drop o
rosijanka [135]

I say windows, since it is very common.

8 0
3 years ago
Other questions:
  • Which reading strategy refers to reading only the key words and phrases?
    13·2 answers
  • What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
    9·2 answers
  • Which is not an element of photography? a Cropping b Height c Directional Lighting d Framing
    11·1 answer
  • In order for Dr. Reynolds to send a CPOE from her office computer system to the computer system at the local hospital, a/an ____
    5·1 answer
  • Which if the following ribbons in Microsoft word is used to add tables and images
    14·1 answer
  • Which words in the sentence make up the adjective phrase? Which word does the adjective phrase modify? The farmer delivers five
    15·1 answer
  • Cryptography has requirements include:
    8·1 answer
  • WILL GIVE BRAINLIEST ANSWER!!!<br><br> How do you manage your screen time?
    8·2 answers
  • Hey should I get a r()blox gift card if so what amount 5 dollars 10 or 100
    14·1 answer
  • Search the Web for three different employee hiring and termination policies. Review each and look carefully for inconsistencies.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!