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


Please Help Members By Posting Answers For Below Questions

Write about the access privileges in c++ and also mention about its default access level?

820


Is sorted c++?

870


What is friend class in c++ with example?

682


When can I use a forward declaration?

809


What are the two shift operators and what are their functions?

810


What are the benefits of pointers?

780


How are Structure passing and returning implemented by the compiler?

838


Explain differences between new() and delete()?

818


Write my own zero-argument manipulator that should work same as hex?

793


List the issue that the auto_ptr object handles?

810


What is rvalue?

896


What is flag in computer?

802


Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.

858


How does c++ sort work?

750


Why cout is used in c++?

764