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
In this unit, you developed your skills at coding in Python. In this lab, you will put those skills to work by creating a progra
Arturiano [62]

Answer:

Don't forget to close any parentheses you open. Other then that everything looks fine, I just polished it a little bit

Explanation:

name = input("What is your first name? ")

print("Hello", name)

age = int(input("How old are you? "))

print("In 10 years you will be", (age+10))

print("In 20 years you will be", (age+20))

print("5 years ago you were", (age-5))

5 0
3 years ago
Read 2 more answers
Try to crack the code:
ololo11 [35]

Answer:001101110010010100011011010110010011100100100000001100100100110001000010001101100100010100100000001101100100100001010001010101001101001010

Explanation:

i copied

3 0
2 years ago
A form of Internet identity theft involving phony e-mail messages asking customers to update their credit card numbers, account
irina [24]

Answer: Phishing

Explanation:

Phishing is a form of identity theft involving phony email messages asking customers to update credit, debit, cards, accounts passwords, and all whole of personal information. It is still one of the relevant form of identity theft whereby personal information is taken away in form of electronic communication or messages.

One example could be when a person receives a mail from xyz.com and ask him/her to click on a page. upon clicking on it the person will be redirected to another page. in that page several details would be there such as username and password, bank account details. So once all these details are entered in the web page all our personnel information will leaked into the servers of the hackers and could lead to serious troubles. Sometimes phishing is also in form of fake social networking website which resembles exactly to that of the original one.

So Phishing is a for of identity theft.

3 0
3 years ago
How do I make Dank memes
Dmitrij [34]

Well bro you see what you gotta do is be a gamer.

HIT OR MISS

I GUESS THEY NEVER MISS

H U H ?

YOU GOT A BF?

I BET HE DOESNT KISS YA

M U A H


It be like that sometimes b r u h

6 0
3 years ago
Read 2 more answers
Complete the sentence.<br> The IP protocol creates and addresses packets at the _____ layer.
brilliants [131]
Addresses packets at the internet layer
4 0
3 years ago
Read 2 more answers
Other questions:
  • Consider the following method.
    13·1 answer
  • What action makes RAM on your computer disappear?
    12·2 answers
  • You are developing a system to process lists of days of the week, represented as strings. Create a function is_weekend that cons
    12·1 answer
  • What is a single-user computer?
    8·1 answer
  • What is the difference between player-centric game design and designer-centric game design? How does a player-centric game assis
    7·1 answer
  • Individual internet users connect to isps through a(n ________.
    11·1 answer
  • I am doing 7th grade coding 3.02 assignment can anybody help me it says bad input on line 3 and this is what it is can someone h
    6·1 answer
  • How many voltage values can be represented with a 10-bit binary code?
    15·1 answer
  • HELPPP PLEASE <br><br> Html can be used to create complicated mobile applications <br> True or false
    10·1 answer
  • 2. When you establish a connection to a remote host using Remote Desktop Connection, what appears at the top of the screen that
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!