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

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

How is new() different from malloc()?

0 Answers  


What is the difference between global variables and local variable

0 Answers  


Difference between pointer to constant and constant pointer to a constant. Give example.

0 Answers   HAL,


Explain the isa and hasa class relationships. How would you implement each?

0 Answers  


Is atoi safe?

0 Answers  


Can we use resume in error handling i.e. in the catch block

5 Answers   Infosys,


Which is best c++ or java?

0 Answers  


Can you pass an array to a function in c++?

0 Answers  


if there is binary tree which one is the easiest way to delete all child node?

1 Answers   Persistent,


write a program that a 5 digit number and calculates 2 power that number and prints it.

2 Answers   Vimukti Technologies,


Are there any special rules about inlining?

0 Answers  


What is vector processing?

0 Answers  


Categories