Skip to content

Instantly share code, notes, and snippets.

@mmikhan
Created March 20, 2015 21:12
Show Gist options
  • Save mmikhan/32754bd83a0aba3ab84c to your computer and use it in GitHub Desktop.
Save mmikhan/32754bd83a0aba3ab84c to your computer and use it in GitHub Desktop.
Write a small C program to calculate and display the area of a rectangle using the formula mentioned in the example
//
// main.c
// midterm
//
// Created by Md Mazedul Islam Khan on 3/21/15.
// Copyright (c) 2015 Md Mazedul Islam Khan. All rights reserved.
//
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
int area, length, width;
printf("Please enter the length of the reactangle: ");
scanf("%d", &length);
printf("Please enter the width of the reactangle: ");
scanf("%d", &width);
area = length * width;
printf("Length of the reactangle is: %d\n", length);
printf("Width of the rectangle is: %d\n", width);
printf("The area of the rectangle is: %d\n", area);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment