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
In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....
What is late binding c++?
Define 'std'.
What is a c++ map?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What do you mean by global variables?
How does class accomplish data hiding in c++?
What is a character in c++?
If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?
Explain operator overloading.
What are the data types in c++?
What is the difference between cin.read() and cin.getline()?
What is a syntax in c++?
Explain rtti.
Do class declarations end with a semicolon?