EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking New
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra New

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Tins in a box

By: mofm  -  Date Submitted: 2009-07-25 17:43:58

  1. #include <stdio.h> //header files
  2. #include <stdlib.h> //header files
  3.  
  4. float cyl_diameter,cyl_height,cyl_radius,cyl_radius2,cyl_answer,cyl_vol,total_cyl_vol,waste //Cylinder variables
  5. float cont_height,cont_width,cont_lenght,cont_area,cont_vol,cont_answer //Container variables
  6. int fitinbox
  7. char buff[20]//buffer
  8. float cylinder_vol (float cyl_height,float cyl_diameter) //Work out
  9. {
  10. cyl_radius = cyl_diameter / 2 // calculate radius
  11. cyl_radius2 = cyl_radius*cyl_radius //calculate radius squared
  12. cyl_answer= 3.14*cyl_radius2*cyl_height//calculate volume
  13. return cyl_answer//return area to main function
  14.  
  15. }
  16.  
  17. float container_vol(float lenght,float height,float width) //works out the container volume
  18. {
  19. cont_answer= lenght*height*width
  20. return cont_answer
  21. }
  22. int amount_fits(float diameter,float lenght,float width,float height) //works out the amount of cylinders that fits in a box
  23. {
  24. int answer
  25. answer = (int)(lenght / diameter) * (int)(width / diameter) * (int)(height / cyl_height)
  26. return answer
  27. }
  28. void main ()
  29. {
  30. do{
  31. printf ("Enter the height of the Cylinder in CM: ")
  32. cyl_height = atof(gets(buff))
  33. if (cyl_height <=0)
  34. {
  35. printf("Height Entered is To low.n")
  36. }
  37. }while(cyl_height <=0)
  38. do{
  39. printf ("Enter the diameter of the Cylinder in CM: ")
  40. cyl_diameter = atof(gets(buff))
  41. if (cyl_diameter <=0)
  42. {
  43. printf("Diameter Entered is To low.n")
  44. }
  45. }while(cyl_diameter <=0)
  46. do{
  47. printf ("Enter the Width of the box in CM: ")
  48. cont_width = atof(gets(buff))
  49. if (cont_width <=0)
  50. {
  51. printf("Width Entered is To low.n")
  52. }
  53. }while(cont_width <=0)
  54. do{
  55. printf ("Enter the Length of the box in CM: ")
  56. cont_lenght = atof(gets(buff))
  57. if (cont_lenght <=0)
  58. {
  59. printf("lenght Entered is To low.n")
  60. }
  61. }while(cont_lenght <=0)
  62. do{
  63. printf ("Enter the Height of the box in CM: ")
  64. cont_height = atof(gets(buff))
  65. if (cont_height <=0cyl_height > cont_height)
  66. {
  67. printf("Height Entered is To low.n")
  68. }
  69. }while(cont_height <=0cyl_height > cont_height)
  70. /*The above code Gets input from user and makes sure the input is above 0 if not it will
  71. tell the use thir is an error and show the input prompt again*/
  72.  
  73. cyl_vol = cylinder_vol(cyl_height,cyl_diameter) // calls function to work out cylinder volume
  74. cont_vol= container_vol(cont_lenght,cont_height,cont_width)//calls function to work out container volume
  75. fitinbox = amount_fits(cyl_diameter, cont_lenght, cont_width, cont_height)
  76. // above calls function to work out the amount of tins that fit in a box
  77. total_cyl_vol = cyl_vol * fitinbox // this works out the total volume used inside the box by the tins
  78. waste = cont_vol - total_cyl_vol //this takes the total volume used by the tins and takes it from the box volume
  79.  
  80. printf("You can fit %d cylinders in boxn",fitinbox) //Shows user the program output
  81. printf ("The waste volume is: %2.2f CM3n",waste)
  82.  
  83.  
  84. }
  85.  
Return to ajax category list

Who's Online

415 Guests, 94 Users
hemiptera, chrbarrol, dark_void, towncrown, EngGi235, blink_212, klesco, vapour, Ausome1, _InSane_, LordHelmet, BnE, N4g4c3N, ThaKeeper, th3punish3r, locust, c0re, iwanlearn, Anderl, ghostraider100, Ghostrider, eliking510, harsha2hack, NotMyOwn, Calumoo, MajorDeath, Rex_Mundi, sabre725, bhoang93, r!v3rTw!ggz, jarlskov, invas10n, snozzberries, Nusquam-Redono-Sapientia, data, zeth, psychomarine, yuka, DnA-Ender, 454447415244, Ultraminor, T-Metal, antibubbles, raven001, aVoid, Psiber_Syn, sirEgghead, Protagoras, niggletandco, Vahakn, Chaplin, BinaryShinigami, zoegeorgica, hacker807, Red_beard, eviscerator, TheFender, InjectioN, totalnoob, Posix, obrigadoo, cul8er, Mcasdf, teehee, Ops, Protest123, Blizer, gabel, Marian, Edika, zofy, Nasrudin, dochaley, TheRetech, j0sh, kcaz, cool.nik, Sand, SaMTHG, fawk3s, rajabaja, avalor, hettoo, mat_2010, barbseven, daandeveloper33, tommy1092, Likantrop7, sajan619, Knuppel, Distorted, Bloodmaster25, buffer, apablo