Raju lives in a colony. On his 9th birthday, his father gift him a Pogo Stick. He
is so excited to play with pogo stick. The pogo stick
moves one unit per jump. He wanders around his house jumping with pogo sticks. He
wants to show the pogo stick to his friends and
decide to go using pogo sticks. Write a program to find number of jumps needed to
reach his friends house. Assume that Rajus house is
in the location (3,4). Input and Output Format: Input consists of two integers x,
y. The x and y corresponds to x and y coordinates of his
friends house. Output is an integer - the number of jumps he needs to reach his
friends house.
Solution
#include <stdio.h>
#include <math.h>
int main ()
{
int x1=3,y1=4,x2,y2;
float power,power1,power2,sqr;
scanf ("%d",&x2);
scanf ("%d",&y2);
power1=pow((x2-x1),2);
power2=pow((y2-y1),2);
power=power1+power2;
sqr=sqrt(power);
printf ("Raju needs %0.f jumps",sqr);
return 0;
}
Sample Input
5 6
Sample Output
Raju needs 3 jumps
is so excited to play with pogo stick. The pogo stick
moves one unit per jump. He wanders around his house jumping with pogo sticks. He
wants to show the pogo stick to his friends and
decide to go using pogo sticks. Write a program to find number of jumps needed to
reach his friends house. Assume that Rajus house is
in the location (3,4). Input and Output Format: Input consists of two integers x,
y. The x and y corresponds to x and y coordinates of his
friends house. Output is an integer - the number of jumps he needs to reach his
friends house.
Solution
#include <stdio.h>
#include <math.h>
int main ()
{
int x1=3,y1=4,x2,y2;
float power,power1,power2,sqr;
scanf ("%d",&x2);
scanf ("%d",&y2);
power1=pow((x2-x1),2);
power2=pow((y2-y1),2);
power=power1+power2;
sqr=sqrt(power);
printf ("Raju needs %0.f jumps",sqr);
return 0;
}
Sample Input
5 6
Sample Output
Raju needs 3 jumps
Hello Everyone,
ReplyDeleteI like this article, It is very useful to me. I’m working with 1daypainters. pro is the best Calgary Painting Company providing Stucco Painting Calgary, Exterior House Painting Calgary & Knock Down Ceiling Calgary. Hire us if you are looking for Stucco Painters, House Painters & Calgary Painters.
Calgary house painting
Same Day Painting Calgary
Calgary Painting Companies
Calgary Painting Companies
Painting Company Calgary
Nice post, check out the best pogo stick for 9 year old
ReplyDelete