Monday, June 18, 2012

To enter elements in a 1-D array and then print them


/* Program to enter elements in a 1-D array and then print them */

#include<stdio.h>

#include<conio.h>

void main()

{

  int arr[10],i;

  clrscr();

  /* To enter elements in a 1-D array */

  printf("Enter the elements of the array:\n");

  for(i=0;i<10;i++)

  {

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

  }

  /* To print the elements of 1-D array */

  printf("\n\n Entered array -->\n");

  for(i=0;i<10;i++)

  {

    printf("\t%d",arr[i]);

  }

  getch();

}

 

OUTPUT

Enter the elements of the array:

12

23

34

45

56

67

78

89

37

55

 

 

 Entered array -->

        12      23      34      45      56      67      78      89      37    55

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.