home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

C Program

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2469
Discussions: 200,959, Posts: 2,379,552, Members: 246,330
Old March 13th, 2007, 03:35 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Mar 2007
Posts: 3
C Program

Well I know I am a newbie to this forum, so sorry if I am posting in the wrong spot, I spent a little bit trying to look for the C part of this Forum, but couldn't find one (guess I am either blind or lazy). Well I need some help I have a program started but can't seem to finish it. This is the program requirements:
Cross-sectional area: base * height
Moment of inertia: (base * height3) / 12
Section Modulus: (base * height2) / 6

The company makes lumber with base sizes of 2, 4, 6, 8, 10 inches. The height sizes are
2, 4, 6, 8, 10, 12 inches. All combinations are possible. Produce a table as below showing
the computed engineering properties, using proper formatting. (Use for/while/do-while
loops, whatever suits you.) Use flow charts to first describe the basic problem solution
(details of formatting can be omitted).

Input data for the algorithm: Base and Height (predefined – no input from user)
Output: A table as shown below. (Only partial table shown – compute the entire table)

Lumber Size Cross-sectional Moment of Section
Base * Height Area Inertia Modulus
---------------- ------------------ ---------------- ----------------
2 * 2
2 * 4
2 * 6
2 * 8
2 * 10
2 * 12
4 * 2
4 * 4
4 * 6
4 * 8
4 * 10
4 * 12
6 * 2
6 * 4
6 * 6
.
.

Here is the program I have right now:
#include<stdio.h>
int main ()
{
printf("Lumber Size"; "Cross-Sectional Area"; Moment of Inertia"; "Section Modulus");
for (counter=2; counter<=12; counter++2)
printf("%d"; "%3d"; "%10.2f"; "%10.2f", counter);
return 0;
}

So any help ASAP would be great. I probably will have more programs I'll need help with so I'll just keep posting them in this thread. Thanks anyone, this will help me a lot. I am a beginner in programing by the way.
Taros14 is offline   Reply With Quote
Old March 13th, 2007, 03:45 PM     #2 (permalink)
Anime Otaku
 
RobRich's Avatar
 
Join Date: Oct 2001
Location: Tampa, FL USA
Posts: 108,975
Blog Entries: 15
Welcome to TechIMO. I have moved your thread to the programming forum for better community visibility.
__________________
Robert Richmond | TechIMO Community Relations Director
Infinite perceptions. One reality.
FanFiction.Net - Unleash your imagination.
RobRich is online now   Reply With Quote
Old March 13th, 2007, 03:46 PM     #3 (permalink)
Junior Member
 
Join Date: Mar 2007
Posts: 3
Ok thanks, yeah sorry, didn't know about section.
Taros14 is offline   Reply With Quote
Old March 13th, 2007, 03:49 PM     #4 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
try webmastering and programming forum - as far as you are concerned you might have to pay me to give you the answer if u are going to continue to put programs up... but i will give you a hint - you a close, but Start at the greatest piece of lumber, and keep filling the space until u are down to 2 inches and then there is no space left :P

(on the assumption that you have a Space to be field using the greatest piece of lumber first)

also a bit more information would be nice

also after re-reading you thread again and again you can basically ignore what i have said above -

so i can understand u need to;

User Inputs Values - base and height
Using those values u have to find the Inertia, etc etc using those calculations?

Last edited by exally : March 13th, 2007 at 03:57 PM.
exally is offline   Reply With Quote
Old March 13th, 2007, 03:55 PM     #5 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
you will need a nested for loop within your current for loop of basically the same style - move all calculations and output into that nested loop.

then use something like ((double)counter*(double)counter2) / 12 - to calc inertia
all i am doing there is typecasting the counter to a double so when you do the calculations you will recieve a double back (which u can they convert to float) then print that to the screen
exally is offline   Reply With Quote
Old March 13th, 2007, 04:30 PM     #6 (permalink)
Super F@D Folder
 
Join Date: Jun 2004
Posts: 5,083
Send a message via AIM to sr71000
you'll need 2 loops....the outer loop iterates though your base sizes.....the inner loop to iterate through your height sizes. give that a shot and if you can't get it from there maybe we'll help more (we don't really like doing homework though...you ought to try and figure it out yourself and come to us if you REALLY can't figure it out with MUCH more specific questions).
sr71000 is offline   Reply With Quote
Old March 13th, 2007, 04:33 PM     #7 (permalink)
Junior Member
 
Join Date: Mar 2007
Posts: 3
Well thank you. I thought I needed 2 "for" statements, but really wasn't sure. I like do ... while loops, and detest "for" even if they are smaller. I have asked the prof for help, and she helped me a bit, but I am still having trouble. I think I got it now though, thanks all!
Taros14 is offline   Reply With Quote
Old March 13th, 2007, 04:42 PM     #8 (permalink)
Super F@D Folder
 
Join Date: Jun 2004
Posts: 5,083
Send a message via AIM to sr71000
learn to love for loops...they really do have their place...i use them more than any other loops!
sr71000 is offline   Reply With Quote
Old March 13th, 2007, 05:00 PM     #9 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
while loops are theoretically quicker sr7100 - and better too if u have multiple escape clauses but it all depends in the situation, navigating an array or something similar definately use for loops also do-while loops i very rarely see

though the best loop to learn to do is the function recursion, they are just plain sadistic
exally is offline   Reply With Quote
Old March 13th, 2007, 06:01 PM     #10 (permalink)
Super F@D Folder
 
Join Date: Jun 2004
Posts: 5,083
Send a message via AIM to sr71000
I'm thoroughly in love with recursion. I had it stuffed down my throat last semester and now that i understand it....life is SOOO much easier when it comes to programming. You still attempt to use iteration when possible for the sake of resources but if it's a small problem then recursion is amazing. The trick is learning to turn it into tail recursion if possible...save yourself a CRAPLOAD of resources that way as the problem gets large!!!
sr71000 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this program ok? cpembo Security and Privacy Issues 6 September 11th, 2005 05:17 PM
Need Program! eminem_rh25 General Tech Discussion 1 July 1st, 2005 06:10 PM
looking for a program... jpiermarini General Tech Discussion 7 April 25th, 2005 04:27 PM
C Program magicz69 General Tech Discussion 1 July 12th, 2004 01:12 PM
i Need program... nice moon General Tech Discussion 2 June 16th, 2002 07:53 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2976)
The disrespect of Obama by Russian .. (45)
Making Health Care Worse (181)
Wireless Televisions. (12)
CPU fan stops spinning randomly (10)
Regular Build (11)
windows 7 problem (7)
Laptop with wireless problem. (5)
windows vista security holes (13)
Is the PSU I received dead? (13)
Point and Shoot Camera Suggestions. (5)
Print spooler problem (16)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Recent Discussions
Modern Warfare 2: Who Bought It? (65)
Point and Shoot Camera Suggestions. (5)
CPU fan stops spinning randomly (10)
Is the PSU I received dead? (13)
Print spooler problem (16)
Nvidia GTX 260 problem (0)
windows vista security holes (13)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
Open With ..... Win7 (1)
webcam (0)
upgrade for hp a6101 (0)
Laptop with wireless problem. (5)
tv not turn on-makes clicking sound (2)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)


All times are GMT -4. The time now is 11:01 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28