The main problem with your code is that the arrays should not be passed using the address operator (&). So if you wanted to pass the array to your [icode]countEven[/icode] function, you'd use the following
[code=C]
countEven(numbers);
[/code]
This is mainly because the name of the array is a pointer to its first element.

The second problem is that you've forgotten to put the j in your function's return statement.

Last but not least, the [icode]size[/icode] and [icode]j[/icode] variables inside [icode]main[/icode] are not used, so you can get rid of them.

Here's how I'd write the above piece of code
[code=C]#include <stdio.h>

int countEven (int *numbers)
{
int even[7];
int i=0, j=0;

for(; i < 7; ++i)
    if(!(numbers[i] % 2))
        even[j++]=numbers[i];

return j;

}

int main (void)
{
int numbers[] = {2, 5, 10, 16, 31, 17, 30};

countEven(numbers);

printf ("%d\n", countEven(numbers));

return 0;

}
[/code]

ybsolar commented: there's a nice FOR loop. +0

You could have a look over [url=http://zlib.net]zlib[/url], I think it's your best bet.

dragonpunch commented: nice link +0

You simple write its name and pass it the arguments. For example:
[code=C]

include <stdio.h>

int main(void) {

/* printf *is* a function, and that's how we call all the other functions */
printf("I am %d years old\n", 15);

return 0;

}
[/code]

Going a step further and tokenizing the function call, we get

[icode]printf[/icode] -- the function's name
[icode]"I am %d years old\n"[/icode] -- the function's first argument
[icode]15[/icode] -- the function's second argument

The program is [b][color=red]wrong[/color][/b]. Here's why:

First of all, you are not including a header file, therefore, you have no access to the I/O functions (i.e. [icode]scanf[/icode]).

Next, you define [icode]main[/icode] as [icode]void main()[/icode], when it should be [icode]int main(void)[/icode].

Furthermore, you write [icode]scanf("%d", a);[/icode]. This is incorrect, as the value of [icode]a[/icode] must be changed by the function. Therefore, you must feed it a [i]pointer to a[/i]: [icode]scanf("%d", &a);[/icode].

You don't need braces around the statements inside a [i]case[/i] statement. So, instead of
[icode]
case 1: {
printf("You are happy.");
break;
}
[/icode]
we write
[icode]
case 1:
printf("You are happy.");
break;
[/icode]

Last but not least, your function is not returning anything. It should return 0 upon successful execution. So instead of [icode]getch();[/icode], use [icode]return 0;[/icode].

Read a good book on it, but it might be a little too expensive for just file I/O. If you're looking for a reference, check the Dinkumware link in my signature.

A [i]parameter[/i] is used when defining/declaring (or prototyping) a function, and an [i]argument[/i] is passed (or given) when calling the function. In the example below, [icode]x[/icode] and [icode]y[/icode] are parameters, while [icode]a[/icode] and [icode]b[/icode] are arguments:
[code]
double average(int x, int y); / Function prototyping; x and y are parameters /

int main(void) {

int a = 10, b = 20;

printf("%d\n", average(a, b); /* The function is called; a and b are arguments */

}

double average(int x, int y) { / Function definition; x and y are parameters /

return (x + y) / 2;

}
[/code]

Because you declare [icode]acName[/icode] as a [i]character [b]pointer[/b][/i]. That is, you cannot change individual letters. All you can do is have it point to another string. So you could write
[code]

include<stdio.h>
include<stdlib.h>

int main(void)
{
char acName="hello daniweb";
acName="H";
printf("%s\n",acName);
}
[/code]
and the output would be [icode]H[/icode].

In order to capitalize the first letter, you have to declare [icode]acName[/icode] as a [i]character [b]array[/b][/i]. You do this by declaring it as an array of characters, but a [i]null character[/i] must be included in the characters count. That is, "hello daniweb" has 13 characters. You add the null character and declare an array of 14 characters. The version below does what you want.
[code]

include<stdio.h>
include<stdlib.h>

void main()
{
char acName[14] = "hello daniweb";
*acName='H';
printf("%s\n",acName);
}
[/code]

Mouche commented: Nicely explained with example code +4

I think you need [url=http://www.dinkumware.com/manuals/default.aspx?manual=compleat]a reference[/url]. You can also check the header files on your own computer, installed by the compiler.

I haven't used Xcode in a while, but since you've got it installed, open TextEdit (unless you're comfortable with a command-line text editor, of course), write your program in there, and save it as [b]attempt.c[/b] in your [i]home directory[/i] (the one with Movies, Music, and so on). Next, fire up your Terminal (Applications -> Utilities -> Terminal.app) and type
[code]gcc attempt.c -o attempt -Wall[/code]
Next, type in
[code]./attempt[/code]

Now, to explain things a bit. Compiling the program is done, in the simplest form, using
[code]gcc attempt.c[/code]
What this does is 1) call the gcc compiler, 2) pass it [b]attempt.c[/b] as [i]argument[/i], and 3) produce [i]object code[/i] in the file [b]a.out[/b] (correct me if I'm wrong, but [i]a[/i] stood for Assembly, right?).

If you compile it using the command above, you have to type
[code]./a.out[/code]
in order to run the actual program. You can, of course, control the name of the output file. This is done by calling gcc with the [icode]-o[/icode] [i]flag[/i] (standing for [i]output[/i]) and passing an output file name to it. That is, if we wanted the name of the executable to be [i]attempt[/i], we would use
[code]gcc attempt.c -o attempt[/code]
Now we run the program using
[code]./attempt[/code]

Compilation will fail if the compiler finds an [i]error[/i] in your code, and you'll be notified. It won't fail, though, if your code generates [i]warnings[/i], but the actual program may not behave as intended, or even crash at some point during execution. If you want the warnings to appear on ...

The problem in your approach is that your mind is stuck to thinking from left to right. Try thinking from right to left.

That is, compute d1, then d10, then d100. You also don't need the digit you've just stored anymore, so you're free to drop them. To give you an example, let's compute d1.

[code=C]
d1 = r % 10 / Thinking from right to left, we first store d1 /
r /= 10 / Now we drop the last digit of r, as we don't need it anymore /

/ By the time we've got all of d1, d10 and d100, r will be equal to r / 1000 /
[/code]

I hope this is what you were asking and that it solves your problem. Good luck!

Adak commented: perfect answer +3

We'd rather "f" your intelligence. Or the lack thereof.

If conio.h appears in the book (windows-dependant), it is not a good book. My $0.2.

Ancient Dragon commented: Yes. +33

A very good first reading is [url=http://norvig.com/21-days.html]Teach Yourself Programming in 10 Years[/url].

Ancient Dragon commented: love it :) +33

[icode]%[/icode] is part of [i]conversion specifications[/i] such as [icode]%d[/icode] or [icode]%f[/icode]. Therefore, if you simply write [icode]%![/icode], it will be interpreted as requiring a second argument matching the data type associated to [icode]![/icode] (a so-called [i]conversion specifier[/i]).

[icode]printf("Hello, World%!");[/icode] will print [icode]Hello, World![/icode]. Furthermore, it will display a formatting warning at compilation.

abhimanipal commented: Nice .... I did not know this +1