Friction Problem - Force Calculation

Algorithm

Step 1: Start

Step 2: Take inputs - Weight (w), Angle (ang), Coefficient of Friction (cof), and Direction (dir)

Step 3: Convert angle to radians

Step 4: Based on the direction:

  • If upward, use formula: P = (cof * w) / (cos(angle) + cof * sin(angle))
  • If downward, use formula: P = (cof * w) / (cos(angle) - cof * sin(angle))

Step 5: Display the required force

Step 6: End

Flowchart

graph TD; A([Start]) --> B[/Input weight, angle, friction, direction/]; B --> C[Convert angle to radians]; C --> D{Direction of force}; D -->|Upward| E[Use Load-Up Function and \nCompute Force]; D -->|Downward| F[Use Load-Down Function and \nCompute Force]; E --> G[/Display result/]; F --> G; G --> I([End]); classDef start fill:#00cc44,stroke:#006622,stroke-width:2px,color:#ffffff; classDef stop fill:#ff4444,stroke:#cc0000,stroke-width:2px,color:#ffffff; classDef process fill:#4488ff,stroke:#0044cc,stroke-width:2px,color:#ffffff; classDef decision fill:#ff8844,stroke:#cc4400,stroke-width:2px,color:#ffffff; classDef input_output fill:#ffdd44,stroke:#cc9900,stroke-width:2px,color:#000000; class A start; class I stop; class C,E,F,H process; class B,G input_output; class D decision;

C Program

#include <stdio.h>
#include <math.h>

#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
float loadup(int, float, float);
float loaddown(int, float, float);
int main() {
    int w, ang, dir;
    float ang_r, p, cof;
    printf("Enter weight of the block in N: ");
    scanf("%d", &w);
    printf("\nEnter Direction of the Force in Degrees: ");
    scanf("%d", &ang);
    printf("\nEnter Coefficient of Friction: ");
    scanf("%f", &cof);
    printf("\nEnter direction of Force:\n1 - Upward\n2 - Downward\nChoice: ");
    scanf("%d", &dir);
    
    ang_r = (ang * PI) / 180;
    
    switch(dir) {
        case 1:
            p = loadup(w, ang_r, cof);
            printf("Force required to pull the block: %.2f N\n", p);
            break;
        case 2:
            p = loaddown(w, ang_r, cof);
            printf("Force required to pull the block: %.2f N\n", p);
            break;
        default:
            printf("Invalid choice. Please enter 1 or 2.\n");
            break;
    }
    return 0;
}
         


float loadup(int w1,float a1,float cof1)
{
    float p1;
    p1=(cof1*w1)/((cos(a1))+(cof1*sin(a1)));
    return p1;
}

float loaddown(int w1,float a1,float cof1)
{
    float p1;
    p1=(cof1*w1)/((cos(a1))-(cof1*sin(a1)));
    return p1;
}

                

Test Case Output
Enter weight of the block in N: 400
Enter Direction of the Force in Degrees: 55
Enter Coefficient of Friction: 0.35
Enter direction of Force:
1 - Upward
2 - Downward
Choice: 1

Force required to pull the block: 167.68 N