Thursday, May 23, 2013

What is structure??

A structure is an object that consist of named members, that may be of different data types. The members have public access


Concept:  A structure provides a means of grouping variables under a single name for ease of use and handling of the same. The structure can be nested to develop complex hierarchies. Structure may be copied to and assigned value like other variables. They are also  useful in passing groups of logically related data into function.


Syntax:-

struct stucture_name
{
        ......
        .......     // list of data types and variable  name
       .......
};



Monday, May 20, 2013

Array program

Array programs:------------------------------------


#include<stdio.h>
#include<conio.h>
3define DIM 5

void main()
{
    int arr[DIM];
    int i=0;

while(i<DIM)
{
  printf("element %d:",i);

  scanf("%d",&arr[i]);
  ++i;
}

printf("Array Elements");
i=0;

while(i<DIM)
{
printf("%d\t",arr[i]);
++i;
}
   printf("\n");
getch();
}




\\next program


#include<stdio.h>
#include<conio.h>
#define DIM 5
void main()
{
    int arr[DIM];
    int i;
    for(i=0;i<DIM;++i)
        {
            printf("elementsv%d:",i);
            scanf("%d",&arr[i]);
        }
    printf("array elements:");
for(i=0;i<DIM;++i)
    printf("%d",arr[i]);
   printf("\n");
printf("Array elements in reverse order");
    for(i=DIM-1;i>=0;--i);
        printf("%d",arr[i]);
    printf("\n");
    getch();
}





\\next program


#include<stdio.h>
#include<conio.h>
#define N 5
void main()
{
    int arr[N];
    int i, max;
    for(i=0;i<N;i++)
    {
       printf("element %d:",i);
           sacnf("%d",&arr[i]);

    }
   max=arr[0];
     for(i=1;i<N;i++);
    if(max<arr[i])
       max=arr[i];
            printf("MAX Array Element is %d:\n",max);
  getch();
}