Mr. Ram has a plan of travel to the USA. He wants to keep track of the baggage weight. He will carry a backpack of 7 kg for sure. If he decides to carry one extra baggage, the weight increases by 23 kg. If he decides to carry two extra baggage, the weight increases by 46 kg. Software needs to be developed to decide how much baggage is carried by Ram with the following requirements. a. The number of baggage to be carried has to be captured. b. Check for the number of baggage. c. Compute the total weight.
d. Display the final weight carried by Ram
#include<stdio.h>
int main(){
int n;
int i;
int finalWeight=0;
printf("How much baggage is carried by Ram: ");
scanf("%d",&n);
if(n==1){
finalWeight=7;
}
if(n>1){
finalWeight=7;
for(i=1;i<n;i++){
finalWeight+=23;
}
}
printf("\nThe final weight carried by Ram is: %d kg\n\n",finalWeight);
getchar();
getchar();
return 0;
}
Comments
Leave a comment