Menu Close

Compute the total number of photos at each restaurant

Meera is a food blogger and all her fans craves for the photos of the new restaurants and its dishes . Her manager has asked to tell the exact no of photos she is going to post at the end of weekend.   If she posts 3 photos of a dish and there are n dishes at a restaurant.  

Can you help her calculate the total photos knowing she will go to 1 restaurant each day?

Input: 
7 lines of input  has two values representing the name of the place and no of dishes per week.

Output:
Print the Total number of videos by Joslyn at each restaurant 
#include <stdio.h>
struct video{
  char name[20];
  int dish;
};
int main(){
  struct video clip;
  int total=0,i;
  for(i=0; i<7; i++){
    scanf("%s%d",clip.name,&clip.dish);
    printf("%s : %d\n",clip.name,3*(clip.dish));
    total+=3*clip.dish;
  }
  printf("TOTAL : %d",total);
return 0;
}

INPUT_1:
Shimla  21
Chennai  6
Mysore  4
Kedharnath  23
Amaranth  9
Hydrabad  7
Bangalore  8

OUTPUT:
Shimla:  63
Chennai:  18
Mysore:  12
Kedharnath:  69
Amaranth:  27
Hydrabad:  21
Bangalore:  24
TOTAL:  234


INPUT_2:
delhi  25
Chennai  6
Mumbai  40
Kedharnath  23
Amaranth  19
Hydrabad  17
Bangalore  18

OUTPUT:
delhi:  75
Chennai:  18
Mumbai:  120
Kedharnath:  69
Amaranth:  57
Hydrabad:  51
Bangalore:  54
TOTAL : 444


ILLUSTRATION:

Executed using gcc

πŸ‘† πŸ‘† πŸ‘† The above code doesn’t give output like this as shown in the above picture. That code gives output as soon as input of one line is given.
As this above picture gives clear output perspective of the code and below πŸ‘‡ code which gives clear output and an alternate of the above code is here below πŸ‘‡ πŸ‘‡ πŸ‘‡.

#include <stdio.h>
struct video{
  char name[20];
  int dish;
};
int main(){
  struct video clip[10];
  int i,total=0;
  for(i=0; i<7; i++){
    scanf("%s%d",clip[i].name,&clip[i].dish);
    total += 3*clip[i].dish;
    }
    printf("\n\n");
    for(i=0;i<7;i++){
    printf("%s : %d\n",clip[i].name,3*(clip[i].dish));}
 printf("TOTAL : %d\n\n",total);
return 0;
}

Morae Q!