Problem:
Write a program which takes length and breadth as input. Than calculate area and perimeter of the room.Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct distance{
int length;
int width;
};
struct room{
struct distance a;
}r;
void myftn();
int main()
{
myftn();
printf ("\n\nPress any key to exit.");
getch();
return 0;
}
void myftn ()
{
int p,s;
printf ("Enter lengtgh: ");
scanf ("%d",&r.a.length);
printf ("Enter widtgh: ");
scanf ("%d",&r.a.width);
p = 2 * (r.a.length * r.a.width);
s = (r.a.length * r.a.width);
printf ("\n\nArea = %d",s);
printf ("\nPerimeter = %d",p);
}
Output
Input Length and Breadth. Calculate Area and Perimeter Using Struct in C Language |
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.