Hello & Welcome!!
Here, We are going start a new Tutorial series. In this series we are going to learn programming with C.
Why C??
Well, Good question. C is called the mother of programming language. It's the closest language to computer. We know computer can't understand any kind of language. It's only know true or false. We have to use a software called compiler to make it understood our program. Compiler compile the code to machine language or binary representation.Then only computer can understand it.
C is closest language to machine language. So, if we learn C, we could go to close to computer. And also if you learn C well, will can learn any other one easily. That's why C...
C is closest language to machine language. So, if we learn C, we could go to close to computer. And also if you learn C well, will can learn any other one easily. That's why C...
No more talk....Lets start...
First, We need a compiler to write and compile the code. We will use Codeblocks as compiler. So, go to this link and download codeblocks. After completing the download install the setup. After installing you will see the shortcut icon on desktop. Open it!!
Now, you will see like this.
Now, we have to create a new file to start programming. For creating a new .c file
Click> File>New>Empty File
or
Press> Ctrl+Shift+N
Now, you will see like this. So, this our main window, We will program here.
Now, before starting programming, we have to save it. So,
Click>File>Save
or
Press>Ctrl+S
Save the file.
Now, Lets start programming.....!!
First type these...
#include<stdio.h>
int main()
{
return 0;
}
Typed it?? Lets learn what is it??
#include<stdio.h>
by typing this we have included stdio header file. This is the way to add a file in C language. So, what is header file and what is stdio header file? Why we include it? Header file is pre-maded file where some function are included. We can use those function by including the header file. There are some header file. Such as, stdio.h, math.h, string.h ......
stdio means standard input output. In this header file some function are included for some basic work such as take input or giving output. That's why we included it.
Next, we are seeing int main(). This is a function and it's the main function a program. We will do all of our programming in this function. For any function we have to use {}. { means starting of a function and } means end of a function. That's why we use it for main function and write a thing return 0; in it. We have written int before main(). It means this main function return integer type value. int is the short form of integer and we will use it in all of our program.
Now, lets come to return 0; .We will write this at the end of the program. When we will run this program, return return something to the function. and return 0 return nothing. 0 means nothing.
We have used a semicolon at end of the return 0. It means the end of the statement. We have to use it for all statement.
So, these are the basic thing for writing a program. We have to use it for all program.
Now, we will learn a function which is included in stdio.h header file. Look at this function.
printf();
This is function for printing something. We will use it for printing something. For doing this we will write something in these two ().
Lets write and run our first program.
int main()
{
printf("Hey You!!");
return 0;
}
We tell to print Hey You!! . We will use "" for printing anything.
For running this go to Build>Build and run or Press>F9.
You will see....
So, Congress!! You have done your first program. So, keep going.
That's all for today. Hopefully learned something. See you on Next tutorial.....
EmoticonEmoticon