Anyone know C++ ? (NLC)

Anything goes in here.....
User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Wed Jan 30, 2008 12:24 pm

steve_weegie wrote:If at first you dont succeed, plagiarise? ;)

http://www.shedai.net/c/new/#section1group2

How are you expected to calculate pi? there's a few different methods and will all yield different results depending on the number of iterations you compute

Cheers,

Steve
tried a few of the codes on this link but my compiler doesn't understand them. Keep getting failed build.
1995 Volvo 940SE Estate

fd
Posts: 883
Joined: Mon Apr 23, 2007 4:56 pm

Post by fd » Wed Jan 30, 2008 1:34 pm

Tom wrote: Red wine and laptop does sound appealing. I'm struggling with this. Don't have any experience with programming and frankly don't know where to start. pm sent. :thumbsup
Dude,

C++ is not the language to be cutting your 'programming' teeth in . . . I've seen more people blow their own legs off (virtually) with c++ than anything else . . .

Robins advice is sound, use Cif you must use a C derivative . . . a C++ compiler will handle it . . .

I'm curious however . . . if you have no programming experience . . . and given the relatively involved use of floathing point maths and all the grief that brings . . . is this a crypton factor type of thing ? . . . ;-)

Fd (12+year C++ veterain and mentally scarred as a result)

User avatar
GregR
Posts: 6933
Joined: Tue Oct 18, 2005 1:45 pm
Location: Edinburgh

Post by GregR » Wed Jan 30, 2008 1:42 pm

yeah Tom - use Basic ffs :P

/20 goto 10 faction
Ferrari 458
Porsche 993 C2
Disco V

User avatar
campbell
Posts: 17331
Joined: Sat Mar 25, 2006 12:42 pm
Location: West Lothian
Contact:

Post by campbell » Wed Jan 30, 2008 1:47 pm

Yep, Fd just asked the question I was too tired to pose last night...


...what on earth are you up to, Tom?!
http://www.rathmhor.com | Coaching, training, consultancy

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:02 pm

Sodding Uni work. One of our modules this term is C Programming. We are using Borland C++ and apparently we are supposed to be learning the basics of C etc. Lecturer is Russian with not the best grasp of English, and he merrily talks his way through Float this and Scanf that. I can barely open Borland, let alone try and write a programme that can actually be compiled.

Next week we are due to hand in an assessment that can do the whole Pi thing as described. Goes towards final mark etc... :shock:

A few friends and I have no clue as to what to do.... I imagine I am feeling something akin to the chap in the canoe up the creek etc.... fecking arsing damn I HATE C++.... :rage :chainsaw :tard

From what everyone seems to be saying C++ is a bitch, so I guess I haven't been given the easiest of starts in the whole programming malarky. I'm even unsure of the difference between C and C++.... :shock: :? :oops:

Anyway, if anyone could help it would be much appreciated....
1995 Volvo 940SE Estate

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:03 pm

fd wrote:
Tom wrote: Red wine and laptop does sound appealing. I'm struggling with this. Don't have any experience with programming and frankly don't know where to start. pm sent. :thumbsup
Dude,

C++ is not the language to be cutting your 'programming' teeth in . . . I've seen more people blow their own legs off (virtually) with c++ than anything else . . .

Robins advice is sound, use Cif you must use a C derivative . . . a C++ compiler will handle it . . .

I'm curious however . . . if you have no programming experience . . . and given the relatively involved use of floathing point maths and all the grief that brings . . . is this a crypton factor type of thing ? . . . ;-)

Fd (12+year C++ veterain and mentally scarred as a result)
Thanks Fd, this sounds like the kind of sense this place (Heriot Watt) needs. No programming experience at all and right in at the deep end....
1995 Volvo 940SE Estate

User avatar
ceejam
Posts: 479
Joined: Thu Nov 22, 2007 3:49 pm
Location: East of Scotland
Contact:

Post by ceejam » Thu Jan 31, 2008 4:08 pm

Ah, I remember those days! You don't happen to be doing E&E Eng do you? I did 4 years of it at the Watt.

We got landed with a few terms of programming in C using Borland C++ as the compiler, although I don't think we ever had to use C++.

Our final assessment was to take a txt file with lots of football results in and arrange / manipulate it to provide the league table! Many days were we in the computing lab until "dark o'clock" on that one!!!

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:12 pm

ceejam wrote:Ah, I remember those days! You don't happen to be doing E&E Eng do you? I did 4 years of it at the Watt.

We got landed with a few terms of programming in C using Borland C++ as the compiler, although I don't think we ever had to use C++.

Our final assessment was to take a txt file with lots of football results in and arrange / manipulate it to provide the league table! Many days were we in the computing lab until "dark o'clock" on that one!!!
Actually doing Automotive Engineering. For another 3.5 sodding years :rage this is just one of the funfilled modules i have to do....

maybe it's only C we're doing. I haven't a clue. it's all #include <stdio> etcetc
1995 Volvo 940SE Estate

User avatar
graeme
Posts: 3528
Joined: Tue Mar 15, 2005 11:29 am
Location: Kintore

Post by graeme » Thu Jan 31, 2008 4:30 pm

Tom,

I've been in your shoes! I was clueless with my first Heriot-Watt C programming assignment too (part of electrical and electronic eng degree).

I'd never written a line of code, and was clueless. Simon Ironside did the assignment for me while I watched. Anyway, programming fascinated me so much I demanded he teach me more.

I jacked in the electronics degree and did computing instead. Made a damned career out of software development. Get somebody else to do it for you, but keep a healthy distance if you don't want to get hooked! :)
211
958

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:33 pm

