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 does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)
Why is main function important?
what are the decision making statements in C++? Explain if statement with an example?
Explain differences between new() and delete()?
What are the two types of polymorphism?
What is the header file for setw?
Is string data type in c++?
What is c++ namespace?
Explain binary search.
What are abstract data types in c++?
Why do we need pointers?
What happens when the extern "c" char func (char*,waste) executes?
How do I run c++?
What are the benefits of oop in c++?
What is bubble sort c++?