you check if the arr[i] is greater than greater and then you increment i
rather do

for(int i=0; i<15;i++){

if(arr[i]>greater){
 greater=arr[i];
 }

}

:)

Waseem Shahzad wrote:
/*

to find greater no. from the array whats the problem with this algo.

 please help


 */



#include<iostream.h>


void main(){

int arr[15]={17,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

int greater=0;

for(int i=0; i<15;){

 if(arr[i++]>greater){
  greater=arr[i];

 }

}

cout<<"greater is "<<greater<<endl;


}
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to