C is a procedural language, which means it follows a series of steps/procedures in a systematic order to solve a problem. These procedures are often organized in functions. These functions take in some value(s) as argument(s), operate on them and return an output. But apart from this approach, a function can even change the state of other variables in the global scope, perform input/output operations etc.
Pointer is something that points to the memory location where the value of a variable is stored. Pointers have data-types. This data-type has nothing to do with the value of the pointer itself, because a pointer has a value which is an address, i.e. a number. So the value of a pointer is always an int.
Today we are going to discuss about arrays in C. Arrays is a data structure that can store a fixed-size sequential collection of elements of the same type. In order to understand arrays we must first understand the meaning of the highlighted words of the above definition in terms of programming.
Today is 9th September, the birth anniversary of the creator of C programming language, one of the creators of Unix operating system and one of the forefathers of high level programming, Dennis MacAlistair Ritchie. As we are currently doing a series on C, let us talk about his influence in Computer Science.
Today we are going to discuss about conditionals and loops in programming in general and the syntax of them in C. Conditional statements are those which check the validity of a statement, by implementing logical operations in the CPU and returns a true or false(1 or 0). In C language we do not have the boolean datatype or the values ‘true’ and ‘false’. Here 1 represents true and 0 false. In the hardware, a certain bit in a register (also called flag) is set or unset (a 1 or 0) after the logical operation is performed. This bit is then checked, and depending upon its value the subsequent lines of code are executed.
Variable is a container to hold data. Datatype of a variable defines the type of data to be stored and the space required to store it. Variables in programming are analogous to variables in algebra. Just as algebraic expressions can have constant terms like ax + by = c , C programs can have constants, defined similar to variables but with the const keyword.
Today we are going to discuss include statements in a C programs. In the last blog of this series we’ve discussed about a function, called printf. We didn’t write the function definition, as it was already present in a file called stdio.h.
The real FUN of functions comes into play when you can build a very complex program by dividing it into smaller functions that do parts of the operations and can be reused in different parts of the program. These utility functions can also be packed together in a file(like stdio.h) and distributed among other developers, to reduce the coding effort of everyone.
Lets now discuss about the ‘function’ part in main() function. As the semester has just started, you may not have been introduced to the concept of functions in programming. In layman terms, a function is a block of code which performs a certain operation. This concept of grouping specific codes to perform some task dates back to early days of development of programming.