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

Program will be tested and compiled to receive 5 stars. Please note input only n

ID: 441449 • Letter: P

Question

Program will be tested and compiled to receive 5 stars. Please note input only needs to be read as individual test cases, not multiple lines.

You are going to write a program that takes in a series of integers,N, and prints out all pairs of numbers (a,b), such thatatimesbequalsN, such thatais less than or equal tob, andais not equal to 1. Furthermore, you will print out a special message if the number is a prime.

Input will begin with a line single integer,T(1<T<10). On each of the followingTlines, there will be a single integer,N(2<N<10,000,000).

For each test case, your program should first print a case header. This will begin with

Case X:N

Where X is the case number (from 1 toT), andNis the number which will be factorized. After this line, print a single line for each pair (a,b) such thatais less than or equal tob,ais not equal to 1, andatimesbequalsN. These lines should have the following format

(a,b)

These lines should be printed in increasing order ofa. Be careful to print each pair exactly once. Also, note that there is no space between the comma and the second factor.

If there are no valid pairs of numbers, the number must be a prime. In this event, print the following statement:

This number is a prime!

After each case, print a blank line. For further clarification, refer to the sample I/O.

Input:

4

9

10

11

12

Output:

Case 1: 9

(3,3)

Case 2: 10

(2,5)

Case 3: 11

This number is a prime!

Case 4: 12

(2,6)

(3,4)

NOTE: There is no space between the comma and the second factor

Guidelines:

Program maintains a reasonable use of whitespace

Program uses clear, descriptive variable names

Program reads in all values as integers

Program contains a loop overTtest cases

Program contains a loop overN(or some function ofN)

Program does NOT prompt the user for input

Program contains an if statement for handling the prime case

Program contains at least one for loop

Explanation / Answer

//PLEASE RATE


#include<stdio.h>

#include<stdlib.h>


int main (){

int N,T;// T= testcases, N=number

int i,j;//counters

int prime;//1- is prime 0 - not prime

scanf("%d",&T);


for(i=0;i<T;i++){

prime=1;

scanf("%d",&N);

printf("Case %d: %d ",i+1,N);


for(j=2;j<N;j++){

if(N%j==0 && (j<=(N/j))){

printf("(%d,%d) ",j,N/j);

prime=0;

}


}

if(prime==1){

printf("This number is a prime! ");

}

}


system("pause");

return 0 ;

}