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 c++ redistributable?

1167


Is there any difference between int [] a and int a [] in c++?

944


Explain the concept of dynamic allocation of memory?

1044


Explain the register storage classes in c++.

1145


Is it possible to have a recursive inline function in c++?

977


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

1102


Why can templates only be implemented in the header file?

1060


What is the main function c++?

1069


How many characters are recognized by ANSI C++?

1359


Describe linkages and types of linkages?

943


What is the keyword auto for?

994


Write about the role of c++ in the tradeoff of safety vs. Usability?

1005


Does c++ have foreach?

979


What do you mean by ‘void’ return type?

1000


What is the benefit of encapsulation?

1018