C programming

+1 Danny AA · December 26, 2014
int arr[10] = { -2, 8, 23, -160, -74, 8, 85, -47, 12, 7 }; 
PrintMaxPartAscending(arr, 10); 
that's the array 

void PrintMaxPartAscending(int arr[], int size) 

int i, j = 0, k = 0, counter1 = 0, num = 0, counter2 = 0; 
printf("The original array is :\n"); 
for (i = 0; i < size; i++) 

printf("%d ", arr); 

printf("\n"); 

for (i = 0; i < size; i++) 

if (arr < arr[i+1]) 

j = i; 
counter1++; 



for (i = 0; i < counter1; i++) 

printf("%d ", arr); 

printf("\n"); 




the func need to search the longest ascending numbers and print it
in this case it should print (-160, -47,8, 85.)
need help pls

Post a Reply

Replies

Oldest  Newest  Rating
0 Danny AA · December 26, 2014
someone can help pls?
0 Franz Schmidt · December 27, 2014
Could you please explain what exactly do you mean with longest ascending numbers??
Please give some more examples
0 Danny AA · December 27, 2014
int arr[10] = { -2, 8, 23, -160, -74, 8, 85, -47, 12, 7 };

in this arr u need to check the ascending number.

 -2 is smaller than 8? yes
counter++
8 is smaller than 23? yes
counter++;
23 is smaller than -160? no
stop and save the numbers you found. 
now you found the first ascending numbers.

now you check
-160 is smaller than -47 ? yes
counter2++;
-74 is smaller than 8 ? yes
counter2++;
8 is smaller than 85 ? yes
counter2++;
85 is smaller than -47 ? no
stop checking and keep the numbers.
now you found the second ascending numbers.

and you keep like this until you get to the end of the array.

tnx for the help...
0 Danny AA · December 27, 2014
but it can be any array not this one specific
0 Franz Schmidt · December 27, 2014
Ok now I understand :D

http://textuploader.com/6amy

Here you are;)
0 Danny AA · December 27, 2014
:) 
Thank you Franz Schmidt !!!!!!!
  • 1

C

107,273 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator