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
Answers were Sorted based on User's Feedback
Answer / jobbine joseph
int main()
{
int Reading_num,Previou_num=-999999,i=0;
for(i=0;i<10;i++)
{
cin>>Reading_num;
if(Reading_num < Previous_num)
{
break;
}
Previous_num = Reading_num;
}
if(i<10)
{
cout<<"Numbers are Not in ASCENDING";
}
else
{
cout<<"Numbers are in ASCENDING ";
}
return(0);
}
| Is This Answer Correct ? | 8 Yes | 1 No |
Answer / 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 |
What is an associative container in c++?
Do you know the use of vtable?
Declare a class vehicle and make it an abstract data type.
what is difference between static and non-static variables
Write a program which employs Recursion
Write a function that swaps the values of two integers, using int* as the argument type?
Which is best ide for c++?
Write a program to concatenate two strings.
How size of a class can be calulated?
Define stacks. Provide an example where they are useful.
What is a container class?
Why do we need constructors in c++?