Please Install our Kuizzer app ! ---- Doesn't Know how to install click here!

Codechef Practice | Week 2

CODECHEF SOLUTION

Week 2 link: Chandigarh University – Practice – Week 2 Coding Competition | CodeChef

1. Sum of Digits: FLOW006

link: Sum of Digits – Submit | CodeChef

// 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

link: First and Last Digit – Submit | CodeChef

#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


link: Area OR Perimeter – Submit | CodeChef

#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;
    }
    
	// your code goes here
	return 0;
}

4. Coldplay: SLOOP

link: Coldplay – Submit | CodeChef

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

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

5. Summer Heat: COCONUT

link: Summer Heat – Submit | CodeChef

#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;
}

* The material and content uploaded on this website are for general information and reference purposes only and don’t copy the answers of this website to any other domain without any permission or else copyright abuse will be in action.

Please do it by your own first!

DMCA.com Protection Status

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
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 !

AdBlock Detected

Looks like you are using an ad-blocking browser extension. We request you to whitelist our website on the ad-blocking extension and refresh your browser to view the content.

Check out our merchandise, available at kuizzer.in

X
0
Would love your thoughts, please comment.x
()
x