# Codechef Practice | Week 2

## 1. Sum of Digits: FLOW006

``````// THIS code starts from INT MAIN so copy paste from here only

#include<iostream>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int sum = 0;
while(n!=0)
{
int r = n%10;
sum+= r;
n /= 10;
}

cout<< sum<< endl;
}

return 0;
}``````

## 2. First and Last Digit: FLOW004

``````#include<iostream>
using namespace std;
int main()
{

int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int rem = n%10;
while(n>9)
{
n = n/10;
}
cout<< n+rem<< el;
}

return 0;

}``````

## 3. Area OR Perimeter: AREAPERI

``````#include<iostream>
using namespace std;

int main() {
int l,b,area,peri;
cin>>l>>b;
area = l*b;
peri = 2*(l+b);
if(area>peri)
{
cout<< "Area"<< endl<< area;
}
else
if(area==peri)
{
cout<< "Eq"<< endl<< area;
}
else
{
cout<< "Peri"<< endl<< peri;
}

return 0;
}``````

## 4. Coldplay: SLOOP

``````// code start from int main so paste from here
#include<iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int m,s;
cin>>m>>s;
cout<< m/s<< endl;
}
return 0;
}``````

## 5. Summer Heat: COCONUT

``````#include<iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum;
sum=(c/a)+(d/b);
cout<< sum<< endl;
}
return 0;
}``````

KUIZZER Helping Educational website for Youngers

Welcome To Kuizzer!

KUIZZER - Helping Educational Website for YoungersYour Post is going to visible like this

Here, Your Promotional Details are going to visible for others whenever they visit the site !