1. SESSION(2023-2024)
A SEMINAR
ON
“APPLET & APPLET LIFE CYCLE”
SUBMITTED INPARTIAL FULFILLMENT OF THE REQUIREMENT FOR AWARD
OF MASTER OF SCIENCE OF COMPUTER SCIENCE
Guided By : Submitted By :
Mr. Faijul Huda Sanju Sanjeev Toppo
(Ass. Prof..of IT Dep..) Msc .Cs III Semester
Roll No. : 09
21-11-2023
KR TECHNICAL COLLEGE AMBIKAPUR
3. INTRODUCTION
Structure in c is a user-defined data type that enables us
to store the collection of different data types. Each
element of a structure is called a member.
The struct keyword is used to define the structure.
Syntax : Example :
struct structure_name
{
data_type1 member_name1;
data_type2 member_name2;
.
.
data_typeN member_nameN;
};
struct employee
{ int id;
char name[10];
float salary;
};
5. STRUCTURE DECLARATION
A structure can be declared using three different ways as
shown :
TAGGED STRUCTURE
STRUCTURE
VARIABLES
TYPE DEFINED
STRUCTURE
6. The structure definition associated with strucutre name is
called tagged strucutre.
Syntax : Example :
TAGGED STRUCTURE
struct tag_name
{
data_type1 member_name1;
data_type2 member_name2;
…… …….
…… …….
data_typeN member_nameN;
};
struct student
{ int rollno;
char name[10];
float avg;
};
7. STRUCTURE VARIABLES
Syntax : Example :
struct
{
data_type1 member_name1;
data_type2 member_name2;
…… …….
…… …….
data_typeN member_nameN;
}
variable1, variable2,variableN;
struct
{ int empno;
char ename[30];
long int salary;
}
emp1, emp2;
8. The strucutre defined associated with keyword
typedef is called type-defined structure.This is the
most powerfull way of defining the structure.
TYPE DEFINED STRUCTURE
Syntax : Example :
typedef struct
{
data_type1 member_name1;
data_type2 member_name2;
…… …….
…… …….
data_typeN member_nameN;
}
TYOE_ID;
typedef struct
{ char cname[26];
int cid;
int run;
long int score;
}
CRICKETER;
9. Syntax :
struct tag_name variable = {mv1,mv2,mvn};
Example :
struct employee
{
char name[20];
int salary;
int id;
}a={“Hemant”,10000,420};
STRUCTURE INITIALIZATION
10. There are two ways to access structure members:
1. By . (member or dot operator)
2. By -> (structure pointer operator)
Syntax :
p1.id
ACCESSING STRUCTURE
11. PROGRAM :
#include<stdio.h>
#include <conio.h>
struct employee
{
int id;
char name[50];
}e1;
void main( )
{
e1.id=420;
strcpy(e1.name,“Hemant Yadav”);
printf( "employee 1 id : %dn", e1.id);
printf( "employee 1 name : %sn", e1.name);
getch();
}
13. A union is a special data type available in C that allows to store
different data types in the same memory location. You can define a
union with many members, but only one member can contain a value
at any given time. Unions provide an efficient way of using the same
memory location for multiple-purpose.
Syntax : Example :
union [union tag]
{
member definition;
member definition;
...
member definition;
} [one or more union variables];
UNION
union Data
{
int i;
float f;
char str[20];
} data;