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 the oldest programming language?
When should overload new operator on a global basis or a class basis?
Do the parentheses after the type name make a difference with new?
can any one help to find a specific string between html tags
which is changed to a sting..
weather.html looks (for location) is
What does obj stand for? declare an array of structure where the members of the
structure are integer variable float variable integer array
char variable access all elements of the structure using dot
operator and this pointer operator Are strings mutable in c++? What are the advantages of using a pointer? Is python written in c or c++? What is type of 'this' pointer? Explain when it is get created? Write a single instruction that will store an EVEN random
integer between 54 and 212 inclusive in the variable myran.
(NOTE only generate EVEN random numbers) Why do we learn c++? What is a class template in c++? an integer constant must have atleast one
a) character
b) digit
c) decimal point Do you know what are static and dynamic type checking?