Skip to main content

C crash course

It is a simple Crash course or a summary of a course on Udemy.
If you want to know the basics of C. you would like to see it. It is not for the ultimate beginners. if it is your first time to code, you can search for everything. Don't forget it is just a crash course.


In C Language. There is something called Compilation


1. preprocessing: putting some character like # to remove repetition by providing functionality with inline files, omitting code and defining macros. 
2. compiling: allows for C code to contain inline assembly instructions
3. Assembly: is used to translate the assembly instructions to object code.
4. Linking:  o produce an executable program, the existing pieces have to be rearranged and the missing ones filled in.

How to launch your first code in C


1. write vimnameofproject.c
2. press i to insert
3. write stdio.h
4. write int main {
 Write your code here.
}
5. press escape, then ": wq" then enter
6. type gcc nameofprogram.c -o nameofprogram
7. then ./ nameofprogram

Simple Code explanation


int >>> to define the variable, There is more than a type ( int for integer like 1 2 3. float for float numbers like 1.4,  0.5. double for both and more likely for float.) The difference between those three types not just in the sort of stored data but also in the memory capacity. 

i, j, n >> are variables. It means you can store different numbers on it and change it anytime. It always takes the value of the last number put on it. There is sth else called Constant 
(const) means you can't change it. 

printf>>> a build-in function. There is more than one, and you can build functions on your own. It also represents the output that will appear to the user. 

scanf>> to take what the user will write and put it in the variable n. 
%d >> to admit that the number is an integer. 

&n >>to give an address to store the number. {“*” Operator is used as a pointer to a variable. Example: * a where * is a pointer to the variable a. & operator is used to get the address of the variable.}

For>> It is a loop, iterative way to do a task. There are two types of loops we can use.

For loop >> If you know the number of iteration or can consider it. While loop>> If you want your iteration to stop with a condition. 

i = 1 >> to give i value equals to 1, i<=4 it is the condition needs to continue your iteration. 

i++ means the increase in the variable i by 1 every time in the loop. j-- >> to reduce it by 1. 
"Linkin Park ">> a string data. it writes it as it is. 

printf("\n")>> to break the line. 

return 0 >> to get no data at the end. If you are working on a function you can return some value. I recommend when you write your main function to depend more on print than the return. 

To know what the meaning of this code is, you need to try this code on your own compiler or on an online compiler. 

Next time I will explain (; {})  and some conditions and a small project for all of you. 

Comments

Popular posts from this blog

Miserable

 This one word could describe my life right now. I am writing this because of the last book I read talking about how to re-organize your life. 32 days ago, my dad has gone. In the beginning, I couldn't cry. Now, I can't stop crying about everything. Everything reminds me of him. His favorite stuff became my nightmare. I dream of him every day, too. One week from his death, I took my exams. I didn't remember how I did in them. I knew they were not how I supposed to do, but I am not aware of how I did. I wish I could have cried when he passed. I wanted to cry a lot but I didn't have the ability to face myself with the fact of his death.  He died between my shoulders. I just saw his color turned to yellow like how my grandpa seemed before death. I heard my brother told him some prayers that a person says before death and I just shouted at him to stop. I spent time squeezing his feet to make him shocked. I even talked to him, I said don't go, don't leave me, not now...

MaharaTech: Network Course Summary

I knew it's a long time since my last post. In this post I will try to summarize most of the concepts of MaharaTech Network Course .  The Course Works for beginners and It lasts for 1 hour. If you are a beginner I tell you to plan for this course well. You should schedule 2 hours a day for 5/8 days to get the ultimate benefits of it.  There are 3 main Chapters and I will summarize them so you may return to this post in case you wanted to revise.  Introduction to Computer Networks ISO/OSI Model (7 Layers) TCP/IP Protocol Suite 1.  Introduction to Computer Networks a. Physical layer converts data from 01's to the electrical or optical or electromagnetic image.  b. Datalink layer consists of logical link control to convert, reliable, and flow the data from buckets to frames and preserve the data, resend missing messages. The other is MAC which adds the sender and receiver's physical addresses.  c. Network layer takes segments and converts them to packets. add ...

Hobbies but no time!

Hi hi hi, It's been a long time since the last time here. I know I am probably not your model, besides writing my blog in English makes it not easy to scroll down.  Today I am talking about Hobbies and how to back to your hobbies while your schedule is crowded like a shit. 1. Know Your Hobbies      You need to list your favorite 10 hobbies and if you wanna try sth in the future related to this field     My 10 are [Walking, Dancing, Reading, Learning, Writing, Domino, Complete words, Sports, Problem Solving]     and I wanted to learn chess.  2. Get The Best 3 Out of Them     After listing your hobbies go rank them with stars, what your good at, and so on. Should we quiet any of the last 10? I don't think so.  3. You Just Need to Focus     I do like Dancing but I have no time to learn it. So, You put your hobbies and choose 1 or 2 to learn more about it. for example, the learnable hobbies from mine are [Dancing, Learnin...