Post: [Clouds' C Programming Tutorial Series] Part One: Introduction To The C Language
04-25-2013, 07:24 AM #1
Clouds
Error 404: Title Not Found
(adsbygoogle = window.adsbygoogle || []).push({});
You must login or register to view this content.


Welcome to this tutorial series I will be doing over the next few weeks. These threads will be introductions to the C language and its basic functions and moving up in to some more intermediate stuff. There are tons of tutorials just like this all around the internet, but this one is brought to you directly from your favorite forum.

Introduction to C


The C programming language originated from Bell Labs in the early 1970s. The language was developed, initially, by Dennis Ritchie. The language is called 'C' as features of it were derived from the earlier language, 'B', which was a variant of Basic Combined Programming Language.

C programs are compiled with often straightforward compilers that allow low-level access to memory and have minimal runtime support. This allowed C to take over many previous programs before coded in Assembly.

The language is greatly cross-platform, stretching from microcontrollers to Windows machines to supercomputers. Despite the language being relatively low-level, the same code can be compiled across all these machines with few to no changes to the source code.

Introduction to Syntax of C


C is a very freeform language that allows the user to code with no whitespace/indentation restrictions. This would allow the coder to create an entire program all on one line, however that is very frowned upon and is considered to be bad coding.

C uses source files that contain function skeletons/definitions and declarations. Functions in C are enclosed in "curly brackets," formally called braces ({ and }), which indicate where the function will "begin" and "end." (Begin and end are in quotes, as they don't fully define the end of the function every time nor is it the exact beginning) All statements in C will be followed by a semi-colon to declare that the statement has ended.

Basic Data Types


There are numerous types that a variable can be, but in this tutorial, I will go over the basic ones and explain a bit about each.

First off, there is the int type. Int declares the variable to be an integer, either positive or negative, that does not have a decimal point. If a number is followed by a decimal, the number is rounded to fit the integer type. The int type is 16 bits in size.

Second comes the char type. Char declares just what you'd think. A character. Char can hold more than a single character, but in order for that to happen, an array must be declared. I will go in to arrays a bit later.

Third off, we have the long type. Long declares a signed integer type that is 32 bits in size.

Next follows the float type. Float declares a single-precision floating-point data type. The actual properties of this are unknown to me, however I do know that most systems follow the 32 bit base 2 format, formally called binary32. Explaining floats would take a lot more time than needed, so if you wish to know more about them, follow You must login or register to view this content..

Finally, I will introduce the double type. Double declares a double-precision floating-point data type, which is exactly the same as the float type, but just doubled in size capability. So instead of it being 32 bit, it is 64 bit and referred to as FP64 (floating point 64 bit). This would take just as much time to explain as the float type, so if you wish to know more, follow You must login or register to view this content..

Character Set


The character set for the C language contains the following:
Letters: a-z, A-Z, and the underscore
Integers: 0 through 9
Punctuation: ~ ! @ # % ^ & * ( ) - + = : ; " ' < , > . ? / | \ { [ } ]
Whitespace Characters: 'space', 'tabs', 'newline' Respectively, the characters for these are: " ", "\t", and "\n"
Newline is the same as a line break. A newline character is inserted at the end of all print statements as to make sure the prompt following the program is on its own line and not the end line of the program.

Basic Operators


Operators are symbols used within expressions, such as equations in the function or loops, that specify what is to be performed. Here I will explain the basic operators and will go in-depth as I go on.

Arithmetic/math: +, -, *, /, %
I can assume you all know what plus and minus is, but the others are as follows:
Multiplication, division, and remainder.

Assignment operator: =
The equals sign is used exclusively as the assignment operator. It is used to set variables equal to an integer n.
For this example, I will call our variable "number." The assignment operator and math operators are used as follows.
int number = n*10;
This will declare a variable number, take a number n, and multiply it by 10. The expression is ended by the semi-colon. If it is not ended as such, the compiler will see whatever follows to be a part of the declaration and you will be thrown errors.

END OF TUTORIAL ONE

Next time I will be going over basic functions in the C language that allow input of data and output of data, as well as other basic requirements to run your code.

The following 2 users say thank you to Clouds for this useful post:

Complete Speed, Saul
12-22-2016, 07:36 AM #2
I take it you never made a second tutorial then, never the less I benefited from this tutorial

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo