Answer to Question #227661 in Algorithms for kkk

Question #227661

Question 3

 

a) Using C or C++ or a program of your choice, write a program that list the storage size of a float, list the minimum and maximum float values, and the precision of the float. 

​​​​​​​​​​​​[10 marks]

 

b) Describe the steps of how you will compile the program written in Question a) above in a typical compiler such as gcc or a compiler of your choice. ​​​[10 marks]

 

c) Show the output (screenshot) of how you have compiled the program written in Question a) above and attach all files (screenshot) generated where applicable. [5 marks]

​​​​​​​​​


1
Expert's answer
2021-08-24T06:53:34-0400
A)
#include<stdio.h>


int main(){
	float numbers[10];
	int i;
	float minimum;
	float maximum;
	for(i=0;i<10;i++){
		printf("Enter the number %d: ",(i+1));
		scanf("%f",&numbers[i]);
	}
	


	minimum=numbers[0];
	maximum=numbers[0];
	for(i=0;i<10;i++){
		if(numbers[i]>maximum){
			maximum=numbers[i];
		}
		if(numbers[i]<minimum){
			minimum=numbers[i];
		}
	}


	printf("\nThe minimum float value: %.2f\n",minimum);
	printf("the maximum float value: %.2f\n",maximum);


	scanf("%d",&i);
	return 0;
}

B)
To run the program use the following command (linux): 
g++ -Wall -pedantic -std=c++11 -g *.cpp && valgrind --leak-check=full ./a.out

C)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS