My First Program in C And Introduction to C Programming

0
162
My First Program in C And Introduction to C Programming

In The Name of Al-Mighty ALLAH The All-Forgiving and All-Mercifull…

Asalam u alikum …!!!

Umair Ali here from securitytraning.com …..

so,i would be teaching you guys , about C language…

The Book , i would Recommend is “Let us C by Yashwant Kanetkar”

Introduction : C , is a simple language created by Dennis Ritchie …!!!

Compiler : Turbo C (You can get Turbo C here )

Let’s start Shall we ?? , Okayy so …
i Saw a lot of videos on youtube but they just made their tutorials in voice , so thought to make tutorials
in a different way ..!!

It’s going to be hard in the 1st time but if you guys would check this video again and again and read the book
i recommended , then i am sure you would get to understand C programming …

So let’s Start …

So let’s write the whole program here in notepad ++ , and let me describe each and every part of it
so that you guys could understand better …
Program:

[code lang=”cpp”]
#include <stdio.h> ——//library
#include <conio.h>
void main(void){
clrscr();
printf("Hello World , Welcome to wonderful world of C programming..!!")
getch();
}
[/code]

Ok here’s codes , let’s write it in compiler 1st to check the results …
Now let’s run these codes by ctrl + f9

atrl+enter to minimize and maximize the screen …
As you can see it prints the status “Hello World Blah Blah Blah ..!!” Anyways let’s come to the point ..
here , <stdio.h> means standard input/output and it’s a library , where as <conio.h> is another library means
console input/output , and we are using the #include command to including these librariess’s codes in our program

a library is actually a set of declearations of functions like printf, without this libraries in the program ,
the compiler won’t understand about any code or the function like printf etc , so these libraries are essential …..

Anyways let me clear this point by omiting these libraries from our program and running the compiler …!!
did you see ? it says printf should have a prototype , i hope my point is clear now …

so what’s a printf ? basically it’s a function defined in our libraries this function helps us to print any status or
phrase we want, as we saw . …

So , we have discussed about the libraries and printf(); function , but you may wonders what’s this void ???

It’s a type we will get into it when we discuss about function later on , so leave it for now just think that it’s
essential to put , void …

Now check this line :

[code lang=”cpp”]
main()){
}
[/code]

so what’s this line ?

well it is also a function without this function the compiler would give u an error ..
and basically whatever we would like to type , goes in this function’s braces ..
like for eg ..

[code language=”cpp”]
main(){
printf("Hello.!!");
}
[/code]

if you type anything without this fucntion the compiler would encountered an error , or sth else would
happens let’s give it a try to clear my point …

just as i said , error .. anyways let’s move to the next part shall we ? ..

basically every word with () this is called a fucntion ..!!

[code language=”cpp”]
#include <stdio.h>
#include <conio.h>
void main(void){
clrscr();
printf("Hello world , welcome to the beauty of C language ..!!");
getch();
}
[/code]

so what’s a getch ??
well it is also a function defined in the libraries , basically what it does is , it helps us to hold the screen and
read those phrase … with out this function the program would run in nano sec that our eyes can;t even see..

recall that every word ends with “()” this is called a function …

for e.g :

[code language=”cpp”]
main()
lol()
Umair()
[/code]

anyways let’s give it a try by omitting getch() and see what happens..

See ? i already run this with ctrl + f9 but nothing shows up ? cuz there’s no getch function ..

now getch means get character from user , and it holds the screen till the user press any key ..

Now you may wonder what’s clrscr() doing in our program ??

well it means clear screen , if you won’t write this function printf will print the old phrase which you typed once
in the output let me clear this point by doing it practically ..!!

see? the old output ..!! isn’t actually clearing cuz of omiting clrscr() function from our program ..
So you get My point Now ??

well now the last part of this section …

The Comments in C programming …

we can put comments for a program for another programmer who would like to check our codes ..

like this ..

[code language=”cpp”]
#include <stdio.h> //this is a library
#include <conio.h> // this is a library
void main(void){ // this is the main fucntion
clrscr(); // this clears the screen
printf("Hello world , welcome to the beauty of C language ..!!"); //this will print a phrase
getch(); // this function holds the screen ..
}
[/code]

Basically when you write anything in front of “//” the compiler doesn’t bother to read it , it ignores that part of
the code ….
Now we can put comments in two ways …

1st is this :

//this is a single comment …

what about multi comment ..

well

[code lang=”cpp”]/*
printf("hello");
etc …
getch();
*/[/code]

this syntex is used as multi-conment …
Now let me show both syntex in our program once so that our point would get clear …
i hope this video would be worthy cuz i tried my best to explain this here however i know
you guys won’t be able to understand it now cuz it’s new , if you guys would read book once your all points
would be clear …!!!

Thanks for watching ..
ALLAH HAFIZ …

ALLAH IS Great

./logout

LEAVE A REPLY

Please enter your comment!
Please enter your name here