EG Information
Training Missions
Knowledge Bank
Pimp Us Out!
Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.
|
| |
Affiliates
|
|
Enigma Group's Code Bank
Tins in a boxBy: mofm - Date Submitted: 2009-07-25 17:43:58 #include <stdio.h> //header files
#include <stdlib.h> //header files
float cyl_diameter,cyl_height,cyl_radius,cyl_radius2,cyl_answer,cyl_vol,total_cyl_vol,waste //Cylinder variables
float cont_height,cont_width,cont_lenght,cont_area,cont_vol,cont_answer //Container variables
int fitinbox
char buff[20]//buffer
float cylinder_vol (float cyl_height,float cyl_diameter) //Work out
{
cyl_radius = cyl_diameter / 2 // calculate radius
cyl_radius2 = cyl_radius*cyl_radius //calculate radius squared
cyl_answer= 3.14*cyl_radius2*cyl_height//calculate volume
return cyl_answer//return area to main function
}
float container_vol(float lenght,float height,float width) //works out the container volume
{
cont_answer= lenght*height*width
return cont_answer
}
int amount_fits(float diameter,float lenght,float width,float height) //works out the amount of cylinders that fits in a box
{
int answer
answer = (int)(lenght / diameter) * (int)(width / diameter) * (int)(height / cyl_height)
return answer
}
void main ()
{
do{
printf ("Enter the height of the Cylinder in CM: ")
cyl_height = atof(gets(buff))
if (cyl_height <=0)
{
printf("Height Entered is To low.\n")
}
}while(cyl_height <=0)
do{
printf ("Enter the diameter of the Cylinder in CM: ")
cyl_diameter = atof(gets(buff))
if (cyl_diameter <=0)
{
printf("Diameter Entered is To low.\n")
}
}while(cyl_diameter <=0)
do{
printf ("Enter the Width of the box in CM: ")
cont_width = atof(gets(buff))
if (cont_width <=0)
{
printf("Width Entered is To low.\n")
}
}while(cont_width <=0)
do{
printf ("Enter the Length of the box in CM: ")
cont_lenght = atof(gets(buff))
if (cont_lenght <=0)
{
printf("lenght Entered is To low.\n")
}
}while(cont_lenght <=0)
do{
printf ("Enter the Height of the box in CM: ")
cont_height = atof(gets(buff))
if (cont_height <=0 cyl_height > cont_height)
{
printf("Height Entered is To low.\n")
}
}while(cont_height <=0 cyl_height > cont_height)
/*The above code Gets input from user and makes sure the input is above 0 if not it will
tell the use thir is an error and show the input prompt again*/
cyl_vol = cylinder_vol(cyl_height,cyl_diameter) // calls function to work out cylinder volume
cont_vol= container_vol(cont_lenght,cont_height,cont_width)//calls function to work out container volume
fitinbox = amount_fits(cyl_diameter, cont_lenght, cont_width, cont_height)
// above calls function to work out the amount of tins that fit in a box
total_cyl_vol = cyl_vol * fitinbox // this works out the total volume used inside the box by the tins
waste = cont_vol - total_cyl_vol //this takes the total volume used by the tins and takes it from the box volume
printf("You can fit %d cylinders in box\n",fitinbox) //Shows user the program output
printf ("The waste volume is: %2.2f CM3\n",waste)
}
|
| Return to
ajax category list |
|
|
Who Visited EnigmaGroup Today?
1581 Guests, 270 Users (182 Spiders)
limited, Hessesian, whisperer, whoami, hackaday, Rex_Mundi, trueorfalse, strudels, Bumpadjuppy, DrOptix, Klosse, InjectioN, blackknight911, Effomeidonize, Distorted, JohnMalkovitzch, TheHarrisonW, Obop, hkevin, ellisp, Vreality2007, advenlydent, zach, ddxc, suetekh, Vengeance987, m0rt, 2345, electro-technic, riesenjoe, IvanDimitriev, nmobin27, RomeoG, timetrust, 2142, 3ntr0py, BillTuer, advilapyday, lotato, lonely.connection, CloverCipher, vnd, aurena, rospark, valy1177, Blavatsky, learning, st3alth, Partisan, K0gller, fitz, Jayjay, psychomarine, Vspectrum, San Marino, TinCardinal, brunoriversyhn, code-g, yshiau, Psiber_Syn, Seasharp, obencefoozy, SlayingDragons, Link-, tinuigimeni, jasonbourne, Fred, GothicLogic, somebody777, Meonkzt, CJ_Omaha, jearrorne, cls777, unsugsNashy, Balksnuntails, Sir D. Naut, batsbargy, Rik, Macabre, Nightraven, Iccyx, Repuhlsive, vipervince2002, Janomatrix, lol, veceattainc, techno, Exclaw, Nikhil, evjfvir967nj, Mod777, dark_void, nermtode, Tjm, bjy1997, hecky, saraf, elprof, damoniceht, trik, jordan86, SnoopSky, dan_movie, OnetInsolefon, darkfire1515, seojlhmyrhwh, Thoplehap, MaxMeier, 1028rajeev, Abhinav2107, autotuneuser, alexelixir, Tauya, Jozinbrejl, kernel_mod, quolc, anandoump, vladavlada, Taicadine, AnnaNoult, GreenTiger, baripadatimes, Ewing, Blackbeard, thepuppeteer, BON-SELE, hak4r, Unotohumsmush, NIGHTWOLF, m4f10, avacraft, becool, thecoder, n01se, alpha1, saki, ObesseJew, ActictGlync, sajan, unicornrainbow, Domihoolbob, matt.14, max66, SnowFury, Spud101, myfabregas, Ausome1, kajman121, Frudopvia, ideveloper6, OLOLO, Bugshuppy, lamb, VagWirura, LialiTiTviors, Ordeptpen, scifics, Pozycj-Z21, Gkjt, interPuscruse, aaftab, TheCheeseDemon, blackcyxx21, jollyjimbo, N4g4c3N, rineDriekly, Rap70r, Xargos, flarornEral, ovetz13, sonu sahu, Breezy, emitleBen, Hackpad, JWTSR, nicyun, kaizo, itevainee, luke460, AverageJoe, zeratu92, litbk, Mr.Pickle, mannavard1611, LoopyLion, NexusVos, mtroscheck, burberrybagsjr, nikedunksxm, xordux, jeho, Lonewolf034, Dragonite, nhorton, Reloaded, Odile, Kaptain_k1rk, Teefelltugh, grizzly, posthuman01, jakesboy2, pwnpwnlolz, Sabo, Lakhoamnmek, Røgue, dot_Cipher, mori, snickerless1, cart1m, Xendz, KELATALFTUS, hubris, Afrika, welepocourl, carpinteyrofbt, ReottphoffBom, Reahastegah, pumashoesld, pdanielt, dmac006, DnA-Ender, Red Fox, couptupleakb, ryanjcrook, iMaxx, sh3llcod3, TimHortons, EmilaHapsaums, Feld Grau, burgeoningneophyte, Maroonhat, CookieAu, tinkansinar, Mitodina, timberlandoutletlufc, zsefvy, guccioutletox, AlexDiru, AbercrombieFitchhl, Ryuske, r0z4, slchill, kalak55, Ph4Kt480ii, beefarn, Jigoku, WrossyJes, pollolololo, ZepSung, Fragility, jell0, C9019, Othrguy, Noticon, KIKNWING, llasarus, mdubz, leah027, iellswo, MAZI_, Estilaamoli, subtentar, Trollorful, no, nas0151, Traybo, howisthechicken, thethird3y3, Somethingclever, marplusz |
| |
|
|
|
|
|