Wikiposts
Search

Notices
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

C Code Problem

Thread Tools
 
Search this Thread
 
Old 30th October 2006 | 17:02
  #1 (permalink)  
Thread Starter
 
Joined: Jun 2006
Posts: 526
Likes: 0
From: BRISTOL!
C Code Problem

Hey all...

Is anyone here any good at C Programming?...

I have a problem, and if anyone is anygood or can code in C then i will post my problem...

Thanks all...
planecrazy.eu is offline  
Reply
Old 30th October 2006 | 22:23
  #2 (permalink)  
 
Joined: Mar 2004
Posts: 133
Likes: 0
From: Bournemouth, UK
I do mostly C++ programming, so PM me your prob.

Regards
Stoneyx
Stoney X is offline  
Reply
Old 31st October 2006 | 11:55
  #3 (permalink)  
20 Anniversary
 
Joined: Jun 2001
Posts: 238
Likes: 40
From: Bristol,UK
I have done a lot of C, lets see the problem.
under_exposed is offline  
Reply
Old 31st October 2006 | 14:17
  #4 (permalink)  
Fixed+Rotary (aircraft, not washing lines)
 
Joined: Jan 2005
Posts: 357
Likes: 0
From: Peak District, Yorkshire, UK
Let's see it.

Its probably == in place of =

or a missing ;

or a ++ operator in the wrong place...

or it could be something funky such as arrays of pointers to functions which are going to unprotected memory!!
MyData is offline  
Reply
Old 31st October 2006 | 18:37
  #5 (permalink)  
 
Joined: Jul 2002
Posts: 537
Likes: 0
From: Northampton UK
C'mon, post it here!

I used to write C for a living, would be good to "put my coding trousers back on" and have a go!!!

RC
rotorcraig is offline  
Reply
Old 1st November 2006 | 13:43
  #6 (permalink)  
Thread Starter
 
Joined: Jun 2006
Posts: 526
Likes: 0
From: BRISTOL!
Hey, i will post some problems later, i seem to have many =). But its ok if you just help with the C code ones...

I got my initial problem solved by Stoney X.

But i have 12 different tasks i am stuck on, i have completed 30 or so on my own, just getting a little stuck with the more complex things.

I am at Uni right now, but when i get back i will post the problems for all to help =)

Thanks all...
planecrazy.eu is offline  
Reply
Old 1st November 2006 | 20:58
  #7 (permalink)  
Thread Starter
 
Joined: Jun 2006
Posts: 526
Likes: 0
From: BRISTOL!
Hello Again All...

here is my C Code problem...

A Ball is thrown upwards at a speed of 15m/sec, it rises in the air and falls again. Display a table of the heights at intervals of 0.2second from the time it is thrown untill it reashes the ground.

the formula for the height at any point in time is:

height = 15 x time - 4.9 x time(squared)

keep the ball going untill the ball falls below zero

-----------------------------------------------------------------------

Thanks for any help on the above, its got me...

Once completed, there are variables, but i am ok at added different variables in, like changing speed, but the whole sum and loop thing is over my head...

Thanks agian...
planecrazy.eu is offline  
Reply
Old 1st November 2006 | 21:23
  #8 (permalink)  
 
Joined: Jul 2002
Posts: 537
Likes: 0
From: Northampton UK
Okay, here's my punt. Caveats are (1) I haven't written C for 5 years at least and (2) I don't have a C compiler so may not even compile!!!
// Include the Standard IO header
#include <stdio.h>
void main()
{
// t represents time
// h represents height of the ball
float t,h;
// initialise both to zero (ie at time 0, height is 0)
t=0;
h=0;
// loop until height goes negative (ball falls below zero)
while (h>=0)
{
// height = 15 x time - 4.9 x time(squared)
h=(15*t)-(4.9*t*t);
// print time, height and a new line
printf("%f %f\n",t,h);
// add 0.2 seconds to time
t=t+0.2;
}
}
RC

Last edited by rotorcraig; 1st November 2006 at 23:24.
rotorcraig is offline  
Reply
Old 1st November 2006 | 21:27
  #9 (permalink)  
 
Joined: Jul 2002
Posts: 537
Likes: 0
From: Northampton UK
Well it runs ... output is
0.000000 0.000000
0.200000 2.804000
0.400000 5.216000
0.600000 7.236000
0.800000 8.864000
1.000000 10.100000
1.200000 10.944000
1.400000 11.396000
1.600000 11.456000
1.800000 11.124000
2.000000 10.399999
2.200000 9.283998
2.400000 7.775997
2.600000 5.875996
2.800000 3.583995
3.000000 0.899993
3.200001 -2.176008
Found an online C compiler!!!!

DJGPP Public Access Cross-Compiler

RC
rotorcraig is offline  
Reply
Old 2nd November 2006 | 11:06
  #10 (permalink)  
Thread Starter
 
Joined: Jun 2006
Posts: 526
Likes: 0
From: BRISTOL!
Thanks for that Craig, the app works great, and thanks for the anotations, i now actually understand whats going one, so thanks, your better than my Uni teacher...

I use Dev C++ from http://www.bloodshed.net

Its a compiler and GUI wordpad type of thing, and its free...

Thanks again...
planecrazy.eu is offline  
Reply
Old 11th December 2006 | 10:53
  #11 (permalink)  
Thread Starter
 
Joined: Jun 2006
Posts: 526
Likes: 0
From: BRISTOL!
Hey Guys/Gals

I need some help once again...

I have to make a programme that inputs can be entered in, stored, deleted, edited and added after the initial add, but for some reason i am having issues with adding extra fields to an array.

Here is the flow,

User inputs how many records, a loop is run until x is reached and the loop increased the values of the array each time.

I need to add extra records to the array after records have first been input. I guess i need some way to find out how many records have been allocated and retreive them and add one to the last record?

Im not 100% sure, so anyhelp would be of use.

Here is what i am doing
# Built a programme to enter in the names and ages of friends. The programme must be able to add x friends, one friend, and 20 friends in bulk. It must also have a list feature and search. The records must also be able to be edited and deleted. In addition, the programme must be able to add records after initial records have been entered.

Thanks again,...
planecrazy.eu is offline  
Reply

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.