C Programming Tutorial 22, Functions pt.3

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

so that's pretty much it for this tutorial, so, see you guys.

danopo
Автор

Within the int main() the return code provides a way for the program to terminate. As you may it may not know boolean values 1 being true, 0 being false. When you run you program the it's boolean value in into main will be true "1" until the code return 0 which will render the program terminated. The "return" is what you are expecting to output which is useful in functions. If you don't expect to return anything special you "void" the process. E.g. "void func1();"

robbybobby
Автор

Same concept but this time the code asks the user for input:

#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int addNumbers(int number, int number2) {
int total = number + number2;
return total;
}

float multiplyNumbers(float firstNum, float secondNum) {
return firstNum * secondNum;
}

int main() {
int number;
int number2;
int temp;

printf("Enter a number\n");
scanf("%d", &number);

printf("Enter another number\n");
scanf("%d", &number2);

temp = addNumbers(number, number2);

printf("The value of those numbers are %d\n", temp);


float firstNum;
float secondNum;
float temp2;

printf("Enter a float number\n");
scanf("%f", &firstNum);

printf("Enter another float number\n");
scanf("%f", &secondNum);

temp2 = multiplyNumbers(firstNum, secondNum);

printf("The sum of the float numbers is %f\n", temp2);
return 0;
}

BergTutorials
Автор

I was watching in full screen at 0:22 I was like, " what the fuck is Sendori, I don't remember installing that". Then I remembered that it wasn't my actual screen. I'm an idiot.

petergriffin
Автор

Am a bit confused wat do u mean when u say a function returns a value 2 the user??

kwekughartey
Автор

nice videos man they did not come to be in vain many still watch them world wide

RionMusik
Автор

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


void noob(char message[], int ammount);
int add(int num1, int num2);
int main()
{
   sss (2, 4);

    return 0;
}

void noob(char message[], int ammount){
    for (int i = 0; i < ammount ; i++)
printf ("ERROR %s \n:", message);

}
int add(int num1, int num2){
int sss = num1 + num2;
return sss;
}



what is wrong ?

merhat
Автор

im kind of confused, at the end he says void to not return any data well it was indeed returning the message and a set of for loop instructions to the print statement

so what does void void again?

rmz
Автор

I misspoke, I meant to say "return a value to the caller".

iTzAdamX
Автор

I'm a little confused here. Who is 'the caller' is he referring to? Can anyone help me?

axiemaxhar
Автор

so that's pretty much it for this tutorial so, see you guys.

danopo