Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a float in c++?

974


which of the following is not an secondary constant a) array b) real c) union

1790


How can I learn c++ easily?

1060


What methods can be overridden in java?

1245


What is implicit pointer in c++?

1065


What is the use of object in c++?

1086


Write a program to find the reverse Fibonacci series starting from N.

1253


How does class accomplish data hiding in c++?

1162


What is the prototype of printf function?

1167


What is abstraction in c++ with example?

1093


What is the difference between an enumeration and a set of pre-processor # defines?

1367


Can I learn c++ as my first language?

1096


Explain what you mean by a pointer.

1089


What do you mean by “this” pointer?

1064


What is an associative container in c++?

1045