Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Write the exact output for the following programs:

55 views
Skip to first unread message

محمد رجب

unread,
Mar 21, 2015, 3:03:53 PM3/21/15
to
#include<iostream.h>
main( )
{ int n = 4;
switch(n)
{case 2: cout << "ZZZ\n";
case 3: n=n*5; cout<<"AAA\n";
break;
case 4: n=n/2; cout<<"BBB\n";
case 5: n=n%2; cout<<"CCC\n";
default: cout<<"DDD\n";} }

Paavo Helde

unread,
Mar 21, 2015, 3:27:53 PM3/21/15
to
=?UTF-8?B?2YXYrdmF2K8g2LHYrNio?= <md.r...@gmail.com> wrote in
news:b9baaf3c-b328-4fad...@googlegroups.com:
This program is not valid C++, so it is up to the implementation if it will
have any output. However, I think no compiler version released in the last
15 years will compile it, so the practical answer would be "no output".

hth
Paavo

Lőrinczy Zsigmond

unread,
Mar 21, 2015, 3:32:34 PM3/21/15
to
Well, take you guess, then try it.
My guess:

BBB
CCC
DDD

reason: lack of 'break' statements.

JiiPee

unread,
Mar 21, 2015, 3:33:15 PM3/21/15
to
yes agree.... no output. heh

Lőrinczy Zsigmond

unread,
Mar 21, 2015, 4:02:02 PM3/21/15
to
> Well, take you guess, then try it.
> My guess:
>
> BBB
> CCC
> DDD
>
> reason: lack of 'break' statements.


BCC5.5 proved me right.

red floyd

unread,
Mar 21, 2015, 11:09:16 PM3/21/15
to
Dude, you should NOT have answered. He's trying to get us to
do his homework.

Lőrinczy Zsigmond

unread,
Mar 22, 2015, 5:51:01 AM3/22/15
to
> Dude, you should NOT have answered. He's trying to get us to
> do his homework.

That might be so:)
He will fail nonetheless
if he cannot even compile and execute a trivial example program...

Osmium

unread,
Mar 22, 2015, 9:21:47 AM3/22/15
to
"red floyd" wrote:
That seems very unlikely. Why in the world would any school teach such an
ancient version of the language? Consider the difficulty of finding
something like 20 copies of an ancient text book.


Victor Bazarov

unread,
Mar 22, 2015, 10:03:57 AM3/22/15
to
Considering that the OP is in Egypt it's not an unlikely scenario that
they are using second-, third-, or even higher order-hand books along
with software and equipment... Still doesn't justify doing their
homework for them.

V
--
I do not respond to top-posted replies, please don't ask

Öö Tiib

unread,
Mar 22, 2015, 2:49:20 PM3/22/15
to
On Sunday, 22 March 2015 11:51:01 UTC+2, Lőrinczy Zsigmond wrote:
Yes but your answer was against rules of the game too. You should
either avoid answering at all, link FAQ 5.2 or give some entertaining
to read but wrong answer to homework questions.

guinne...@gmail.com

unread,
Mar 23, 2015, 9:02:59 AM3/23/15
to

Lőrinczy Zsigmond

unread,
Mar 23, 2015, 10:36:04 AM3/23/15
to
> Yes but your answer was against rules of the game too.

Strictly speaking, it is still no *proved*
that it was a homework question;
plus, funny false answers were already provided by other posters.

Öö Tiib

unread,
Mar 23, 2015, 2:41:33 PM3/23/15
to
Sorry, but the situation, that محمد رجب is Egyptian programmer who
did meet the OP puzzle during his work, is unimaginable for me.
He is clearly studying it. Hard to understand what *proof* for
that you are talking about. Can you try to elaborate the logic?

0 new messages