Saturday 29 April 2023

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 3

 3]Accept initial velocity (u), acceleration (a) and time (t). Print the final velocity (v) and the

distance (s) travelled. (Hint: v = u + at, s = u + at2)

#include<stdio.h>
#include<conio.h>

void main()
{
 int u,a,t;
 float v,s;

 clrscr();

 printf("\nFinding Final velocity and distance travelled by body:");
 printf("\nEnter the initial velocity:");
 scanf("%d",&u);
 printf("\nEnter the acceleration:");
 scanf("%d",&a);
 printf("\nEnter the time in sec:");
 scanf("%d",&t);

 v=u+(a*t);
 printf("\nFinala velocity is :%f",v);
 s=u+(a*t*t);
 printf("\nDistance travelled is:%f",s);

 getch();
}


/*OUTPUT : 

Finding Final velocity and distance travelled by body:                         
Enter the initial velocity:55                                                  
                                                                               
Enter the acceleration:56                                                      
                                                                               
Enter the time in sec:40                                                       
                                                                               
Finala velocity is :2295.000000                                                
Distance travelled is:24119.000000                                             

*/

No comments:

Post a Comment

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...