User Tools

Site Tools


notes:cprog

This is an old revision of the document!


C/C++ Programming Course Notes Wiki

For help with wiki syntax:

25 August

#include <stdio.h> -This is called a preprocessor directive, it aids the compiler in the early stages of compilation.

Comments can be added to computer programs to increase their readability. These can take the form of multiline comments which start with /*. This leads the processor to ignore all information until a */ set of tokens is reached.

// are single line comments, adopted from C++ that allow for short commentsto be make easily.

All c programs contain the following function: int main() {

In this function int is the return value or data type. There are several types of data types, these include char, short int, int,long int and long long int. Main is the name of the function, and the parenthesis following that name indicate that this is indeed a function. A parameter, if a function operates on a certain parameter, could be put inside the parenthesis.

Programs should end with a return(0); This is a sort of check. If the program returns 0 it is running correctly.

C understands several logical operators, such as -& or bitwise and which implies that both parts of a given statement are true or the statement is not true. -| or bitwise or which implies that for a statement to be true one part of a given statement must be true.

» is a bitwhise right shift. « is a bitwise left shift. These are useful in multiplying and dividing as a computer is incapable of understanding even basic mathematical operations. ! is a bitwise not. This implies the converse of the following statement.

 basic math operators

= set equality (thing on right to thing on left)
+ add
- minus
* mult
/ divide
% remainder of division (called modulus in some languages)
notes/cprog.1503945904.txt.gz · Last modified: 2017/08/28 14:45 by kjones35