, ' options: { ignoreHtmlClass: "tex2jax_ignore", processHtmlClass: "tex2jax_process" }, startup: { ready: () => { console.log('MathJax is loaded and ready'); MathJax.startup.defaultReady(); MathJax.startup.promise.then(() => { console.log('MathJax initial typesetting complete'); }); } } }; ], ['\\(', '\\)']], displayMath: [['$','$'], ['\\[', '\\]']], processEscapes: true, processEnvironments: true, tags: 'ams' }, options: { ignoreHtmlClass: "tex2jax_ignore", processHtmlClass: "tex2jax_process" }, startup: { ready: () => { console.log('MathJax is loaded and ready'); MathJax.startup.defaultReady(); MathJax.startup.promise.then(() => { console.log('MathJax initial typesetting complete'); }); } } };
// hello_world.c
#include <stdio.h>
// Print "Hello, world!" followed by newline and exit
int main(void){
printf("Helllo, world\n");
return 0;
}
// Compilation command line
$ gcc hello_world.c -std=c99 -pedantic -Wall -Wextra // or g++ -o generated_file_name target_file_name, ex: g++ res hello_world.c
$ ./a.out
// Output
Hello, world!
many .c files --compiler--> many .o files --linker--> one excutable file
int add(int num1, int num2){
int a = num1 + num2;
return a;
}
int main(){
int a = 10;
int b = 20;
int c = add(a+b);
}
NOTE: We initialize and assign value to another variable a in function add. But the a value in function add doesn’t make any difference to a value in main function due to different thread, i.e the value change of parameters doesn’t change the value of argument.
It’s to notify compiler there is a function before defining it. With so, we can define the function seperately/later.
int max(int a, int b);
int main(){
int a = 10;
int b = 20;
return max(a, b)
}
int max(int a, int b){
return a > b ? a:b;
}
// head file swap.h
# include <iostream>
using namespace std;
void swap(int a, int b); // declare the function
// source file
# include "swap.h"
void swap(int a, int b){
int temp = a;
a = b;
b = temp;
cout << "a = "<< a << endl;
cout << "b = "<< b << endl;
}
// main file
# include "swap.h"
# include <iostream>
using namespace std;
int main() {
int a = 10;
int b = 20;
swap(a, b);
system("pause");
return 0;
}