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
Typically, when an organization purchases Internet access from an Internet Service Provider (ISP), the ISP will grant it
Radda [10]

Answer:

(B) A single public IP address that it can use for NAT

Explanation:

Because the IPV4 IP protocol is still used today, the number of available IP addresses is limited (only 4,294,967,296 addresses in the world), for this reason, the most correct practice is the assignment of a single public IP to those companies that acquire services from an ISP, with some few exceptional cases of companies that own several.

So that the company's addressing can be executed successfully, the use of NATs is enabled, this allows the translation of network addresses, allowing the company to have as many private networks as necessary and that these can be communicated Correctly with the global network, the Internet, through the public IP of the company.

4 0
4 years ago
Which tab will you use to format data in cells?
melamori03 [73]

Answer:

Right Click and select Format Cells (CTRL + 1)

Explanation:

To format cells in Excel, you select the cell(s) you want to format, right click, and in the dialogue box that appears select 'Format Cells'.

6 0
3 years ago
What is the answer to this question?
Helga [31]

Answer:

LoadFactorLimit >=1

Explanation:

The maximum Load factor limit allowed is equal to 1. And it cannot be greater than 1. And as the load factor limit is reached, the HashSet size is increased. And hence, the correct condition statement for this question is as mentioned above.

Remember the Load factor = number of keys stored in a HashSet divided by its capacity. And its maximum value cannot be more than 1.

7 0
3 years ago
Design a BCD-to-Gray code decoder. Your decoder will have 4 inputs: A, B, C and D, representing a 4-bit BCD code (A being the MS
ra1l [238]

Answer:

Binary to Gray Code Converter

The logical circuit which converts the binary code to equivalent gray code is known as binary to gray code converter. An n-bit gray code can be obtained by reflecting an n-1 bit code about an axis after 2n-1 rows and putting the MSB (Most Significant Bit) of 0 above the axis and the MSB of 1 below the axis.

The 4 bit binary to gray code conversion table is given in attached file.

3 0
3 years ago
Read 2 more answers
Which of these is an.optical medium of storage?
makkiz [27]
Do you have some answer choices?
8 0
3 years ago
Other questions:
  • What is the main function of the motherboard?
    12·1 answer
  • If you combine two cells into one, what action are you performing?
    12·2 answers
  • To open computer manger you would
    13·1 answer
  • Ano kaya ang nararamdaman mo at mangyari sayo kung tatlong araw ka nang hindi kumakain​
    6·1 answer
  • what program searches the Internet for specified keywords and returns a list of the pages where the keywords were found
    6·1 answer
  • C++ code pls write the code
    12·1 answer
  • Write a program that include a method that returns the sum of all the elements of a Linked List of Integers. Allow the user to e
    11·1 answer
  • Could u help me on this u just have to compare how its alike please help ​
    5·2 answers
  • Develop an algorithm and write a C++ program that finds the number of occurrences of a specified character in the string; make s
    12·1 answer
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!