Write a program and call it sortcheck.cpp which receives 10 numbers from input and checks whether these numbers are in ascending order or not. You are not allowed to use arrays. You should not define more than three variables
Answer Posted / rajesh
I think this one is good answer...
#include<iostream>
using namespace std;
int main()
{
int prev = 0, next, i;
for(i = 0; i<5; i++)
{
cin>>next;
if(next > prev)
{
prev = next;
}
else
{
cout<<"not in ascending
order..\n"<<endl;
break;
}
}
if(i==5)
cout<<"Ascending order...\n"<<endl;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Write about the access privileges in c++ and also mention about its default access level?
Is sorted c++?
What is friend class in c++ with example?
When can I use a forward declaration?
What are the two shift operators and what are their functions?
What are the benefits of pointers?
How are Structure passing and returning implemented by the compiler?
Explain differences between new() and delete()?
Write my own zero-argument manipulator that should work same as hex?
List the issue that the auto_ptr object handles?
What is rvalue?
What is flag in computer?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
How does c++ sort work?
Why cout is used in c++?