user404 Posted April 1, 2016 Share Posted April 1, 2016 Hello!I'm learning C, so I'll be posting the problems I'm solving here, join in if you want and post your solutions in your favorite language. Challenge 1: Write a program that reads numbers, until it reads 0, and then outputs them in reverse order. Solution: #include <stdio.h> #define MAX 100 int main(void){ int matrix[MAX]; int num, i=0; printf(" Input at most %d integers, stop with 0\n", MAX); do{ printf(" number[%d] = ", i); scanf("%d", &num); if(num==0) break; matrix[i]=num; i++; } while( i< MAX ); while(i--) printf(" %d", matrix[i]); printf("\n"); return 0; } Quote Link to comment Share on other sites More sharing options...
Rkiver Posted April 1, 2016 Share Posted April 1, 2016 I may be wrong, but these so much appear to be "Do my homework for me"..... Quote Link to comment Share on other sites More sharing options...
user404 Posted April 1, 2016 Author Share Posted April 1, 2016 yeah, i'm going through an old C book of exercises... Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted April 1, 2016 Share Posted April 1, 2016 What if I want more than 100 numbers? Where is the realloc? ;) Quote Link to comment Share on other sites More sharing options...
cooper Posted April 3, 2016 Share Posted April 3, 2016 *cough*qsort*cough* Sorry, I have a cold. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.