Question: For each case, we want to plot input (n x-axis) verses execution time (t y-axis). Each of the above cases has two programs to solve
For each case, we want to plot input (n x-axis) verses execution time (t y-axis). Each of the above cases has two programs to solve the corresponding problem. We want to compare the behavior of both programs (i.e. practical comparison) by prepare a figure using Excel. Each figure should have two lines, one for the first program and the other for the second program. In addition to the figures, provide the collected data in separated tables.
Case 1: Check whether a number is Prime or not. Recall that an integer n is prime if it is evenly divisible only by 1 and n.
| Program 1 (2...n) | Program 2 (2...n ) |
| #include using namespace std; main() { int n,c=0; bool prime=true; cout<<"input n: " ; cin>>n; for (int i=2;i if (n%i==0) prime=false; if (prime) cout<<"Prime"; else cout<<"Not Prime"; } | #include #include using namespace std; main() { int n,c=0; bool prime=true; cout<<"input n: " ; cin>>n; for (int i=2;i if (n%i==0) prime=false; if (prime) cout<<"Prime"; else cout<<"Not Prime"; } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
