- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 1: [C] – Data Types, Operators, Conditional Statements, Loops, and Command Line › Function in C: How to create
Tagged: define function, function, function in C, functions
#include <stdio.h>
#include <cs50.h>
int main(void)
{
long creditcardno;
do
{
creditcardno =
get_long("enter");
}
while (creditcardno < 0);
}
The above code accepts positive integers while taking input for credit card no.
The task is now to form a function my_function () that will perform the above task when called in the main function.
All that I can figure out is:
#include <stdio.h>
#include <cs50.h>
long my_function (void);
Will the next line include int main (void) or that will not appear at all.
Is it possible that I form a different c file such as test.c that will include function definition only and this file be called in main function in credit.c. Or both possibilities are there. I can have function defined and called in the same file so that everything can be performed from credit.c file.
Reply
https://cs50.stackexchange.com/questions/42051/function-in-c-how-to-create[learn_press_profile]