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 c++ redistributable?
Is there any difference between int [] a and int a [] in c++?
Explain the concept of dynamic allocation of memory?
Explain the register storage classes in c++.
Is it possible to have a recursive inline function in c++?
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
Why can templates only be implemented in the header file?
What is the main function c++?
How many characters are recognized by ANSI C++?
Describe linkages and types of linkages?
What is the keyword auto for?
Write about the role of c++ in the tradeoff of safety vs. Usability?
Does c++ have foreach?
What do you mean by ‘void’ return type?
What is the benefit of encapsulation?