dumb question

T

trainee

0 is the first element in an array, however in decimal constant connotation,
it acts as it normally would in the real world.

tranee
 
G

Guest

Maximus Ñвојевремено напиÑа:
int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

Because, 5*5 is not 35, but 25!
Tested on gcc 3.3.1, 2.95 and MS Visual Studio 98 with this code:

#include <stdio.h>
int main(void)
{
int a = 5 * 5;
printf("%i\n", a );
return 0;
}
 
J

Jeff Schwab

Maximus said:
Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

tia,
max.

LOL.

Since my wife is currently intent on some romance novel, I'm also doing
"like nothing." I will therefore make the valiant attempt to answer
your question, which reminds me strongly of certain post-frat-party
conversations involving substance abuse.

I suppose the most conceptually fulfilling answer is that 0 * n = 0.
So, defining the multiplication in terms of addition in a sort of "base
1," tally-like notation:

5 * 5

== ( 0 + 1 + 1 + 1 + 1 + 1 )^2

== ( 0 + 0 + 0 + 0 + 0 + 0 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )

Counting up the 1's, you still get 25. The 0's don't contribute. They,
too, are "like nothing."

-Jeff
 
J

Jeff Schwab

== ( 0 + 0 + 0 + 0 + 0 + 0 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )
+ ( 1 + 1 + 1 + 1 + 1 + 1 )


My second D'oh of the night! Pretend the first column there is all 0's.
 
V

Victor Bazarov

Maximus said:
Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

It depends on your definition of 'counts', I guess. In BASIC, IIRC,
an array declared/defined as

int a(5,5)

actually does have 36 elements...
 
M

Maximus

Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

.... a dosen't return 35 ? considering that the computer counts 0 ?

tia,
max.
 
J

Jumbo

Maximus said:
Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

The subject says it all.
<sigh>

Perhaps you'd better go back to doing nothing in front of your screen,
Maximus. LOL.
 
J

Jumbo

Maximus said:
Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

The subject says it all.
<sigh>

Perhaps you'd better go back to doing nothing in front of your screen,
Maximus. LOL.
 
J

Jumbo

Maximus said:
Hi,
I was doing like nothing in front of my screen when I suddenly had the
misterious question : why when you do somthing like this:

int a = 5 * 5;

... a dosen't return 35 ? considering that the computer counts 0 ?

The subject says it all.
<sigh>

Perhaps you'd better go back to doing nothing in front of your screen,
Maximus. LOL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top