Question: 5 - Create a program in C named prime. The program should read a line from the standard input stream. The line should be a

5- Create a program in C named prime. The program should read a line from the
standard input stream. The line should be a non-empty sequence of decimal dig
its, that is, ASCII characters in the range 0-9, terminated by an end-of-line mark.
The program should convert the digit sequence to a big integer. To do that, the
program can multiply values in the range 0..9 by powers of ten and sum them up.
The program should test the big integer for primality. Then the program should
write to the standard output stream a line consisting of (1) the sequence of deci
mal digits, (2) a space, and (3) the message "probably prime" or "composite" as
appropriate. The program should repeat until end-of-file of the standard input
stream.
If the prime program reads 0 from the standard input stream, then the program
should write to the standard output stream a line consisting of 0, a space, and the
message "neither". Similarly, if the prime program reads 1 from the standard in
put stream, then the program should write to the standard output stream a line
consisting of 1, a space, and the message "neither". If the program reads a mal
formed line from the standard input stream, then it should write to the standard
output stream a line consisting of (1) the sequence of decimal digits, (2) a space,
and (3) the message "malformed". Then it should continue.
 5- Create a program in C named prime. The program should

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!