Write a function named is_prime

Assignment Help C/C++ Programming
Reference no: EM13339028

A positive integer n is said to be prime (or, "a prime") if and only if n is greater than 1 and is divisible only by 1 and n . For example, the integers 17 and 29 are prime, but 1 and 38 are not prime. Write a function named "is_prime" that takes a positive integer argument and returns as its value the integer 1 if the argument is prime and returns the integer 0 otherwise. Thus, for example,

cout << is_prime(19) << endl; // will print 1
cout << is_prime(1) << endl; // will print 0
cout << is_prime(51) << endl; // will print 0
cout << is_prime(-13) << endl; // will print 0

Reference no: EM13339028

Questions Cloud

Why are academic health centers are vital : Why are academic health centers are vital to research and technology? give 3 examples
What is the output of the loop as it is written : Correct the syntax of the loop so that the logic of the corrected loop corresponds to the formatting of the original loop. What is the output of the corrected loop?
Discuss the potential negative impact of a dominant culture : To prepare: Review "Working With Immigrants and Refugees: The Case of Aaron."
Write a function named digit_name : Write a function named "digit_name" that takes an integer argument in the range from 1 to 9 , inclusive, and prints the English name for that integer on the computer screen.
Write a function named is_prime : Write a function named "is_prime" that takes a positive integer argument and returns as its value the integer 1 if the argument is prime and returns the integer 0 otherwise.
Find the terminal velocity of the sled : A test sled has a mass of 400 kg and is acted on by a thrust force of 200,000 N. It also experiences a viscous drag of 1600•V where V is the velocity. Find the 'terminal velocity' of the sled
Rreasons unrelated to the organ : Transplantable organs become available on short notice--usually because a donor has died for reasons unrelated to the organ. They need to be removed and transplanted very quickly because they only remain fresh for a limited period. Then there i..
What is current in the loop when the torque is at max value : The loop consists of a single turn of flexible conducting wire that is wrapped around a flexible mount such that the dimensions of the rectangle can be changed.
How far downstream does the canoe land : If the river current is 2 m/s (from left to right) and the canoe is moving at 5m/s toward the upper shore at a 60° angle, how far downstream does the canoe land

Reviews

Write a Review

C/C++ Programming Questions & Answers

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

  Whitewater high school has contracted

Whitewater High School has contracted you to write a program that will read a file of student names and test scores in the formation FIRST NAME LAST NAME: SCORE1 SCORE2 SCORE3, where each of the scores is an integer

  Draws a pyramid consisting of bricks

Write a C program that draws a pyramid consisting of bricks arranged in horizontal rows, so that the number of bricks in each row decreases by one as you move up the pyramid.

  Allows its salesclerks to enter the length and width

a program that allows its salesclerks to enter the length and width (both in feet) of a rectangle and the price of a square foot of tile. The program should calculate and display the area of the rectangle and the total price of the tile.

  Wrtie a function called gen_rand_double_array

Wrtie a function called gen_rand_double_array that generates 900 samples of size 22500 random numbers from U(10, 12). For each of these 900 samples, write a main funciton that calculates the mean and finds the simulated probability that the mean is b..

  Write function that finds the minimum of three double value

1. Write a function that finds the minimum of three double values. This function should use another function that finds the minimum of two double values.

  Prepare a temperature converter

Have to write a small program that prompts the user to enter a temperature in degrees Fahrenheit and then prints a massage as to whether the alarm will sound at that temperature.

  A parking garage charges a $2.00 minimum

A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof over three hours.

  Design a simple atm service kiosk

Design a simple ATM service kiosk. This kiosk supports the following options for its menu: 1. Viewing your account balance2. Depositing cash3. Withdrawing cash

  A program computes and displays the number of centimeter

The Earth's ocean levels have risen an average of 1.8 millimeters per year over the past century. Write a program computes and displays the number of centimeters and number of inches the oceans rose during this time.

  Floating point values into an array

Write a program that allows a user to enter 10 floating point values into an array. Then, in a loop, the program should prompt the user for a desired precision and subsequently display each value to the correct precision.

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd