Advertisement
at3107

tcs

Oct 26th, 2020
1,916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. void fun(vector<int>& arr)
  2. {
  3.     int n=arr.size(),sum=0;
  4.     bool ok=(n<=20);
  5.     for(int i:arr)
  6.     {
  7.        if(i>120 || i<=0) ok=0;
  8.        if(i<17) sum+=200;
  9.        else if(i<=40) sum+=400;
  10.        else sum+=300;
  11.     }
  12.     if(ok) cout<<"Total Income "<<sum<<" INR"<<endl;
  13.     else cout<<"INVALID INPUT"<<endl;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement