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
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
What is expression parser in c++
What are static and dynamic type checking?
Distinguish between new and malloc and delete and free().
Explain the difference between static and dynamic binding of functions?
Can we run c program in turbo c++?
Can you Mention some Application of C/C++?
How can an improvement in the quality of software be done by try/catch/throw?
How does c++ structure differ from c++ class?
What do you understand by pure virtual function? Write about its use?
We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?
Where do I find the current c or c++ standard documents?
What is pointer to array in c++?
What is a node class in c++?
If a header file is included twice by mistake in the program, will it give any error?