Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is done on Visual C++ with Windows Console Application in Visual Studio. Pl

ID: 3590741 • Letter: T

Question


This is done on Visual C++ with Windows Console Application in Visual Studio. Please do the format as:
#include <stdio.h>

Please NO java. Thank you

Create a program that uses functions and arrays that performs the following: Creates a report to display to the user containing the following information: o Accept user input for a starting number o determine whether or not the entered number is prime or not o find the next 20 prime numbers after your selected numbers o display your results This can be created either using the console application as we've done in class or as a windows application if you're more comfortable withh that.

Explanation / Answer

/* C++ Program - Print Prime Numbers */

#include<conio.h>

#include<stdio.h>

#include <iostream>

using namespace std;

//function declaration to check prime numbers

void checkPrimeNumbers(int);

//main function begin

int main()

{

int startnum;

// to print all the prime number between any range from startnum

cout<<"Enter starting number : ";

cin>>startnum;

//funciton call to check prime numbers

checkPrimeNumbers(startnum);

return 0;

}

//function defianation to check prime numbers

void checkPrimeNumbers(int start)

{

//varible declatains,a[20] array used to store prime numbers

int end, i, j,k, count=0,a[20]={0};

end=0;

//loop to check 20 prime numbers using end varible

for(i=start,k=0; end<=20; i++)

{

count=0;

for(j=2; j<i; j++)

{

if(i%j==0)

{

count++;

break; //break statement runs means the number is not prime

}

}

//count==0 means given number is prime

if(count==0)

{

//display if user input value is prime

if(i==start)

cout<<start<< "is a prime"<<endl;

end++;

//store prime numbers in array

a[k]=i;

k++;

}

}

//Display 20 prime numbers stored in array a

cout<<"20 Prime Numbers after "<<start<<" are "<<endl;

for(k=0;k<20;k++)

cout<<a[k]<<" ";

}

Output :

Enter starting number : 3
3 is a prime
20 Prime Numbers after 3 are
3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote