Monday, April 4, 2011

struct in c++

| Monday, April 4, 2011 | 0 comments

           The structure is a collection of data elements are combined into a single unit of data.Each data element is called a field or element structure. Fields can have different data types or, even if the field is in one but still could siakses individually.

Declaration of structure
structname_struktur
{
  type1 element1;
  type2 element2;           member / element of structure
  type3 element3;
  } nane_object;   //identifier that is used to calling structure

------------atau---------------
structname_struktur
{
  type1 element1;
  type2 element2
  type3 element3;
  .
  .} ;
struct name_struct name_object;

/ / example struct with the same data type:
struct date
{
int date;
int month;
int year;
} th;
--- --- or can be written
struct date
{
int date, month, year;
} th;

/ / example struct with different data types:
struct student
{
NIM char [10];
char name [25];
char department [2];
float GPA;
}MHS;



example program
/ / program inventory data
# include <iostream>
# include <conio.h>
struct stock {
char name [50];
int Amount;
stoks};
main ()
{
court <<"Enter item name ="; cin>> stoks.name;
court <<"Enter the number of items ="; cin>> stoks.jml;
court <<"";
court <<"------------------------- \ n ";
court <<"";
court <<"Output" <<stoks.name <<"=";
court <<stoks.jml;
getch ();}




0 comments:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment

thank you for visiting my blog and comment here. I hope the commentary contains a comment which intend to build and repair. criticism and suggestions I gladly accept.

Popular Posts

 

Total Pageviews

stat

© Copyright 2010. http://programminghaha.blogspot.com . All rights reserved | http://programminghaha.blogspot.com is proudly powered by Blogger.com | Template by o-om.com - zoomtemplate.com