Skip to main content
0 online
theremin thereminOG 2002

This following program compiles w/o errors, but it's not running when I try to run it. The screen just flinches.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{


int count;
int alpha[5];

alpha[0] = 5;

for (count = 1; count < 5; count++)
{
alpha[count] = 5 * count + 10;
alpha[count - 1] = alpha[count] - 4;

}


cout << "List elements: ";

for (count = 0; count < 5; count++)
cout << alpha[count] << " ";
return 0;

}

D
dgiaimoOG 2003

Should't you have something following those "#include"s?

theremin thereminOG 2002

Yes of course. I do. They got omitted in the post somehow I guess. Weird.

So that's not the answer. Sorry. hrm

iwz iwz

oof, this isn't for #1 is it? what is your goal in that first for loop? it's creating some pretty weird numbers in the array

theremin thereminOG 2002

Totally separate program. Should've said that. Sorry.

Funnily enough, I don't even know the goal of it.

Just wanna know what it outputs. But it's not running.
And there's not even any errors in compiling.

iwz iwz

i dunno, it looks fine to me, but i don't know C, nor do i have a C compiler.. hehe

D
dgiaimoOG 2003

How can you know Java, but not C?

theremin thereminOG 2002

Actually Java was a little easier for me

iwz iwz

I learned Java on the job.

Here's how my programming learning has gone so far:

Logo (hehe) -> GW-BASIC -> QuickBasic -> HTML -> VBScript -> JavaScript -> AppleScript -> ColdFusion -> Java. And I'm currently learning Ruby.

Of those, I learned AppleScript, ColdFusion and Java on the job.

I really would love to learn C and C++, but I don't really have an application for it.

theremin thereminOG 2002

BASIC's my favourite. (no sarcasm) Ahh the simple times.

iwz iwz

haha why did i include HTML in there

theremin thereminOG 2002

It counts

D
dgiaimoOG 2003

Interesting. For me it went:

Logo (Yes, me too) -> BASIC -> C -> C++ -> Java -> Perl (kinda) -> C# (kinda) -> PL/SQL

C and C++ are actually really good to learn so that you can play around with low level stuff like memory management. Sometimes when you only use Java you can forget about all the stuff going on behind the scenes.

yay yayOG 2004

Oo Oo i want to play

Hmm well, I didn't learn in a specific order

theremin thereminOG 2002

For me:

HTML - 1996/97, Visual BASIC - 1997, BASIC - 1997 (Gw & Q. What's the difference anyway?) yeh I learned kinda backwards, C++ - 1998, Visual BASIC - 1999, C - 2000, JavaScript - Early 2000s forget exactly, PERL early 2000s, some CSS somewhere around here, SQL 2003, Java 2006, and now I'm back to relearning C++ as well as CSS and XML.

I know I seem intelligent enough, but I used to be better at this stuff. I'll probably wind up doing something in Real Estate or teaching English.

theremin thereminOG 2002

I'm using the Bloodshed Dev-C++ http://www.bloodshed.net/

deanh77 deanh77Founder

why don't you try changing this:
for (count = 0; count < 5; count++)
cout << alpha[count] << " ";

to:

for (count = 0; count < 5; count++) {
cout << alpha[count] << " ";
}

I know in java you can do the first, but I'm not sure if it works the same in C, anyway, give it a shot. (My C is really really rusty)

D
dgiaimoOG 2003

I just copied it verbatim and compiled it, and it ran just fine. You must have something set up weird on your machine.

theremin thereminOG 2002

May you copy and post the output ? Thanks

D
dgiaimoOG 2003

List elements: 11 16 21 26 30

iwz iwz

yeah i think that's what i got when i did it on paper

theremin thereminOG 2002

Thanks

yay yayOG 2004

The screen is closing before you can see the output, run in a command line window or figure out how to put a key capture at the end (like getch() or _getch())

yay yayOG 2004

*bump*
I was right? I see system("pause");

I think I've seen this problem/solution nearly 50 times.

theremin thereminOG 2002

isn't getch only in C?

didn't know C++ has the command

gonna flip thru my book

D
dgiaimoOG 2003

Anything (almost) in C is also in C++.

yay yayOG 2004

Yeah the new standard even puts these into the namespace by making new standard headers prefixed with c, like cmath, and cstdlib, cstdio

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.