Wednesday, 28 November 2012

Position and value of smallest number


//Position and value of smallest number in an array
#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 int array[100],small=32767,n,loc=-1;
 printf("Enter no. of values: ");
 scanf("%d",&n);
 printf("Enter Values:\n");
 for(int i=0;i<n;i++)
 {
  printf("value %d: ",i+1);
  scanf("%d",&array[i]);
  if(array[i]<small)
  {
   small=array[i];
   loc=i;
  }
 }
 printf("Smallest Value is: %d\n",small);
 printf("Position of smallest value: %d",loc+1);
 getch();
}
//program written by Mars.

1 comment:

  1. .thank you for sharing useful post.
    web programming tutorial
    welookups

    ReplyDelete

You are welcome, your comment helps me to make this blog more better.