1. ## Can you help me with this.. please...

Hi to all C enthusiasts,

Greetings!

My name is Alexander, a C enthusiast, 17-year-old, and live in Bacolod City, Negros Occidental Philippines. I have given my brief info and this is my first time to post here. My problem is, I have coded an output like this:
Code:
```Enter num1: 1
Enter num2: 1
Enter num3: 3
Enter num4: 5
Enter num5: 3

Number 1 appeared 2x
Number 3 appeared 2x
Number 5 appeared 1x```
I tried it with this code..
Code:
```#include <stdio.h>
#include <conio.h>
void main() {
int num[5] = {0};
int x, y, temp;
clrscr();

for(x = 0;  x <= 4; x++) {
printf("Enter num%d: ", x+1);
scanf("%d", &num[x]);
}
printf("\n");

for(x = 0; x <= 3; x++) {
for(y = x + 1; y <= 3; y++) {
if(num[x] > num[y]) {
temp = num[x];
num[x] = num[y];
num[y] = temp;
}
printf("\n");

int h = 0;
x = 0;
y = 1;
while(x <= 4) {
h = 1;
printf("Number %d ", num[x]);
while(num[x] == num[y]) {
y++;
h++;
x++;
}
printf("appeared %dx\n", h);
if(h == 1) {
x++;
y++;
} else {
x = y;
y++;
}
}
}
}
getch();
}

But the Output is:

Enter num1: 1
Enter num2: 1
Enter num3: 3
Enter num4: 5
Enter num5: 3

Number 1 appeared 2x
Number 3 appeared 1x
Number 5 appeared 1x
Number 3 appeared 1x```
Please anyone, evaluate this problem and post me your responses so that it will help enhance my understanding in arrays and loops.

Cordially Yours,

Alexander Daguob
Student, BSCOE - I, AMACC - B

2. It seems to me if you made this, you have understood how to loop! rofl. I could make this process alot easier for you if you would want my brief version of how to do it, but I'm not analyzing that for you, that's your job

3. Hi pre

So you want someone to comment the code for you?
The code is too long for its problem, theres is a too short version of that

4. Originally Posted by loko
Hi pre

So you want someone to comment the code for you?
The code is too long for its problem, theres is a too short version of that
Hello po sir,

Opo.. gusto ko lang po malaman ang simple at tamang code dahil yung mga code na na-post ko po ay ang nakaya lang ng logic ko...
Sana po tolongan nyu ako...

5. haha bro i dont think they allow any spkoen language here other than english. So lets talk in english.

This is all you need.
Code:
```

//initializing data
for(x = 0;  x <= 4; x++) {
printf("Enter num%d: ", x+1);
scanf("%d", &tmp);
num[tmp-1]++; // Increment index for 3.
}

//printing output..
for( x = 0; x <= 4; x++ ){
if( num[x] > 0 )
printf(  Number %d appeared %dx ", x + 1, num[x] );
}```
The code above hasnt been tested. But im sure it will work .

6. Sir Loko,

Code:
```#include <stdio.h>
#include <conio.h>
int main() {
int x, tmp, num[5] = {0};
clrscr();
//initializing data
for(x = 0;  x <= 4; x++) {
printf("Enter num%d: ", x+1);
scanf("%d", &tmp);
num[tmp-1]++; // Increment index for 3.
}
printf("\n");
//printing output..
for( x = 0; x <= 4; x++ ){
if( num[x] > 0 )
printf("Number %d appeared %dx\n", x + 1, num[x]);
}
getch();
return 0;
}```
How come I didn't think of using the memory locator of the scanf as the index of my array... perhaps I'm only a newbie C enthusiast...lolz
I, however, am thanking you sir for your effort in giving me a simple code..

7. No Problema . And dont call me sir we are almost the same age

8. ## Getting to know loko.

Okay..

9. Originally Posted by Alexthunder
Okay..
Anyway, what school are you in? Your name? Age?

Im from STI somewhere in Southern Tagalog. Im a second Year Student. My age?? Secret .

10. and your course and name?

11. Alexthunder,

If you must ask other forum members about their personal information, why don't you private message them? It doesn't have anything to do with C.

12. Im in a 2 years computer science course. My name is Mal.

Lets talk sa Yahoo sometime. PM me your Yahoo.

13. Originally Posted by cwr
Alexthunder,

If you must ask other forum members about their personal information, why don't you private message them? It doesn't have anything to do with C.

Peace

14. ## I am sorry

Originally Posted by cwr
Alexthunder,

If you must ask other forum members about their personal information, why don't you private message them? It doesn't have anything to do with C.
Sir, sorry, I'm a newbie here in cboard forums, I didn't know sir how to pm him so I've posted it in here... don't worry sir it won't happen again..

15. Click on USER CP there you will find option for sending messages.