Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 398 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Language C for all beginners

#1
Hello Code Community Members
This is just a quick tutorial for all beginner who want to learn c language

first of all you have to know about c standard libraries or header files, without including that, you can't even coding a bit in c or c++.
Let's take a look at some important header include.

  • <iostream> : This one is stand for (input/output stream) and use to get input from user and give output message to users screen(it's use for c++)

  • <stdio.h> : stdio Stand for (standard input/output) also use to get input and shows output message on screen. but it has some other more functions(see latter)

  • <cmath.h> : If you are going to use mathematical function in your program then it's recommended to include cmath

  • <conio.h> : Stand for (console input/output), also use to get input and shows output on screen ,but it has some built it functions(see latter)

  • <string.h> : Use for string functions [very useful]

  • <windows.h> : Use for windows applications


[To see links please register here]

but I am not going to cover all, google is your best friend for it


Lets learn how to include a header file
  • Here is syntax to include header file in C language


    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.


  • I'm going to show you two examples, let's take <conio.h> and <stdio.h> as example :fuckyea:

    1. Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.
      • It's use for getting input and showing input message on screen but it has some other built in functions like :

        1. Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.
          • stand for clear screen use to clear the contents of screen.
          [/*]

        2. Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.
          • stand for Get Character. The function use to get single character from user, your console will be paused till you give any single character. The character user entered can also stored in variable. e.g
          [/*]

        3. Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.
          • The console window will be paused till you give any character suppose you give (*) . the (*) character will saved in (ch) variable.
          [/*]

        You can know more about it with google so I'm not going to explain everything here because google is your best friend



      • Hidden Content
        You must

        [To see links please register here]

        or

        [To see links please register here]

        to view this content.
        • (standard input/output) it also contains different function that use in that task of input and output, Here is some common functions:

          1. Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.
            • This works similar as getch() works in conio.h header.


          2. Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.
            • stand for Put Character use to display single character using stdio.h header.


          3. Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.
            • Stand for Get String use to get input from user.

            As I said find others on google because google is your best friend
          [/*]
        [/*]
      [/*]
    [/*]

now we know how to include a header file so lets make a simple hello world program, In addition I will put comments for every line. for your better understand.



Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Variables are important part of any program in any language without this you can't make any good program.
  • int :stand for integers use for decimal numbers from 0 to 9

  • char :stand for characters use for any single character

  • float :use for real values such as 1.2, 2.3 , 4.5 etc

  • double :use for big real values.
    • Here is syntax to declare variables in C language.

      • Hidden Content
        You must

        [To see links please register here]

        or

        [To see links please register here]

        to view this content.
        • Here is a example for your better understand.

          Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.


          gives value to variable a

          Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.

          Now we got something new, It thing is (%d), what is this? it's actually string format use for function printf()

        • Here is some common string formats and symbols:

          1. %d : for decimal values
          2. %s : string values
          3. %c : character values
          4. %x : hex values


        • So if you want to print decimal value using printf function, syntax will be:


          Hidden Content
          You must

          [To see links please register here]

          or

          [To see links please register here]

          to view this content.

        [/*]
      [/*]
    [/*]


Let's go to talk about Operators (e.g. + - * = in C and C++)
you can know what is operators from

[To see links please register here]

, If you want to know everything about it

Here is list of operators:
  • (+) : for adding two values e.g(a + b)
  • (-) : for subtracting two values
  • (*) : Multiply two values
  • (/) : use for division
  • (%) : it's modulus operator use to get remainder of two values.
  • (=) : for assigning value to variable
  • (==) : for comparing two values for example (a==10) here we are not giving value to (a) but we are comparing and checking is a equal to 10.
  • (!=) : not equal, also use for comparing (a!=10) we are checking is (a) not equal to 10
  • (<) : less then operator, (a < 10) this command will check is the value of (a) is less than 10.
  • (>) : Greater then operator. (a > 10) is the value of (a) greater then 10.
  • (<=) : Less then or equal to. use to check if the value of left side is less then or equal to the value of right side for example (a <=10) here if the value of (a) is 0 to 10 then the condition is true.
  • (>=) : Greater then or equal to. (a >= 10) if the value of (a) is 10 or above then the condition is true.
  • ( || ) : or operator. it will work like this (a=10 or b = 10) but you will get error using this now instead of "or" we will use operator "||" (a=10 || b=10) this statement is true.
  • (&&) : And operator . wok like this (a = 10 and b = 10) again it's false then use and operator here, (a=10 && b=10) this is true statement.
  • You also can use as more values as you want like this

    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.


  • Here is syntax for using if statement

    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.


  • The conditional operators are use with if statement

    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.



    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.


  • yes condition is true because the value of (a) is 10 is not equal to (b=9) but the the 10 is greater then 9, and that's why the condition is true

    The code you will write here will execute.


    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.

  • Let's make a simple program using if statement.


    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.


    Try the above code and you will get console message "yes the condition is true"

I think now you got a question, I'm sure now you are thinking if the condition is false what will happen right? well don't worry guys, here is answer for it, we go for else statement!

To make a better program you will need to use else statement with if statement. because if the condition of "if" is false, then the the "else" statement will execute automatically.
  • The syntax of using else statement is:


    Hidden Content
    You must

    [To see links please register here]

    or

    [To see links please register here]

    to view this content.
    • Here is a example how it works


      Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.

    [/*]

Now little bit wired right? let's do it practically
make another simple program using if/else statement.




Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Run the above program it will show you "Running else statement"
how ?

Because the the condition of "if statement" is false because 8 is neither equal to 9 nor greater then 9. that's why the control skip the if statement and run the else statement code.


Multiple if/else statement and switch statement


Take a look at multiple if/else and switch statement.
  • Q : why i said multiple if/else and switch together ?

    A : Because both statements works same. you will need these statements if you have multiple conditions. still confused ?

Here are examples :
  • Suppose if a student get 40% marks in exams then he is simply pass. if he takes above then 50% then he has grade "C". If above 70% then grade "B".

  • And principle asked you to make a program for student then what will you do ?
    of course this program needs "if statement"
    but there are multiple if . then you will do it like this:

    • Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.



  • Like this huh? :no:
    If you are doing like this then you are going wrong . here are multiple if/else.

  • Take a look here:

    • Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.


  • I think now little bit confused for sure :yuno:, Don't worry let's get a real life example with simple program :

    • Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.


  • Note : always use (&) operator in function scanf(); like this scanf("%d",&a); else the program will be crashed as it will not allocate the value on right address. (&) sign use to get the memory address of variables.


how the above program works ? still confused ?
yeah it's a bit complicated instead of this you can use "switch statement"

Let's go ahead take a look at switch statement:
  • It's easy to understand and easy to use for multiple conditions
    • syntax for using this is:

      • Hidden Content
        You must

        [To see links please register here]

        or

        [To see links please register here]

        to view this content.

      [/*]
    [/*]
  • Example for switch statement :

    • Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.


  • Let's get real life example :

    • Hidden Content
      You must

      [To see links please register here]

      or

      [To see links please register here]

      to view this content.

    [/*]

Go ahead take a look on looping:

Looping mean run the commands again and again till the condition get false ..got it ?:lulsec:

of course not :yuno:

Ok here we start:

There are three main loops
  • for loop

  • while loop

  • do while loop
  • First we will talk on "while loop".
    • Syntax of using while loop is:

      • Hidden Content
        You must

        [To see links please register here]

        or

        [To see links please register here]

        to view this content.


    • how loop This loop works ?

      suppose you give while (a<=10) and the value of a is less then ten the loop will check condition oh yes the condition is true then it will execute the code again but using increment or decrement operator is changed and after all the time will come the value of a will not less then or equal to 10

      The condition will false and the loop stops..wtf? pretty confused ? :yuno:

      I know :pfft:

      Let's take a real life example:

      • Hidden Content
        You must

        [To see links please register here]

        or

        [To see links please register here]

        to view this content.

      [/*]
    • how the above program works?

    • see the value of a = 0 while(a <=10) this condition is true the control enter in code area and executes the code. by using
      a++ = a = a+1
      now the value of a = 1+1=2
      The loop will check again the condition, condition was (a<=10), now the value of a=2 here 2 is also less then 10, the control will enter again in execution area and will execute the program

      again here a++, now the value of a =2

      and a++ means a=a+1 = a= 2+1=3

      now the value of a is three which is still less then 10.
      At last the time will come the value of a will become 11 and the condition (a<=10) will become false and loop will be stopped.
      • Do while loop

        This loop will work at least once either the condition is true or false.
        • Syntax for do while loop:

          • Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.


        • Let's take a real life example :

          • Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.

          [/*]

      • For loop

        It is a wide loop used by programmers it executes the statement for specific number of times.
        • Syntax of for loop is:

          • Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.


        • Real life example:

          • Hidden Content
            You must

            [To see links please register here]

            or

            [To see links please register here]

            to view this content.

          [/*]
        [/*]

      Classes, user define function, file handling, arrays will be covered in my next tutorial
      -CrazyFrog-
      I dont care if you leech this tutorial but please give me credits saying CrazyFrog :biggrin:
      [/*]
    [/*]
Reply

#2
Give credits to the original owner of this tutorial. I can see the other forum tags in here, including emoticons that we dont have.
Reply

#3
Props to the owner, Was very in-depth. Not looking for c/p though.
Reply

#4
i posted this in my forum and posted here in my forum i have this meme smiles, uhm well i don't post my tutorials anymore here. i just tried to do something for the community, this is my own tutorial and

[To see links please register here]


Remember to think twice before say something to someone
Reply

#5
Finally we got your forum link !
Reply

#6
Quote:(07-12-2013, 01:30 PM)CrazyFrog Wrote:

[To see links please register here]

i posted this in my forum and posted here in my forum i have this meme smiles, uhm well i don't post my tutorials anymore here. i just tried to do something for the community, this is my own tutorial and

[To see links please register here]


Remember to think twice before say something to someone

Quote:(07-12-2013, 01:35 PM)Eternity Wrote:

[To see links please register here]

Finally we got your forum link !

Eternity, It really wasn't that hard to find it. Simple GOOGLE of eHackerz simple. He has said it was his site before. And since you are the original owner, Then I thanked you. So I don't get your panties in a wad beautiful.
Reply

#7
Thank you, enjoy
Reply

#8
Well I didn't know that it was your post, but if it is then great tutorial and good job!
Reply

#9
Great tutorial! Very HQ too. And don't worry, if you wrote this tutorial then you're free to post it anytime, anywhere.
I want to see more awesome tutorials from you.
Reply

#10
Quote:(07-12-2013, 01:37 PM)Blue Wrote:

[To see links please register here]

Quote: (07-12-2013, 01:30 PM)CrazyFrog Wrote:

[To see links please register here]

i posted this in my forum and posted here in my forum i have this meme smiles, uhm well i don't post my tutorials anymore here. i just tried to do something for the community, this is my own tutorial and

[To see links please register here]


Remember to think twice before say something to someone

Quote:(07-12-2013, 01:35 PM)Eternity Wrote:

[To see links please register here]

Finally we got your forum link !

Eternity, It really wasn't that hard to find it. Simple GOOGLE of eHackerz simple. He has said it was his site before. And since you are the original owner, Then I thanked you. So I don't get your panties in a wad beautiful.

But truly, that website looks pretty cool ;3
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through