1 Replies - 5662 Views - Last Post: 18 February 2008 - 08:58 AM Rate Topic: -----

#1 sitesh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-February 08

finding smallest number among given numbers using While Loop in C lang

Post icon  Posted 18 February 2008 - 08:49 AM

#include<stdio.h>
void main()
{
int x,i=1,small,p;
while(i<=10)
{
printf("Enter %d no = ",i);
scanf("%d",&x);
if(x<small)
{
small=x;
p=i;
}
i++;
}
printf("smallest no = %d,position = %d", small,p);

}
Is This A Good Question/Topic? 0
  • +

Replies To: finding smallest number among given numbers using While Loop in C lang

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,559
  • Joined: 25-January 07

Re: finding smallest number among given numbers using While Loop in C lang

Posted 18 February 2008 - 08:58 AM

please explain the problem you are facing, that will help us to help you. :)

btw, the problem that I can see here is that you haven't initialized small to the smallest number.

initialize small with smallest possible integer before while loop. and still if there are any problems then post it here [with proper explanation of course]

This post has been edited by AmitTheInfinity: 18 February 2008 - 09:10 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1