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
4vir4ik [10]
4 years ago
5

Write a program that tests whether an integer is a prime number.

Chemistry
1 answer:
Alika [10]4 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int main() {

   int n;

   cin>>n;//taking input form the user.

   bool b=true;

   for(int i=2;i<n;i++)//looping

   {

       if(n%i==0)//checking that i divides n.

       {

           cout<<"The number is not prime";

           b=0;

           break;

       }

   }

   if(b)

   {

       cout<<"The number is prime";

   }

return 0;

}

Input:-

23

Output:-

The number is prime.

Explanation:

The above written program is in C++.First I have declared an integer n.Then taking input form the user and storing it in n abd also declared a boolean variable with value true.Then I have used a for loop for checking n is divisible by any number from 2 to n-1 if it is then printing the message of not prime,making the value of b to false and coming out of the loop.out of the loop if the value of the b is true then printing the number is prime.

You might be interested in
A laboratory technician combined sodium hydroxide with excess iron(II) nitrate. A reaction took place according to this chemical
Whitepunk [10]

 The initial  mass  of sodium hydroxide  is  3.3 g (answer C)

 <u><em>calculation</em></u>

Step 1 : find the  moles of iron (ii) hydroxide (  Fe(OH)₂

moles =  mass÷  molar mass

from periodic table the  molar mass of Fe(OH)₂  = 56 + [16 +1]2  = 90 g/mol

moles  is therefore = 3.70 g÷ 90 g/mol = 0.041 moles

Step 2:  use the mole ratio to  calculate the moles of  sodium hydroxide (NaOH)

   from given equation  NaOH : Fe(OH)₂    is 2 :1

therefore the moles of NaOH = 0.041 x 2 = 0.082 moles

Step 3: find  mass of NaOH

mass = moles x molar mass

from the periodic table the  molar mass of NaOH = 23 +16 +1  = 40 g/mol

mass  = 0.082  moles x 40 g/mol = 3.3 g ( answer C)


8 0
4 years ago
Why do we use 51.0mL of NaOH but only 50.0mL of HCl?
bixtya [17]

Answer

Na OH reacts with H Cl and forms Na Cl and H₂O

NaOH + HCl   →   NaCl + H₂O                                              

Here we can see that  1 mole of NaOH reacting with 1 mole of HCl and forming 1 mole of NaCl and 1 mole of H₂O

when  NaOH and HCl are added together in equal amount then they will completely neutralize each other but NaOH is hygroscopic in nature which means it can absorb water from air so it will not be weighted accurately.

hence, for neutralization we will take extra NaOH.

3 0
3 years ago
A solution has a hydrogen ion concentration of 0.001 M, what is the pH of the solution
LenKa [72]
PH= −log
10
​
[H
+
]
= −log
10
​
(0.001)
= −log
10
​
(10
−3
)
= −(−3)log
10
​
10
pH=3.
01
4 0
3 years ago
What is orbital theory of bonding in metals
lianna [129]
Metals of Group 1 donate 1 electron from its ns orbital to form ionic bond, where n is the no. of its outermost shell. 
Metals of Group 2<span> donate 2 electrons from its ns orbital to form ionic bond, where n is the no. </span>of its <span>outermost shell. </span>
5 0
3 years ago
To explain the photoelectric effect, Albert Einstein linked the photoelectric effect to an idea from which scientist?
Georgia [21]
Max planck
hope i helped!
7 0
3 years ago
Read 2 more answers
Other questions:
  • Identify this reaction.
    12·1 answer
  • How is the solubility of carbon dioxide gas in water increased?
    9·2 answers
  • What property do all types of waves share?
    14·1 answer
  • What is the name of the binary compound that has the formula k2s?
    6·1 answer
  • Which of the following will increase the volume of a gas?
    7·1 answer
  • Is this a scientific model? Use complete sentences to explain why or why not. (5 points)
    6·1 answer
  • A certain type of decorative lamp contains colored liquids. These liquids form globs that break off and rise to the top of the l
    10·1 answer
  • 5. Which of the following materials
    10·1 answer
  • In a chemical reaction the mass of the products should be
    9·1 answer
  • A student sets up a box with a flashlight that shines on a mirror located at position X. Other possible locations for objects in
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!