ezoic

Tuesday, December 20, 2016

C programming step by step

I am learning C language currently.

Here is a full c programming tutorial:

https://www.youtube.com/watch?v=-CpG3oATGIs&t=2s

This is a quite good one.

A simple hello world c program  is like this:

#include <stdio.h>

int main () {

printf("Hello World! \n");

return 0;

}

Then to compile it:

gcc hello.c -o hello

To run;

./hello

If you want to have some math function, you need to add math.h



#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main() {
const double a=3.1;
double b;
b=cos(a);
printf("%f \n",b);
return 0;
}
To compile it:
gcc -o 5th 5th.c -lm


i.e. you need to add -lm in the end. 








No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...