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
Neko [114]
3 years ago
9

Write a program which promptsuser to enter an integer value. Using while loop print the valuesfrom

Computers and Technology
1 answer:
tino4ka555 [31]3 years ago
6 0

Answer:Following is the c++ code for the problem:

#include <iostream>

using namespace std;

int main() {

   int number;

   cout<<"Enter the number"<<endl;

   cin>>number;

   int i=0,c=0,odd[500];

   while(i<=number)//loop for printing the numbers form 0 to number.

   {

       cout<<i<<" ";

       if(i%2!=0)// storing in the odd array if the number is odd.

       {

           odd[c++]=i;//storing odd numbers..

       }

       i++;

   }

   cout<<endl;

   i=0;

   cout<<"The odd numbers are "<<endl;

   while(i<c)//loop to print the odd numbers.

   {

       cout<<odd[i]<<" ";

       i++;

   }

   cout<<endl<<"The prime numbers are "<<endl;

   i=0;

   int sum=0;

   

   while(i<c)//loop to print the prime numbers..

   {

       int div=2;

       while(div<odd[i])

       {

           if(odd[i]%div==0)

           break;

           div++;

       }

       if(div==odd[i])

      {

           cout<<odd[i]<<" ";

           sum+=odd[i];//updating the sum..

      }

       i++;

   }

   cout<<endl<<"The sum of odd prime numbers is "<<sum<<endl;//printing the sum..

return 0;

}

Output :

Enter the number

49

0 1 2 3 4 5 6 7 8 9 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  

The odd numbers are  

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49  

The prime numbers are  

3 5 7 11 13 17 19 23 29 31 37 41 43 47  

The sum of odd prime numbers is 326 .

Explanation:

First I have printed the values from 0 to n and i have taken an array to store odd numbers.After that i have printed the odd values.And after that i have printed prime numbers among the odd numbers and their sum. These all operations are done using while loop.

You might be interested in
Is the internet a private place?
Ludmilka [50]
Hey there!

No, the internet is not a private place

I hope this helped! :-)
8 0
3 years ago
Read 2 more answers
In 1971, Intel created and marketed the first microprocessor chip, called the Intel 4004. What was significant about this invent
PilotLPTM [1.2K]
The answer is D

<span>D) It allowed computers to be smaller because the chip allowed for the creation of computer components with varying capabilities.</span>
7 0
3 years ago
Write an expression that evaluates to true if and only if the string variable s does not equal the string literal end.
Marysya12 [62]
Which language is this in?

For Java,

if (s.equals("end"))
    return true;
7 0
3 years ago
I can talk to you! How about we talk through the you know where people comment and say stuff about the question1
pychu [463]
Hmmm what do you want to talk about??
3 0
3 years ago
Read 2 more answers
___ is the most important variable that is measured and controlled in a commercial hvac system.
Pavel [41]

The parameter being monitored and controlled is the controlled variable. The dry-bulb temperature of the air leaving the cooling coil is the controllable variable in this particular instance. The sensor assesses the state of the controlled variable and provides the controller with an input signal.

<h3>What is a HVAC ?</h3>

The employment of various technologies for heating, ventilation, and air conditioning is done to regulate the temperature, humidity, and cleanliness of the air in a closed environment. Its objective is to provide adequate indoor air quality and thermal comfort.

  • To cool or heat a building, the main unit of a ducted system forces air via a network of air ducts. On the other hand, ductless systems don't have air ducts and employ different techniques to spread cleaned air across a room.

Learn more about HVAC system here:

brainly.com/question/20264838

#SPJ4

6 0
2 years ago
Other questions:
  • Collins and quillian explained the results of priming experiments by introducing the concept of _____ into their network model.
    12·1 answer
  • A _____ is a search engine that combines internet technology with traditional library methods of cataloguing and assessing data.
    8·1 answer
  • ________ is the amount of data that can be transmitted across a transmission medium in a certain amount of time.
    15·1 answer
  • Suppose an initially-empty queue Q has performed a total of 32 enqueue operations, 10 front operations, and 15 dequeue operation
    14·1 answer
  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Ab
    11·1 answer
  • If the executives for Office Max LLC, a chain of office supply stores, developed the chain's objectives by asking buyers and sto
    11·1 answer
  • What is the creative nature of a computer<br> Help
    15·2 answers
  • Think of a genre (science, music, math, sports, video games, etc.) and create at least 10 questions. You can decide whether you
    12·2 answers
  • Explanation historical development of computer ​
    10·1 answer
  • Logistic Regression is a type of __________ problem.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!