Answer to Question #270037 in C for Sherlock

Question #270037

1. Write a C program that will convert Second into Minute and Hour.


2. Write a C program that will enter marks of three Quizzes calculate the mean


of this marks. (Mean and Total)


3. Write a C program to find (x+b)2


output.


4. Write a C program to enter base and height of a triangle and find its area.


5. Write a C program to calculate area of an equilateral triangle.

1
Expert's answer
2021-11-22T09:34:15-0500


1. Write a C program that will convert Second into Minute and Hour.


#include <stdio.h>
int main() {
	int sec, h, m, s;
	printf("Input seconds: ");
	scanf("%d", &sec);
	
	h = (sec/3600); 
	
	m = (sec -(3600*h))/60;
	
	s = (sec -(3600*h)-(m*60));
	
	printf("H:M:S - %d:%d:%d\n",h,m,s);
	


	getchar();
	getchar();
	return 0;
}








2. Write a C program that will enter marks of three Quizzes calculate the meanof this marks. (Mean and Total)
#include <stdio.h>
int main()
{
	int q1, q2, q3,total=0;
	float mean;
	
	printf("Enter three quizzes: ");
	scanf("%d %d %d", &q1, &q2, &q3);
	total=(q1 + q2 + q3);
	mean = total/3.0;
	printf("The total is: %d\n", total);
	printf("The mean is: %.2f", mean);


	getchar();
	getchar();
	return 0;
}








3. Write a C program to find (x+b)2 output.
#include <stdio.h>
int main()
{
	float x,b,result;
	
	printf("Enter x and b: ");
	scanf("%f %f", &x, &b);
	result= (x+b)*(x+b);
	printf("(%.2f + %.2f)^2 = %.2f\n", x,b,result);


	getchar();
	getchar();
	return 0;
}




4. Write a C program to enter base and height of a triangle and find its area.


#include <stdio.h>
int main()
{
	float base,height,area;


	printf("Enter a base of a triangle: ");
	scanf("%f",&base);
	printf("Enter a height of a triangle: ");
	scanf("%f",&height);
	area = 0.5*base * height;
	printf("The area of a triangle: %.2f\n",area);


	getchar();
	getchar();
	return 0;
}




5. Write a C program to calculate area of an equilateral triangle.
#include <stdio.h>
#include <cmath>
int main()
{
	float side,area;


	printf("Enter a side of a triangle: ");
	scanf("%f",&side);
	area = (sqrt(3.0)/4.0)* side*side;
	printf("The area of a triangle: %.2f\n",area);


	getchar();
	getchar();
	return 0;
}

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
New on Blog
APPROVED BY CLIENTS