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:
Step 5: Display the required force
Step 6: End
#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; }
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