Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

Write a C program that reads 2 positive integers (of type int) 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 http://en.wikipedia.org/wiki/coprime if you don't know what this -whether the two numbers are relatively prime or not (see means.) 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 & ged.c: GCD calculation function hader 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 usingtouch 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 should use scanf("d", &x)i to read an integer that the user types in Don't forget the ampersand in front of the variable Write a C program that reads 2 positive integers (of type int) 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 http://en.wikipedia.org/wiki/coprime if you don't know what this -whether the two numbers are relatively prime or not (see means.) 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 & ged.c: GCD calculation function hader 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 usingtouch 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 should use scanf("d", &x)i to read an integer that the user types in Don't forget the ampersand in front of the variable

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago