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
What is a float in c++?
which of the following is not an secondary constant a) array b) real c) union
How can I learn c++ easily?
What methods can be overridden in java?
What is implicit pointer in c++?
What is the use of object in c++?
Write a program to find the reverse Fibonacci series starting from N.
How does class accomplish data hiding in c++?
What is the prototype of printf function?
What is abstraction in c++ with example?
What is the difference between an enumeration and a set of pre-processor # defines?
Can I learn c++ as my first language?
Explain what you mean by a pointer.
What do you mean by “this” pointer?
What is an associative container in c++?