//This is an example, coding not complete. Say main runs the function add, int add adds two random numbers and int random gets a random number from the array. By keeping 3 functions, how would I pass b and c to int add? Right now b and c are undeclared

int main{

int add(){
 d = b + c
 printf("the sum of two random nubmers are %d, d)

int ranom(){ 
    a = [1,2,3,4,5,6]
    b = rand[a]
    c = rand[a]

Functions support parameters, which are designed for this exact purpose:

int add(int a, int b)
    return a + b;

int main(void)
    int a = 5;
    int b = 2;
    int c = add(a, b);

    printf("%d + %d = %d\n", a, b, c);

    return 0;

This is basic C that any reference will cover

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.