Wednesday, 6 February 2013

Write a c program to accept 10 numbers from user, store these numbers into an array & find the smallest value from array using pointer



#include<stdio.h>
#include<conio.h>
  void main()
{
  int a[20],i,*p;
  clrscr();
  printf("\nEnter the array elements: ");
  for(i=0;i<10;i++)
{
  scanf("%d",&a[i]);
}
  p=&a[0];
  p=a;
  for(i=0;i<10;i++)
{
  if(*p>a[i])
{
  *p=a[i];
}
}
  printf("\nThe smallest value of given array is: %d",*p);
  getch();
}

//OUTPUT:

//Enter the array elements: 12
//23
//43
//11
//24
//65
//67
//89
//87
//54

//The smallest value of given array is: 11

1 comment:

  1. From this array how will we print the cube of numbers placed at odd subscript position???

    ReplyDelete