Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Sunday, January 9, 2011

Write a program to find out the smallest number in the array using pointers.


Source Code :

#include<stdio.h>
void main()
{
      int a[10],*p,i,min;
      clrscr();
      p=&a[0];
      printf("\nEnter 10 Elements : ");
      for(i=0;i<10;i++,p++)
            scanf("%d",p);
      p=&a[0];
      min=*p;
      for(i=0;i<10;i++,p++)
            if(*p<min)
                  min=*p;
      printf("\nSmallest Element : %d",min);
      getch();
}

Output :

Enter 10 Elements : 2 5 6 9 8 4 1 3 7 5

Smallest Element : 1

No comments:

Post a Comment