Well this is CBSE 2008 Question. I just want to know how to get the output 
manually.




________________________________
From: Paul Herring <[email protected]>
To: [email protected]
Sent: Thu, 11 March, 2010 10:11:14 PM
Subject: Re: [c-prog] Random()

  
On Thu, Mar 11, 2010 at 3:40 PM, sruthy_inuyasha
<sruthy_inuyasha@ yahoo.co. in> wrote:
>
> #include<stdlib. h>
> #include<iostream. h>

Why are you using both C and (very old) C++ headers. Decide which
language you're using and stick to it. The only time you should be
mixing the two is with legacy applications written in C and you're
moving it to C++.

> void main()

main returns int. Not void, float or struct foo.

> {
> randomize();

No such function in Standard C (or C++), and you don't seem to define
it. Look up srand().

> char Area[][10]={ "North"," South","East" ,"West"};

char* Area[] = {"North","South" ,"East"," West"};

> int ToGo;
> for(int i=0; i<3; i++)
> {
> ToGo = random(2)+1;

No such function in Standard C (or C++), and you don't seem to define
it. Look up rand(), and read <http://c-faq. com/lib/randrang e.html>

> cout<<Area[ToGo] <<":";
> }
>
> Outputs are
>
> North:South: East
> South:East:South
> South:East:East
>
> Can you tell me how North:South: East is possible?? I tried and I have no
> idea hw that output is possible. If it is possible how do I get it ( I
> meant the procedure)?

Ignoring the fact that you fail to flush cout, those lines, if
copy/pasted, seem to be missing : on the ends of the lines.

Why you're getting seemingly impossible results are probably because
your program is invoking undefined behaviour.

-- 
PJH

http://shabbleland. myminicity. com/tra
http://www.chavgang s.com/register. php?referer= 9375




      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/

[Non-text portions of this message have been removed]

Reply via email to