Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 4th, 2002, 12:21 PM
enixioc enixioc is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 3 enixioc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool For just £2 a month you can help newbies program code for themselves.

... just kiddin'

Hi there. I am a newbie and I have been learning C for the past, um, day. So please don't laugh at my simplistic problems. Or at least keep your laughs to yourself.

A quick intro on me: my only previous knowledge of programming is playing about with QBASIC when I was 12 or 13, and the furthest I ever bothered to learn was 'if...then...else' statements. So you can imagine that the programs I created didn't really do much at all. I have been using Clickteam programs for years and you can see my game creations at my website: URL But Multimedia Fusion Express (the clickteam program I used) simplified many things so coding was less painful. I have learned a lot from it, which I might apply to C later on. I also know HTML like the back of my hand, but that doesn't qualify as a programming language. I don't code HTML by hand anymore, using GoLive is much quicker

I have been reading the C tutorial at Howstuffworks (URL). I have gone through the first four pages relatively smoothly, and I have use the GCC compiler and 'Advanced Editor' on Linux (Mandrake, KDE). I have just installed C++Builder (version1) onto Windows from an old PC Plus cover CD.

However, on the array page, the tutorial has gone into complications and not really explained them in a way I can understand. The program below is creates 'random' numbers, displays them, sorts them by value and then displays that. To be perfectly honest, it just scares me! I've tried to break it down to see how it works, but I still don't understand it.

#include <stdio.h>

#define MAX 10

int a[MAX];
int rand_seed=10;

/* from K&R
- returns random number between 0 and 32767.*/
int rand()
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}

int main()
{
int i,t,x,y;

/* fill array */
for (i=0; i < MAX; i++)
{
a[i]=rand();
printf("%d\n",a[i]);
}

/* bubble sort the array */
for (x=0; x < MAX-1; x++)
for (y=0; y < MAX-x-1; y++)
if (a[y] > a[y+1])
{
t=a[y];
a[y]=a[y+1];
a[y+1]=t;
}
/* print sorted array */
printf("--------------------\n");
for (i=0; i < MAX; i++)
printf("%d\n",a[i]);
return 0;
}

Anyone know how the hell this works?

Heh... another question. Is there a way to get console apps in C++builder to stay open when they are finished instead of terminating, without having to put a while loop at the end? If not, I'll probably do back to GCC, but builder does makes compiling quicker and easier...

Reply With Quote
  #2  
Old April 4th, 2002, 02:49 PM
enixioc enixioc is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 3 enixioc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
WAIT!!! I've figured it out!!!!!!!!! WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO! I never thought that solving programming puzzles could be so rewarding!!!!! It's just so simple when you understand it!!!!!!



Reply With Quote
  #3  
Old April 4th, 2002, 04:05 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
DO NOT POST crabs like this here again because:

1) Off topic because there's C/C++ forum

2) When you figured out something, you need to tell us step by step how you did it. By saying I've figured it out!! without further details, you should just keep that to yourself rather than posting here, because it tells readers nothing but indicating that you are trying to show off to readers.

Reply With Quote
  #4  
Old April 6th, 2002, 05:26 PM
enixioc enixioc is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 3 enixioc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm sorry.

I posted it here because I thought the C/C++ forum would be for advanced users. I havn't used devshed before, so I don't know how you do things here. With 'dev' in the name, I assumed that this forum was programming related.

I could post a reply saying how it works, but since I was the person who wanted to know in the first place, I did not bother to. I posted that, ahem, histerical message to let people know I didn't need a reply.

Maybe it was that stupid title I used that annoyed you...

Reply With Quote
  #5  
Old April 8th, 2002, 05:27 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> I thought the C/C++ forum would be for advanced users

There is no such rule. If you have a PHP question regardless how simple it is, you are more than welcome to ask only in PHP forum.

Beginners forum is NOT a catch-all forum. It actually is a useless forum because here in Devshed there are plenty of forums for you to post to.

Reply With Quote
  #6  
Old April 12th, 2002, 10:46 AM
The Ostrich The Ostrich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Oxford, UK
Posts: 31 The Ostrich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
freebsd

freebsd: There is no need to rip someone's head off for the correct assertion that he wouldn't have got an answer on the C/C++ forum.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > For just £2 a month you can help newbies program code for themselves.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway