Practice problems for C programming language

   

Hey guys once again welcome to the Decoders blog, I hope you all are doing well and today I'm present with another logic but this time we will practice some problems from edabit you can also go through edabit it is a free coding platform where you can improve your coding skills and learn new things .............


//You work in a toy car workshop, and your job is to build toy cars from a
collection of parts. Each toy car needs 4 wheels, 1 car body, and 2 figures of
people to be placed inside. Given the total number of wheels, car bodies and figures
available, how many complete toy cars can you make?

/*Sample input
(4,1,2) number of cars that can be created is 1
(43,15,87) number of cars that can be created is 10
*/

#include<stdio.h>
int main()
{
    int wheel,body,fig,cars;
    printf("Enter the values\n");
    scanf("%d%d%d",&wheel,&body,&fig);

    int n1 =wheel/4;
    int n2 =body/1;
    int n3 =fig/2;

    if(n1<n2 && n1<n3)
    {
        cars=n1;
        printf("Number of cars =%d",cars);
    }
    if(n2<n1 && n2<n3)
    {
        cars=n2;
        printf("Number of cars =%d",cars);
    }
    if(n3<n2 && n3<n1)
    {
        cars=n3;
        printf("Number of cars =%d",cars);
    }

    return(0);

}

Comments

Popular Posts