Boat Problem - Vector Resultant

Algorithm

Step 1: Start

Step 2: Declare variables p, q, ang, ang_r, rx, ry, r, gama

Step 3: Take input for force P, force Q and angle between them

Step 4: Convert angle from degrees to radians

Step 5: Calculate Rx using Rx = P*cos(ang_r) + Q

Step 6: Calculate Ry using Ry = P*sin(ang_r)

Step 7: Calculate R using R = sqrt(Rx^2 + Ry^2)

Step 8: Calculate angle gama using atan(Ry/Rx)

Step 9: Convert gama from radians to degrees

Step 10: Print Rx, Ry, R and gama

Step 11: End

Flowchart

graph TD; A([Start]) --> B[Declare variables]; B --> C[/Input P, Q, ang/]; C --> D[Convert ang to radians]; D --> E["Calculate Rx = P*cos(ang_r) + Q"]; E --> F["Calculate Ry = P*sin(ang_r)"]; F --> G["Calculate R = sqrt(Rx^2 + Ry^2)"]; G --> H["Calculate gama = atan(Ry/Rx)"]; H --> I[Convert gama to degrees]; I --> J[/Print Rx, Ry, R, gama/]; J --> K([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 input_output fill:#ffdd44,stroke:#cc9900,stroke-width:2px,color:#000000; class A start; class K stop; class C,J input_output; class B,D,E,F,G,H,I process;

Program

// Boat problem
#include <stdio.h>
#include <math.h>
#define PI 3.1416

int main() {
    int p,q,ang;
    float ang_r,rx,ry,r,gama;
    printf("\nEnter force P : ");
    scanf("%d",&p);
    printf("\nEnter force Q : ");
    scanf("%d",&q);
    printf("\nEnter angle between P and Q : ");
    scanf("%d",&ang);

    ang_r=(ang*PI)/180;
    rx=(p*cos(ang_r))+q;
    ry=p*sin(ang_r);
    r=sqrt((pow(rx,2))+(pow(ry,2)));
    gama=atan(ry/rx);
    gama=(gama*180)/PI;

    printf("\nRx : %0.2f",rx);
    printf("\nRy : %0.2f",ry);
    printf("\nR : %0.2f",r);
    printf("\nAngle made by Rx with horizontal : %0.2f",gama);

    return 0;
}