Question: Write a C program that reads 2 positive integers from the user using scanf() function, prints the following information, and then terminates: - the average

Write a C program that reads 2 positive integers from the user using scanf() function, prints the following information, and then terminates: 
 - the average of the two (this should be printed as a floating point number.) 
 - whether each number is a prime number or not 

In order to see if two numbers are relatively prime, you should calculate the GCD using Euclidean algorithm. You are allowed to look up the algorithm and/or code on the Internet, in which case you should cite the source in your README.txt file. 
Your code should be organized as follows: 
- gcd.h & gcd.c: GCD calculation function header and definition 
- prime.h & prime.c: prime number testing function header and definition 
- main.c: everything else 

- Makefile

All files must be named EXACTLY as above, case-sensitive. When you run "make", it should build an executable file called "main". 
The makefile should have correct dependencies. For example, if you build everything, change prime.h, and run make again, only prime.c and main.c should recompile, not gcd.c. (You can simulate changing a file by using touch command.) 
You can use printf("You typed in %d and %d ", x, y); 
to print integers, and printf("The average is: %f ", avg); 
to print a floating point number. And you can use 
 scanf("%d", &x); 
to read an integer that the user types in. Dont forget the ampersand in front of the variable. 

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!