C++ user defined functions explained 📞

preview_player
Показать описание
C++ functions tutorial example explained

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

#include <iostream>

void happyBirthday(std::string name, int age);

int main()
{
// function = a block of reusable code

std::string name = "Bro";
int age = 21;

happyBirthday(name, age);

return 0;
}
void happyBirthday(std::string name, int age){
std::cout << "Happy Birthday to " << name << '\n';
std::cout << "Happy Birthday to " << name << '\n';
std::cout << "Happy Birthday dear " << name << '\n';
std::cout << "Happy Birthday to " << name << '\n';
std::cout << "You are " << age << " years old!\n";
}

BroCodez
Автор

you explained it so goood ı've never understand the functions this well thank you

yellowhellow-wigi
Автор

tip from papa please use using namespace std;

KapeelManek
Автор

I really like your C++ series. Keep it up. Please make more C++ Videos. So, let's defeat the YouTube algorithm.

FrederikWollert
Автор

Simple weight calculator. - Pretty efficient.
#include <iostream>

void weightCalc() {
int mass ;
double weight ;
std::cout << "Enter your mass in kg." << '\n';
std::cin >> mass;
std::cout << mass<< '\n';
weight = (mass * 9.8);
std::cout << weight << "N";
}


int main() {
weightCalc();

return 0 ;

}

johnny_ow
Автор

is any good to use functions below main?

tanvirsahrierjishan
Автор

finally, hello world v2.0

#include <iostream>

void hello(std::string world);

int main()
{
std::string world = "Hello, World!";
hello(world);
return 0;
}

void hello(std::string world)
{
std::cout << world << std::endl;
}

taigo
Автор

}
void find_x(double a, double b, double c ){
double x1;
double x2;
double D = pow(b, 2) - 4*a*c;
if (D>0){
x1=(-b+sqrt(D))/2*a;
x2=(-b-sqrt(D))/2*a;
std::cout << x1 << " " << x2;
}
else if(D<0){
x1 = -b/2*a;
std::cout << x1;
}
else{
std::cout<<"there are no square roots";
}
}

sviatoidyx
Автор

#include <iostream>
using namespace std;

void happyBoy(bool IsHappy, string name);

int main() {
bool IsHappy = true;
string name = "Andrew";

happyBoy(IsHappy, name);

return 0;
}
void happyBoy(bool IsHappy, string name);
cout << " This boy " << IsHappy << " and he called himself << name << endl;
cout << " This boy " << IsHappy << " and he called himself << name << endl;
cout << " This boy " << IsHappy << " and he called himself << name << endl;

}

artemzakharchuk
Автор

#include <iostream>

void song(int age = 19, std::string Name = "Christian") {
std::cout << "Happy birthday to " << Name <<'\n';
std::cout << "Happy birthday to " << Name <<'\n';
std::cout << "Happy birthday to " << Name <<'\n';
std::cout << "Happy birthday to " << Name <<'\n';
std::cout << "Happy birthday " << age << " Years old of exist in this world" <<'\n';
}
int main()
{
int age = 19;
std::string Name = "Christian";
song();
return 0;
}

christiangaming