C Structure

Structure is a entity that handle all
different type of data type at the same time.

Syntax of Structure

struct name
{
char name;
float price;
int total;
}
struct name a1,a2,a3;

Explanation :

We should use the struct keyword, and after that give the name of structure.
Then in the body part of structure, we declare different data type.
In the Above Example we have char, float, int data type in the one structure.
after the body of structure, we declare name of variable belongs to
the name structure.

Program to find the Simple Interest using Structure.

#include<stdio.h>
#include<conio.h>
void main()
{
int si;
struct simpleinterest
{
int p;
float r;
int t;
float si;
};
struct  simpleinterest  p1;
clrscr();
printf(“\nEnter the principle, rate and time for simple interest\n”);
scanf(“%d %f %d”,&p1.p, &p1.r, &p1.t);
si=p1.p*p1.r*p1.t/100;
printf(“\n The value you entered is : %d “, si);
getch();
}

                                           next  




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top