graeme wrote:Tom,

I've been in your shoes! I was clueless with my first Heriot-Watt C programming assignment too (part of electrical and electronic eng degree).

I'd never written a line of code, and was clueless. Simon Ironside did the assignment for me while I watched. Anyway, programming fascinated me so much I demanded he teach me more.

I jacked in the electronics degree and did computing instead. Made a damned career out of software development. Get somebody else to do it for you, but keep a healthy distance if you don't want to get hooked! :)
you weren't offering were you?? :roll: :lol:

(scuttles off to get ironside's number.......)
1995 Volvo 940SE Estate

User avatar
graeme
Posts: 3528
Joined: Tue Mar 15, 2005 11:29 am
Location: Kintore

Post by graeme » Thu Jan 31, 2008 4:35 pm

stdio lib hints at C. C++ would probably have you using the iostream lib.

It was certainly C in my day, and ceejam concurs, so might be worth double checking. Perhaps post the assignment in full?
211
958

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:37 pm

graeme wrote:stdio lib hints at C. C++ would probably have you using the iostream lib.

It was certainly C in my day, and ceejam concurs, so might be worth double checking. Perhaps post the assignment in full?
didn't want to bore you all but here goes....

B31PY2 PRAXIS 2 (Programming for Engineers I)

ASSIGNMENT 1

Alexander Belyaev and Neil Robertson (based on Emanuele Trucco’s notes).


1. THE PROBLEM
Calculating the value of Pi, the ratio between circumference and diameter, has been a classic problem of mathematics throughout history. One of the many formulae proposed in modern times is an infinite series created in 1699 by the English mathematician Abraham Sharp:

<invalid>


Write a program which computes and prints Sharp’s approximation of Pi using a number of terms to be input from the keyboard (via scanf ). The program must also print the difference between the approximation and the value of Pi stored in the macro constant M_PI, defined in <math>.
To help you in this first assignment, here is a sketchy pseudo-code from which you can develop your code. The variable estimate is an accumulator, that is, a variable to which you keep adding iteratively. We also use a variable pow3 in which we build increasing powers of 3 through the iterations, and a variable sign which takes care of the alternating plus and minus.

1. Initialize: estimate = 1; pow3 = 1;
2. Input number of iterations, N
3. For (k=1 to N, increasing k by 1 each time) {
4. if k is even, sign = 1; else sign = -1;
5. pow3 = pow3*3;
6. add k-th term to estimate, using sign and pow3;
7. }
8. Print estimate and estimation error(M_PI - estimate)

To decide whether k is even or odd, use the remainder function of C. Its operator is the percentage sign, %: for example, 11%3 evaluates to 2, as 3*3=9 and 11-9 = 2. So, if val%2 is null, then val is even.

Finally, if you are curious of Pi and its history, including many approximation formulae, check out David Blatner’s concise and well-written The Joy of Pi, Penguin, 1998 (about 7 pounds).

2. SUBMISSION AND MARKING INFORMATION
2.1. WHEN TO SUBMIT
By Friday 8 February (end week 5).
2.2. WHAT TO SUBMIT
The C program file, on a single file. The name of the file must be
<your>_<your>.c
For example, alexander_belyaev.c . Notice the underscore separating first name and family name.
The test data used, on a single file; indicate clearly different sets of data, and explain why you chose them.
The console record of a session, i.e., the contents of the window in which you input data and results appear. This shows how you run the program and what the prompts, input and output look like at run time. Cut and paste the code to a plain text file, or find the code file in your file system to attach it. Do not use the PrtSc facility to capture an image of the screen, which will be several Mbytes!
2.3. HOW TO SUBMIT
Submit the 3 files above as plain attachments to the module’s email account. Do not submit to personal email (lecturers or lab assistants).

2.4. WHAT NOT TO SUBMIT
 Auxiliary files created by the compiler, e.g., xyz.exe or xyz.ide .
 Encrypted or coded files: plain ASCII files only please.
 Very large files, e.g., the image of the screen captured with PrtSc .
 Do not submit to personal email (lecturer or lab assistants).
 Do not use the PrtSc facility (or any other screen capture utility) to capture an image of the screen with your code.

2.5. HOW YOUR CODE IS MARKED
We shall run your code ourselves under Borland to check your results. You must make sure that your code compiles and run with the Borland compiler in EM2.52.
Below is the marking schedule for this assignment: the maximum you can get is 10.

Correct algorithm 3
Correct use of variables, constants, macros 2
Correct flow control and I/O 3
Good layout, correct header 2

2.6. HOW TO CHECK YOUR MARK
Marks will appear on the VLE site section “Assignmentsâ€
1995 Volvo 940SE Estate

User avatar
graeme
Posts: 3528
Joined: Tue Mar 15, 2005 11:29 am
Location: Kintore

Post by graeme » Thu Jan 31, 2008 4:41 pm

Ach, you've got till 8th Feb. Get down the Union and give us a shout about 8pm on the 7th...

:)
211
958

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:41 pm

:lol: :lol: good plan. can't go to union though as I have an hours drive home (or two hours on public transport....) plus that and I'd be in even more sh*t then. Haven't checked yet to see if resits are during FF7.... :shock: :shock:
1995 Volvo 940SE Estate

User avatar
Tom
Posts: 3220
Joined: Mon Mar 06, 2006 5:50 pm
Location: UK

Post by Tom » Thu Jan 31, 2008 4:48 pm

phew, thank fcuk for that..... resits are 14-22nd of August. FF7 starts just after that... :D Wouldn't want to have to redo first year because I was on FF instead of doing exams..... :lol:
1995 Volvo 940SE Estate

Post Reply