C Tutorial

This C program gets length and width as user inputs and computes the perimeter of rectangle.

Perimeter of rectangle = 2*(length + width)

#include<stdio.h> void main() { int length, width, perimeter=0; printf("\nFinds rectangle perimeter\n-------------------"); printf("\nEnter Length: "); scanf("%d", &length); printf("Enter width: "); scanf("%d", &width); perimeter = 2 * (length + width); printf("Perimeter of Rectangle: %d", perimeter); }Output:

$ cc perimeter-of-rectangle.c $ ./a.out Finds rectangle perimeter ------------------- Enter Length: 8 Enter width: 9 Perimeter of Rectangle: 34

C Program Examples

C Tutorial

Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page

^