# HOW MANY *'s

## HOW MANY *'s

#include<stdio.h>

int main()

{

short i=0;

short n=42;

for( i=0;i<n;n++)

printf("*");

}

CAN U TELL THE NO OF STARS THAT WILL BE PRINTED?

int main()

{

short i=0;

short n=42;

for( i=0;i<n;n++)

printf("*");

}

CAN U TELL THE NO OF STARS THAT WILL BE PRINTED?

**SwitchCase**- Posts : 5

Join date : 2008-08-13

## Re: HOW MANY *'s

if max no. than "n" can hold is x then after x it become -(x+1)

so ans should be (x-42)+x+1 as n start from 42 so it reaches to max val x then become -(x+1) then again increase and reaches to 0

so ans should be (x-42)+x+1 as n start from 42 so it reaches to max val x then become -(x+1) then again increase and reaches to 0

**mnnit.rahul**- Posts : 16

Join date : 2008-08-10

## Re: HOW MANY *'s

32726 times

range of short int in gcc -32768 to 32767

now n=42 and * will be printed at n=32767 are (32767-42+1=) 32726

now at next iteration n=-32768 which is less than i(which is equal to zero) ,hence the loop break

@etawah it's (x-42)+1

range of short int in gcc -32768 to 32767

now n=42 and * will be printed at n=32767 are (32767-42+1=) 32726

now at next iteration n=-32768 which is less than i(which is equal to zero) ,hence the loop break

@etawah it's (x-42)+1

**ankurgutpa**- Posts : 44

Join date : 2008-08-10

Age : 32

Location : Tandon 72

## Re: HOW MANY *'s

abe limit nahi yaad thi

so i used x instead of 32767

samajh gaya!!!!!

so i used x instead of 32767

samajh gaya!!!!!

**mnnit.rahul**- Posts : 16

Join date : 2008-08-10

Page

**1**of**1****Permissions in this forum:**

**cannot**reply to topics in this forum