Basic C++

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

Basic C++

Post by wtd »

Some simple Turing -> Python comparisons

Conditionals:

Code: Select all

if 42 < 34 then
   put "Hello"
elsif 56 > 89 then
   put "World"
else
   put "Foo bar!"
end if[code]

[code]if 42 < 34:
   print "Hello"
elif 56 > 89:
   print "World"
else:
   print "Foo bar!"[code]

Defining a function:

[code]function square (a : int) : int
   result a * a
end square[code]

[code]def square(a):
   return a * a[code]

While loop:

[code]var counter := 0

loop
   put "Hello"
   counter += 1
   exit when counter = 5
end loop[code]

[code]counter = 0

while counter < 5:
   put "Hello"
   counter += 1[code]

Looping over an array/list:

[code]var arr : array 1 .. 5 of int := init (3, 4, 1, 7, 8)

for i : 1 .. upper (arr)
   put arr (i)
end for[code]

[code]arr = [3, 4, 1, 7, 8]

for x in arr:
   put arr[code] 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:3314, old post ID:27094[/size][/color]
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Basic C++

Post by syb »

Okay thank. I am sure i'll have some questions.

I just thought of one. You said your running linux right now. Well i was wondering if you knew how to partion with linux already as your OS.

I am using redhat 8.0 and want to put daul boot (one as win 2k and the other as redhat) on it but all the stuff i've found was how to partion with win 2k then put on linux.

Archived topic from Iceteks, old topic ID:3314, old post ID:27096
The wisdom of sight comes from the father of lights
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

Basic C++

Post by wtd »

When you dual boot with Windows, always install Windows first. Windows doesn't play well with others, but Linux does, so if Windows goes second it'll screw up the bootloader. If Linux goes second, Windows basically doesn't even know it's there, which is just fine. :)

Archived topic from Iceteks, old topic ID:3314, old post ID:27097
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

Basic C++

Post by Red Squirrel »

Yeah just ensure to install a linux bootloader so you can boot windows and linux, and NEVER uninstall that installation of linux, unless you plan to fdisk your entire drive. I learn't that the hard way. :D

Actually, there's ways to recover from that, but they're a risk, it involves rebuilding the MBR and well, if it goes wrong, you're screwed. (I believe this would even affect non-bootable partitions on that drive, but I'm not 100% sure)

Archived topic from Iceteks, old topic ID:3314, old post ID:27098
Honk if you love Jesus, text if you want to meet Him!
syb
Posts: 222
Joined: Wed Jun 18, 2003 10:12 pm

Basic C++

Post by syb »

or you can whip out the MBR ( if MBR means master boot record) If you have nothing worth saving. Okay thanks. I'll install win 2k then put on linux.

Archived topic from Iceteks, old topic ID:3314, old post ID:27101
The wisdom of sight comes from the father of lights
User avatar
MikeDB
Posts: 1224
Joined: Fri May 13, 2005 3:09 pm

Basic C++

Post by MikeDB »

well i see alot of people sort of answerd. Sorry i took so long i had a problem with my parents but anyways i started up a new website oh and when you get there just to let you know that you internet is not down just keep scrolling down till you find a link saying ENTER ok http://members.shaw.ca/mike-db (its not quite done yet but its getting there :biglaugh:

Archived topic from Iceteks, old topic ID:3314, old post ID:27223
aznsamaritan
Posts: 57
Joined: Tue May 10, 2005 7:40 pm

Basic C++

Post by aznsamaritan »

._. im confjused..

Archived topic from Iceteks, old topic ID:3314, old post ID:27291
wtd
Posts: 157
Joined: Sat Sep 25, 2004 7:21 pm

Basic C++

Post by wtd »

aznsamaritan wrote: ._. im confjused..
About what?

Archived topic from Iceteks, old topic ID:3314, old post ID:27302
Locked