# Not getting output for range of numbers prgm

Page 1 of 1

## 5 Replies - 673 Views - Last Post: 19 November 2012 - 04:59 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=300785&amp;s=4a16001a2cb99370deff2318d9498e1f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 bhaktanishant

Reputation: 0
• Posts: 3
• Joined: 19-November 12

# Not getting output for range of numbers prgm

Posted 19 November 2012 - 03:20 AM

i am just learning c myself by book so i am new to c.
i write a code for "find the range of set of numbers" and when i am running, it is not giving output. i knows only "for, while, break, continue" so can't use recursion or anything else.
I am using DEVC++ .

what is wrong with this code ?

```#include<stdio.h>
#include<conio.h>
main()
{
int i,j=1,max,min,tmp;
printf("how many number are there to enter ");
scanf ("%d",&i);

/*code for take two number as max and min */
while (max>min || max == min)
{
printf("\n enter number \n");
scanf ("%d",&tmp);
max = tmp; /* first number as max */
i=i-1; /*enter one number will reduce i by 1 */
printf ("enter number \n");
scanf ("%d",&tmp);
if (tmp>max)
max=tmp;
else
min=tmp; /*  small number as min */
i=i-1;  /* this will reduce i by 1 */
}

/* now we have max and min number */

while (j<=i)
{
printf ("enter number");
scanf ("%d",&tmp);
if (tmp>=max)
max=tmp;    /* when temp is >= max */
else if (tmp<=min)
min=tmp;     /* when temp is <= min */
j++;
}
printf ("the range of entered number is : ",max-min);
getch();
}

```

output :

Is This A Good Question/Topic? 0

## Replies To: Not getting output for range of numbers prgm

### #2 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,449
• Joined: 14-September 12

## Re: Not getting output for range of numbers prgm

Posted 19 November 2012 - 03:43 AM

Looking at your output may probably help.

I would suggest you post your output for an input of your choice.That will enable us to see where exactly your output is faltering.

regards,
Raghav

### #3 Xupicor

• Nasal Demon

Reputation: 457
• Posts: 1,179
• Joined: 31-May 11

## Re: Not getting output for range of numbers prgm

Posted 19 November 2012 - 04:04 AM

See printf reference, format specifiers should be of interest.

### #4 bhaktanishant

Reputation: 0
• Posts: 3
• Joined: 19-November 12

## Re: Not getting output for range of numbers prgm

Posted 19 November 2012 - 04:38 AM

there is a output image below code. also i have been upload output image....

### #5 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,449
• Joined: 14-September 12

## Re: Not getting output for range of numbers prgm

Posted 19 November 2012 - 04:44 AM

You have not set any value for max and min...without which the default values of max and min will be 0.

Even if that is how you want the code to be, then you need to add a %d in your line 37 like this.

```printf ("the range of entered number is :%d ",max-min);
```

regards,
Raghav

This post has been edited by raghav.naganathan: 19 November 2012 - 04:50 AM

### #6 bhaktanishant

Reputation: 0
• Posts: 3
• Joined: 19-November 12

## Re: Not getting output for range of numbers prgm

Posted 19 November 2012 - 04:59 AM

thanks very much, now code is working fine.
that was my mistake .
THNAKS