Pages

Make a program in C# and find the value of displacement by using(s=Vit+ 1/2 at^2 ).


CODE:


using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;

namespace _1EquationofMotion
{
classProgram
    {
staticvoid Main(string[] args)
        {

int Vi, t;
constdouble a = 9.8;
double S;
Console.WriteLine("Please Enter initial velocity:");
            Vi = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please Enter time:");
            t = Convert.ToInt32(Console.ReadLine());
            S = Vi * t + 0.5 * a * t * t;

Console.WriteLine(" with initial velocity {0} and time {1} the value of displacement is {2}", Vi, t, S);
    }
  }
}

OUTPUT:


ALGORITHM:

  • ·         Start:
  • ·         Initializing: int Vi, t , const double a= 9.8 , double S,
  • ·         Output: Please enter initial velocity:
  • ·         Set Vi: Taking input from the user
  • ·         Output: Please enter time:
  • ·         Set t:Taking input from the user
  • ·         Set S: vit+1/2 at^2
  • ·         Output: Result
  • ·         End.

No comments:

Post a Comment