Write a program so that the user will enter two integers say x and y. As long as x>y, the program will print all primes between x and y inclusive. Also, 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 busing the user input x and y.
My code:
// Project 4 IsPrime.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{ int x;
int y;
printf ( "Please enter two positive integers-->");
scanf ( "%d" "%d" , &x, &y );
printf ( "\nPRIME: ");
}
int findPrime ( int a, int b)
If 3 and 30 are entered for x and y, the program should produce the following output:
Prime: 3 5 7 11 13 17 19 23 29
(Prime count =9)
I'm not really sure where to start, not sure how to call isPrime to check to see if its prime or not, pretty sure I know how to write a code to figure out the prime number for 1 number, but not to list in between, just really confused, I know I need a for loop somewhere, and of course a while loop, I could really use help on how the program should look, (an algorithm would be nice). Well, any tips, pointers, or anything else would be greatly appreciated.
Adot2the~

New Topic/Question
This topic is locked




MultiQuote




|