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
Create a program in C named prime. The program should read a line from the
standard input stream. The line should be a nonempty sequence of decimal dig
its, that is ASCII characters in the range terminated by an endofline mark.
The program should convert the digit sequence to a big integer. To do that, the
program can multiply values in the range 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 the sequence of deci
mal digits, a space, and the message "probably prime" or "composite" as
appropriate. The program should repeat until endoffile of the standard input
stream.
If the prime program reads from the standard input stream, then the program
should write to the standard output stream a line consisting of a space, and the
message "neither". Similarly, if the prime program reads from the standard in
put stream, then the program should write to the standard output stream a line
consisting of 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 the sequence of decimal digits, a space,
and the message "malformed". Then it should continue.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
