You are on page 1of 3

Connect Path

The byteXL company is conducting a straight line contest. In the contest, every
participant have to draw a straight line Passing through two persons standing in an
open area. Person1 is standing at (X1,Y1) position and person2 is standing at (X2,Y2)
position. The judge for this contest is a math lover. So, before drawing the straight line
he is asking every participant to write the line equation.

Input format:
The first line contains X1,Y1.
The next line contains X2,Y2.

Output format:
Print the line equation.

Sample Input:
32
26

Output:
4x + 1y = 14

Sample Input - 2:
45
67

Output
2x - -2y = -2

solution

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef struct Point{
double first;
double second;
}point;
void lineEqu(point p1,point p2){
double a = p2.second - p1.second;
double b = p1.first - p2.first;
double c = a * (p1.first) + b * (p1.second);

if (b < 0) {
printf("%.0lfx - %.0lfy = %.lf",a,b,c);
}
else {
printf("%.0lfx + %.0lfy = %.lf",a,b,c);
}
}
int main(){
point A,B;
scanf("%lf %lf",&A.first,&A.second);
scanf("%lf %lf",&B.first,&B.second);
lineEqu(A,B);
return 0;
}

Hypotenuse
Given two sides of a right angeled triangle find the hypotenuse.

Input format:
The first line contains two sides of right angeled triangle.

Output format:
Print the hypotenuse.

Sample Input:
34

Output:
5.00

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

int main(){
int s1,s2;
scanf("%d %d",&s1,&s2);
printf("%.2f",sqrt(pow(s1,2)+pow(s2,2)));
return 0;
}

Number of People
Due to covid many of the restrictions come into action in many public places. Likewise
in the class rooms also teachers asking their students to sit by maintaining distance
between them. In a given class having width W and length L you have to find how many
students can sit in a class by maintaining a circular distance having R radius.

Input format:
The first line contains W and L.
The next line contains R.

Output format:
Print how many students can sit in a class.

Sample Input:
10 10
2

Output:
4

Explanation:
The diameter of the circle is 4.
Width wise 2 students can sit and lenght wise 2 students can sit. So totally 2*2 = 4
students can sit in the class.

solution:
#include<stdio.h>

int main(){
int s1,s2;
scanf("%d %d",&s1,&s2);
int r;
scanf("%d",&r);
int d = 2*r;
printf("%d",(s1/d)*(s2/d));
return 0;
}

You might also like