write a program to accept 10 numbers and check whether they are in ascending order or not
In java
Share
write a program to accept 10 numbers and check whether they are in ascending order or not
In java
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Answer:
class prog1
{
void main()
{
Scanner sc=new Scanner(System.in);
int i,n,f=0,p=0;
System.out.println("Enter 10 integers:");
for(i=1;i<=10;i++)
{
n=sc.nextInt();
if(i>1)
{
if(n<p)
f=1;
}
p=n;
}
if(f==0)
System.out.println("The numbers are in ascending order");
else
System.out.println("The numbers are not in ascending order");
}
}
Explanation:
Hope it help.