import java.io.*;
class Ascending
{ public static void main(String[] args)throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number of strings");
int n=Integer.parseInt(br.readLine());
String s[]=new String[n];
for(int i=0;i<n;i++)
{ System.out.println("enter the string");
s[i]=br.readLine();
}
System.out.println("the strings in ascending order are");
for(int i=0;i<n-1;i++)
{ for(int j=0;j<(n-(i+1));j++)
{
if(s[j].compareTo(s[j+1])>0)
{
String s1=new String();
s1=s[j];
s[j]=s[j+1];
s[j+1]=s1;
}
}
}
for(int i=0;i<n;i++)
System.out.println(s[i]);
}
}
PROCEDURE:- 1.enter values for u,a,t to find distance 2.find distance with the formulae ut+1/2at 2 3.print the above result CODE:- #include<stdio.h> #include<conio.h> void main() { float u,t,a,S; clrscr(); printf(“enter values u,t,a”); scanf(“%f %f %f”, &u,&t,&a); S=(u*t)+(0.5*a*t*t); printf(“\n S = %f”, S); } Input:- enter values u,t,a U=10,t=4,a=4.9 Output:- S =79.200
Comments
Post a Comment