C Development Cycle
Here we discuss how would you create a C Program in five steps
- Come up with the idea of the program.
- Write the source code using an editor.
- Compile the source code and link the program using the C
The Source Code
The source code is basically a language which the compiler(on which we are working) understands.
Example
Suppose there are two persons one is English speaking and the other one is a Spanish speaking so how do they interact or communicate with each other?
The answer is that either one should know both the languages.(ie) the first person knows [...]
The Compiler and the Linker
Compiler is a special program that reads the information given by the user (i.e the source code)and translates it into machine language which is the only language understood by the microprocessor.
Linker converts the information into runnable program (.exe file) for us, which is the final product of users given information.
All the files created in compiling are [...]
Turbo C/C++ Compiler
Before we start our programming language we need a C-language compiler.
I recommend you a Turbo C/C++ compiler.It is easy to start with and is one of the best C/C++ compilers.
Here is the link for the Download Turbo C
Extract the zip file and run TC3SETUP.EXE. It then asks for the destination drive.Write the partition name and [...]
First C Language Program
Now we are starting our first simple program in C. Go to the directory where you have unzipped the Turbo C compiler.
Open Tc folder then open Bin folder and locate TC.exe file and open it. When the program opens go to File –> New. A blue background appears .It is the place where we write [...]
First C Language Program.How it works?
In our previous program i.e
#include<stdio.h>
void main()
{
printf(“My First Program”);
}
You have noticed the parenthesis “( )” I have used i.e in main and in printf .When you use parenthesis it means that you are calling the function.
Function tells the compiler a set of instruction which does something e.g printf is a function it tells the [...]
C Language Program:How will we write it?
From now on we will be writing our program like this.
#include
#include
void main()
{
clrscr();
printf(“My New Program”);
getch();
}
Here we are using another library called conio.h and we are taking two functions from from it i.e[...]
Constants and Variables
Constant is a quantity that does not change throughout the program.
For example we can write this. 3+2=5 . Here 3 , 2 and 5 are constants because it has the same meaning everytime we run the program i.e if i have written ‘3′ its value is three and it cannot be changed. Variable are those [...]
Format specifiers in C language
Format Specifiers in C language tells us which type of data to store and which type of data to print.This statement tells us that it is used in only 2 places
1) In taking Input
2) In displaying Output
Here is an example
int x=5;
printf( ” %d “, x );
The Result will be
5
Function printf of c language does not know [...]
Displaying output in C Language
In c language function printf is used to display output on the screen.
As the Function name printf tells that it is used to print something on the screen. It is used in almost every program of c language.I will describe different ways of using printf function in c language. [...]
Escape Sequences in C Language
Escape sequences in c language are used in the printf function of c language.For example if i want to print a value or anything in a new line i will have to use an escape sequence for new line in printf function of c language.
There are seven escape sequence in c language.
1) [...]
Taking input in C language
To take input in c language we use Scanf function.
Scanf function takes the input from the user and saves it in the variable.We can do multiple of works by taking input .A small example will be
If i have to make a program which prints the force i.e by multiplying mass with acceleration i have to [...]
Comments in C Language
Comments are generally those lines of code which the compiler or you can say computer skips and has no effect on our program.It is used to make our source code more readable i.e easy to understand.
There are two types of comments
1) Single line comment
2) Multiple line comment
[...]
Initializing Taking Input and Displaying Output of different variables
There are three major types of variables which you should know how to declare
1) Integer Numbers
2) Real Numbers
3) Characters
[...]
Arithmetic Operators in C Language
Operators are symbols which trasform a variable or combine two variables in some way to yield a different value.Example addition operator ‘+’ adds two values and the values on which operator works is called operand.
a=b+c;
Here a is assigned or initialized the sum of b and c. [...]
Arithmetic Assignment Operators in C Language
Arithmetic assignment operators in C language are those assigning values on left hand side variable by calculating the two or more operands on right hand side.
Example 1:-
int a = 0 ;
a = a + 1 ;
Relational Operators in C Language
Relational operators are those operators which relate two values and tells that the relation we made in between those two operartors is true or false.
For Example lets say i have two baskets we call first basket b1and second one b2. b1 contains 40 balls while b2 contains 30 ball
Logical Operators in C Language
Logical operators in c language are the operators which combine two or more conditions and evaluate the result (i.e true or false).
For Example
Lets consider same example in relational operators ie b1( i.e basket 1) has 40 balls and b2 has 30 balls.I will now write the statement of logical operator in our language.
Unary Operators in C Language
The are two unary operators in C Language
Increment operators are operators which add 1 in a variable.
Decrement operators are operators which subtracts 1 in a variable.
If Else Conditional Clauses
Conditional clauses are statements defining the conditions.At certain times we want our statement to execute when something occurs ie the condition is fulfilled.For conditions we use relational operators to define our condition.
There are three types of conditional clauses