Solution of Google kickstart sample problem 2022 practice round in c++

 Que- solution of kickstart sample problem practice round?

#include<iostream>
using namespace std;

int main()
{
    int children,bags,total;
   total=0;
    float remaining ;
    cout<<"Total number of children :-";
    cin>>children ;
   
    cout<<"Total number of candy bags :-";
    cin>>bags ;
   
    for(int i=1; i<=bags; i++)
    {
        int candies [i];
     cout<<"candies in C["<<i<<"] bag :- ";
      cin>>candies[i];
      total= total + candies[i];
    }
   
    cout<<"total number of candies are :-"<<total<<endl;
       cout<<"each child gets maximum number of candies is :-"<<total/children <<endl;
   remaining =total-(total/children)*children;
   cout<<"remaining candies are :-"<<remaining;
  
     return 0;
}

Result:-



Post a Comment

Previous Post Next Post