jituTechnology

jituTechnology

A program to calculate the area and perimeter of the rectangle using macro.

A program to calculate the area and perimeter of the rectangle using macro.

Codes
/*A program to calculate the area and perimeter of the rectangle using macro*/
/*Programed by          Jitendra Kr Yadav
                         10116
                         15 Mar,2011*/
#include<stdio.h>
#include<conio.h>
#define AREA l*b
#define PERIMETER 2*(l+b)
main()
{
int l,b;
printf(“Enter the length and bredth of the rectangle:\n”);
scanf(“%d%d”,&l,&b);
printf(“Area = %d”,AREA);
printf(“Perimeter = %d”,PERIMETER);
printf(“Press any key to continue…”);
getch();
}
Output
Enter the length and breadth of the rectangle:
15
6
Area = 90
Perimeter = 42

Press any key to continue…

Add a comment

Comments (1)

  1. vardhanOctober 27, 2013 Reply
    Hello, Thanks for the prog, i used the same prog in codeblocks and it dint work.
    I think there is different way to #define a simple macro. just saying ine AREA l*b is not working.
    please can you explain why?

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930