11
11
struct StructureName {
dataType member1;
dataType member2;
// ... more members
};
#include <stdio.h>
int main() {
// Declare a variable of the 'Person' structure
struct Person person1;
return 0;
}
In this example, we've declared a structure named 'Person' with three
members: 'name' (a character array to store the name), 'age' (an
integer to store the age), and 'height' (a floating-point number to store
the height). We then declared a variable of the 'Person' structure
called 'person1' and initialized its members with data. Finally, we
accessed and printed the information stored in the 'person1' structure.
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
}
Enter radius of a circle 5
Area = 78.500000
Perimeter = 31.400000
Explanation:
1. The user is prompted to enter the radius of a circle, and the input is read using
scanf.
2. The areaperi function is called with the radius and pointers to area and perimeter
as arguments.
3. Inside the areaperi function, the area is calculated as 3.14 * r * r, and the
perimeter is calculated as 2 * 3.14 * r. These values are stored in the memory
locations pointed to by the a and p pointers.
4. The area and perimeter values are printed in the main function, resulting in the
output shown above.