Structure
Upcoming SlideShare
Loading in...5
×
 

Structure

on

  • 197 views

 

Statistics

Views

Total Views
197
Views on SlideShare
197
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Structure Structure Presentation Transcript

  • //Program for array of a stucture#include<stdio.h>#include<conio.h>void main(){struct employee{int id;char n[20];char des[30];char dept[30];float sal;};struct employee e[50];int i,no;clrscr();printf("enter the no.of employees:n");scanf("%d",&no);printf("enter the details for %d personsn",no);printf("emp_id,emp_name,emp_des,emp_dept &emp_salaryn");
  • for(i=0;i<no;i++){scanf("%d%s%s",&e[i].id,&e[i].n,&e[i].des);scanf("%s%f",&e[i].dept,&e[i].sal);}printf(""n************O/P**********n");printf("nemp_idtemp_nametemp_destemp_dept temp_salaryn");for(i=0;i<no;i++){printf("%d%s%s",e[i].id,e[i].n,e[i].des);printf("%s%f",e[i].dept,e[i].sal);printf("n");}getch();}
  • ***************O/P***************************emp_id emp_name emp_des emp_dept emp_salary1 hemant s/w_developer s/w._company 200002 sara Lecturer CSE 220003 charan Lecturer IT 25000
  • //Program for nested structure#include<stdio.h>#include<conio.h>void main(){struct address{char land[30];int strtno;int hno;char city[20];};struct date{int d;int m;int y;};
  • struct person{int id;char n[20];int age;struct date D;struct address A;};struct person p;int x;clrscr();printf("enter the details of the person:n");printf("Id,name, agen");scanf("%d%s%d",&p.id,&p.n,&p.age);x=strupr(p.n);//printf("%s",x);printf("enter DOBn");scanf("%d%d%d",&p.D.d,&p.D.m,&p.D.y);printf("enter address land,strtno,hno,cityn");scanf("%s%d%d%s",&p.A.land,&p.A.strtno,&p.A.hno,&p.A.city);
  • printf("n**********OUTPUT***********n");printf("ID=%dnNAME=%snAGE=%dnDOB=%d/%d/%dnADDRESS=%st%dt%dt%s",p.id,x,p.age,p.D.d,p.D.m,p.D.y,p.A.land,p.A.strtno,p.A.hno,p.A.city);getch();}
  • Enter the details of the person:Id,name,age12sara24enter DOB05041987enter address land,strtno,hno,cityMahakali_colliery20N/17Chandrapur******************OUTPUT********************ID=12NAME=SARAAGE=24DOB=05/04/1987ADDRESS=Mahakali_colliery 20 N/17 Chandrapur