_ap_ufes{"success":true,"siteUrl":"techblix.com","urls":{"Home":"http://techblix.com","Category":"http://techblix.com/category/3g-4g-plans/","Archive":"http://techblix.com/2017/02/","Post":"http://techblix.com/use-reliance-jio-4g-sim-3g-devices-tricks-proven-work-jio-4g-sim/","Page":"http://techblix.com/guestsponsored-posts/","Attachment":"http://techblix.com/use-reliance-jio-4g-sim-3g-devices-tricks-proven-work-jio-4g-sim/j43g-10/","Nav_menu_item":"http://techblix.com/indianist-2/","Custom_css":"http://techblix.com/sahifa/","Wpcf7_contact_form":"http://techblix.com/?post_type=wpcf7_contact_form&p=5633","Wysijap":"http://techblix.com/?wysijap=subscriptions","Feedback":"http://techblix.com/?post_type=feedback&p=7719"}}_ap_ufee
Breaking News

Tcs CodeVita Sample Question Solved

Tcs CodeVita Sample Question Solved:

Tcs CodeVita Sample Question Solved

Problem: A futuristic company is building an autonomous car. The scientists at the company are training the car to perform Reverse parking. To park, the car needs to be able to move in backward as well as forward direction. The car is programmed to move backwards B meters and forwards again, say F meters, in a straight line. The car does this repeatedly until it is able to park or collides with other objects. The car covers 1 meter in T units of time. There is a wall after distance D from car’s initial position in the backward direction.

The car is currently not without defects and hence often hits the wall. The scientists are devising a strategy to prevent this from happening. Your task is to help the scientists by providing them with exact information on amount of time available before the car hits the wall.

 

Tcs CodeVita Sample Question Solved

Sample Solution in C Programming:

#include<stdio.h>
int main()
{
 int D,F,B,T,d,t;
 printf("Distance of wall from car");
 scanf("%d",&D);
 printf("Forward Distance moved by car");
 scanf("%d",&F);
 printf("Backward Distance moved by car");
 scanf("%d",&B);
 printf("Unit of time taken to cover 1 meter");
 scanf("%d",&T);
 if(F>B)
  printf("Car wont hit the wall");
 else if(D<F)
  printf("Time left is %d units",D*T);
 else
 {
  d=D;t=0;
  while(d>0)
  {
   d-=B;
   t+=(B);
   if(d>0)
   {
    d+=F;
    t+=F;
   }
  }
  if(d==0)
   printf("Time left is %d units",t*T);
  else
  {
   d+=B;
   t-=B;
   while(d!=0)
   {
    d--;
    t++;
   }
   printf("Time left is %d units",t*T);
  }
 }
 return 0;
}

see more previous year solved questions, here

Note: contact us if u need more clarifications or finds any error in the code

** check other codevita solved questions

Check Also

reliance jio logo

How to use Reliance Jio 4G SIM on 3G devices – Tricks Proved to Work

Use Jio 4G SIM on 3G devices – 100% tested The main issue with Reliance Jio …

Leave a Reply

error: Right Click is Disabled !!