Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Cdd
Language: C/C++
Code:

#include<stdio.h>
int volume(){
     int dim,dim1,dim2,tvolume;
     printf("How many dimensions? ");
     scanf("%d",&dim);
     switch(dim){
     case 0:
          tvolume=27000;
          break;
     case 1:
          printf("Enter dimension 1: ");
          scanf("%d",&dim1);
          tvolume=dim1*30*30;
          break;
          
     case 2:
          printf("Enter dimension 1: ");
          scanf("%d",&dim1);
          printf("Enter dimension 2: ");
          scanf("%d",&dim2);
          tvolume=dim1*dim2*30;
          break;     
          
     }
     
return(tvolume);
     
}
int main(){
     int carton,i,sum=0,total;
     printf("How many cartons? ");
     scanf("%d",&carton);
     for(i=0;i<carton;i++){
     total=volume();
     sum=sum+total;          
     }
     if(sum>2000000){
         printf("Volume limit exceeded");
     }
     else{
         printf("Volume allowed");
     }
}
Comments: