Write in C language Description There is snail climbing on the wall from bottom, wall is 10 meter height. every day the snail climb up 4 meter, and slide down 3 meter at the night. In day 7 the snail climb up to the top of the wall. Please write a program, read in height of the wall, how many meter the snail climb up a day, how many meter the snail slide down at night, give the answer of which day the snail climb up to the top of the wall. Input Input consist three integer, first is height of the wall, second is meter of snail climb up a day, third is meter the snail slide down at night. Output Out a number represent in which day the snail will climb to top of the wall. Output -1 if the snail can never climb up the top. Sample Input 1 10 4 3 Sample Output 1 7 check_circle Expert Answer (had to many errors) please fix Step 1 #include class asd{ int main { int up = 3; int down = 2; int dept_well = 30; int distance_covered = 0 ; for(int i=1; i<=dept_well; i++) { if(up == dept_well) { printf("Snail is out of the well and the days count is "+i); break; } distance_covered = up-down; up = up + distance_covered; down = down + distance_covered; } return 0; } }
Write in C language
Description
There is snail climbing on the wall from bottom, wall is 10 meter height. every day the snail climb up 4 meter, and slide down 3 meter at the night. In day 7 the snail climb up to the top of the wall. Please write a program, read in height of the wall, how many meter the snail climb up a day, how many meter the snail slide down at night, give the answer of which day the snail climb up to the top of the wall.
Input
Input consist three integer, first is height of the wall, second is meter of snail climb up a day, third is meter the snail slide down at night.
Output
Out a number represent in which day the snail will climb to top of the wall. Output -1 if the snail can never climb up the top.
Sample Input 1
10 4 3Sample Output 1
7
Expert Answer (had to many errors) please fix
#include<stdio.h>
class asd{
int main
{
int up = 3;
int down = 2;
int dept_well = 30;
int distance_covered = 0 ;
for(int i=1; i<=dept_well; i++)
{
if(up == dept_well)
{
printf("Snail is out of the well and the days count is "+i);
break;
}
distance_covered = up-down;
up = up + distance_covered;
down = down + distance_covered;
}
return 0;
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images