Sunday, July 31, 2011

Learn array declaretion in programming language C

#include<stdio.h>          //header file
#include<conio.h>          //header file

int main(int i[])          //main function
{
    clrscr();              //clear output screen
    int n,j;
    printf("How many element do you enter?\n");
    scanf("%d",&n);        //collect data numbre
    for(j=0;j<n;j++)       //for loop
    {
    printf("Enter element no %d: ",j+1);
    scanf("%d",&i[j+1]);                 //collect data in the array
    }
    printf("\n\nData you have enterd:\n");
    for(j=0;j<n;j++)        //2nd for loop
    {
    printf("Element no %d: %d\n",j+1,i[j+1]);       //print collected data
    }
    getch();                //show the output screen
}