Skip to content

Instantly share code, notes, and snippets.

@bonface221
Created April 8, 2025 10:43
Show Gist options
  • Save bonface221/b13d853d25ae6364a4caf11a2a8087b3 to your computer and use it in GitHub Desktop.
Save bonface221/b13d853d25ae6364a4caf11a2a8087b3 to your computer and use it in GitHub Desktop.
C program to calculate the area of a land. Write a C program that accepts the length and width of a rectangular piece of land in foot, converts them into meters and then calculates the area. The program shuould then output the length,width and area in metres. Use a function. Hint 1 foot = 0.3metres and area = length * width
#include <stdio.h>
#include <string.h>
/*
Write a C program that accepts the length and width of a rectangular
piece of land in foot, converts them into meters and then calculates
the area. The program shuould then output the length,width and area in
metres. Use a function. Hint 1 foot = 0.3metres and area = length * width
*/
double calcAreaInMetres(double length, double width)
{
return (length * 0.3) * (width * 0.3);
}
int main()
{
double length, width;
// Ask user for length
printf("Welcome to Land Area calculator\n");
printf("--------------------------\n");
printf("Enter the Lenght in foot\n");
scanf("%lf", &length);
// Ask user for width
printf("Enter the width in foot\n");
scanf("%lf", &width);
double result = calcAreaInMetres(length, width);
printf("Result %lf\n", result);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment