Sponsored Content
Homework and Emergencies Homework & Coursework Questions Write a function named isPrime Post 302466053 by KyleBucket on Monday 25th of October 2010 09:13:54 AM
Old 10-25-2010
Question Write a function named isPrime

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Write a function named isPrime which accepts one integer parameter, say x. Have the function return TRUE if x is a prime. Otherwise, have it return FALSE.

b) Write a program that keeps asking the user for an integer say k. As long as k is greater than 0, the program will call isPrime to see if k is a prime. Print the message “Prime” if it is and “Not Prime” if not. Please run p4step1.exe in the class directory for details.


Step 2: a) Modify the above program so that the user will enter two integers say x and y. As long as y > x, the program will print all primes between x and y inclusive.

b) Write a function named findPrime which accepts two integer parameters say a and b. This function will print all prime numbers from a to b by calling the function isPrime. Have your program call this function using the user input x and y. Please run p4step2.exe for details.

c) In step a) your program should have two functions main and isPrime. In step b) there should be an additional function findPrime.


I know how to write like the first step and that's it.

2. Relevant commands, code, scripts, algorithms:


1. You need to use the following functions:
a. (int) isPrime(int k),
b. (int) isPerfect( int k),
c. void findPrime(int x, int y);
d. void findPerfect(int x, int y);
e. void findSquare(int x, int y).
2. You need to use floor and ceil functions in <math.h> for finding the Square number.

3. The attempts at a solution (include all code and scripts):


int
_tmain(int argc, _TCHAR* argv[])
{
int x;
int k;
printf(
"Enter a positive integer -->", x);

return 0;
}


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Delaware/Newark/US/HSU/CIS120

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How To Write Sed Function

hi iam facing problem regarding sed function. give me reply with example of sed function. and what to meanings of $# and @ in scripting please as reply as soon as possible (1 Reply)
Discussion started by: naveeng.81
1 Replies

2. Shell Programming and Scripting

how to write divided function

hi iam facing problem for divided (%) arthemtic function in for condition. tell me reply and all the arthemtic function in one scripting . (2 Replies)
Discussion started by: naveeng.81
2 Replies

3. Programming

how to write a wrapper c code to return uid using getuid() function

And how to use setuid() ? thanks (4 Replies)
Discussion started by: pwd
4 Replies

4. Shell Programming and Scripting

[BASH] Using a function to write data to a file

Hello, I've created a shell script, which accepts information using an input from the console. Part of the script will write a file containing this information. My code looks like (for the write) function make_file { cat <<- _EOF_ The contents of my file are here _EOF_ } ... (12 Replies)
Discussion started by: cpickering
12 Replies

5. Shell Programming and Scripting

How to write cron job for calling sql function database is postgres

Hi, Please help me to write cron job for calling sql function daily. I have Postgres database. (1 Reply)
Discussion started by: kulbhushan
1 Replies

6. Shell Programming and Scripting

how to write a function to get data under spesific lines ? using bash

I have a text file called ( bvhz ) contains data : Subscriber Data ID = 2 Customer = 99 Data ID = 4 Customer = cf99 Data ID = 5 Customer = c99 Data ID = 11 Customer = 9n9 Subscriber Data ID = 1 Customer = 9ds9 Data ID = 2 Customer = 9sad9 Data ID = 3 Customer = f99... (1 Reply)
Discussion started by: teefa
1 Replies

7. UNIX for Dummies Questions & Answers

how to write a function to get data under specific lines ?

I have a text file called (msgz ) contains data : Subscriber Data ID = 2 Customer = 99 Data ID = 4 Customer = cf99 Data ID = 5 Customer = c99 Data ID = 11 Customer = 9n9 Subscriber Data ID = 1 Customer = 9ds9 Data ID = 2 Customer = 9sad9 Data ID = 3 Customer = f99... (3 Replies)
Discussion started by: teefa
3 Replies

8. Shell Programming and Scripting

how to write a function or awk fn ? , please help !!

************* fixed *************** Begin equipmentId : d9 processor : fox number : bhhhhhh Variable # 1: Id : 100 Type : 9 nType : s gType : 5f mType : 4 LField : England DataField : london Length : 4 End (20 Replies)
Discussion started by: teefa
20 Replies

9. UNIX for Dummies Questions & Answers

MAN and read & write function

How to use MAN to find information about read() and write() function ? The command "man read" show some rubbish, for example "man open" show great information about function I need. (2 Replies)
Discussion started by: bbqtoss
2 Replies

10. Shell Programming and Scripting

Need help to write a function in shell scripting to execute sql files

Hi, I am new to shell scripting and i need to write a automation script to execute sql files. I need to check the table if it is there in system tables and need to write a function to call the .sql files. For ex. I have a.sql,b.sql,c.sql files, where the sql file contains DELETE and INSERT... (1 Reply)
Discussion started by: Samah
1 Replies
groupwise_init(1)				       The Computational Morphometry Toolkit					 groupwise_init(1)

NAME
groupwise_init - Affine initialization for groupwise registration SYNOPSIS
groupwise_init [options] image0 [image1 ...] DESCRIPTION
Compute initial affine alignment for a group of input images, which can be used as an input for groupwise registration OPTIONS
Global Toolkit Options (these are shared by all CMTK tools) --help Write list of basic command line options to standard output. --help-all Write complete list of basic and advanced command line options to standard output. --wiki Write list of command line options to standard output in MediaWiki markup. --man Write man page source in 'nroff' markup to standard output. --version Write toolkit version to standard output. --echo Write the current command line to standard output. --verbose-level <integer> Set verbosity level. --verbose, -v Increment verbosity level by 1 (deprecated; supported for backward compatibility). --threads <integer> Set maximum number of parallel threads (for POSIX threads and OpenMP). Main Options --template <string>, -t <string> Input filename for pre-defined template image. [Default: NONE] --output-root <string>, -O <string> Root directory for all output files. [Default: NONE] --output <string>, -o <string> Output filename for groupwise registration archive. [Default: groupwise.xforms ] --output-average <string> Output filename for registered average image. [Default: average.nii ] --average-cubic Use cubic (rather than linear) interpolation for average image. --no-output-average Do not write average image. --align-centers-of-mass Initially align centers of mass rather than centers of bounding boxes. --init-scales Initialize scale factors using first-order moments --center-template Center aligned images in template grid field of view. AUTHORS
Torsten Rohlfing, with contributions from Michael P. Hasak, Greg Jefferis, Calvin R. Maurer, and Daniel B. Russakoff LICENSE
http://www.fsf.org/licensing/licenses/gpl.html BUGS
Report bugs at http://nitrc.org/projects/cmtk/ ACKNOWLEDGMENTS
From April 2009 through September 2011, CMTK Development and Maintenance was supported by the National Institute of Biomedical Imaging and Bioengineering under Grant No.R01 EB008381 (PI: Torsten Rohlfing). CMTK 2.2.2 Jul 20 2012 groupwise_init(1)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy