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



Write a program and call it sortcheck.cpp which receives 10 numbers from input and checks whether th..

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

Write a program and call it sortcheck.cpp which receives 10 numbers from input and checks whether th..

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

Post New Answer

More C++ General Interview Questions

what is VOID?

0 Answers  


Explain the scope of resolution operator.

0 Answers  


what is C++ objects?

0 Answers  


What are libraries in c++?

0 Answers  


What are the uses of c++ in the real world?

0 Answers  


Define 'std'.

0 Answers  


What are compilers in c++?

0 Answers  


What are inline functions?

3 Answers   Fidelity, Verizon,


what is the basic concept of c++(object oriented programing)

4 Answers   Wipro,


Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?

0 Answers  


Differentiate between declaration and definition.

0 Answers  


Can we remove an element in a single linked list without traversing? Lets suppose the link list is like this 1 2 3 4 5 6 We need to remove 4 from this list (without traversing from beginning) and the final link list shud be 1 2 3 5 6 only thing we know is the pointer to element "4". How can we remove "4" and link "3" to "5"?

6 Answers   CSC,


Categories