A smart city which is equipped with the latest technologies such as self-driving cars (SD), robots, UAV,and many others are shown in Fig.1. Consider a UAV which is deployed to monitor agriculture field andcommunicate with the robot, which can take an N number of different locations (A, B, C, and N) (referFig.1).Develop a C-script that calculates the distance between reference point R (1,3) of a UAV and robotlocations A, B, C, and N number of locations.N is the (non- zero) LSD of your mobile number.For 0 < LSD < 4 then take [N = (2LSD ) *2], and if LSD = 0, take [ N = (2LSD) *4+3]
A smart city which is equipped with the latest technologies such as self-driving cars (SD), robots, UAV,and many others are shown in Fig.1. Consider a UAV which is deployed to monitor agriculture field andcommunicate with the robot, which can take an N number of different locations (A, B, C, and N) (referFig.1).Develop a C-script that calculates the distance between reference point R (1,3) of a UAV and robotlocations A, B, C, and N number of locations.N is the (non- zero) LSD of your mobile number.For 0 < LSD < 4 then take [N = (2LSD ) *2], and if LSD = 0, take [ N = (2LSD) *4+3]
1 Answers
#include<stdio.h> #include<math.h> float distance(); int main() { int num=0, i=0, a=0, b=0 ; float res; printf("Enter total no of locations: "); scanf("%d", &num); for(i=1;i<=num;i++){ a = 0; b = 0; printf("\n\nEnter (x2, y2) for %d location: ",i); scanf("%d,%d", &a, &b); res = distance(a,b); printf("\nTotal distance between R(1,3) & (%d, %d): %f\n", a, b, res); } return (0); } float distance(int x2, int y2){ // Base points int x1=1, y1=3; float t_d; t_d = sqrt(pow((x2-x1),2)+pow((y2-y1),2)); return t_d; }