Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (zrsmith):

Does anyone program in C? Having a hard time understanding this "Define a function named always_five that has no parameters and returns the integer 5 as its result."

OpenStudy (nick67):

int always_five() { return 5; }

OpenStudy (zrsmith):

Ok, how do i call it then from the main()? I know this seems simple, but this class is killing me? Taking it online, and is my first every programming class.

OpenStudy (zrsmith):

I need to use a printf() to confirm.

OpenStudy (nick67):

int always_five() { return 5; } int main() { int result; result = always_five(); printf ("function result is: %d, result); return 0; }

OpenStudy (zrsmith):

Thanks nick67, this class is really tough for me. I was able to compile and it makes sense now.

OpenStudy (nick67):

you're welcome

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!