Skip to main content

Posts

C Programming - 4.5 The printf() function

We have been talking about this guy for so long and he finally came And you will see him most of the time whenever you write a C code. So, What printf() function do? It basically prints everything within the double quotation . for example: printf("I am a programmer"); this prints:                     I am a Programmer In full code that will be- #include <stdio.h> int main() {      printf("I am a Programmer");      return 0; } Now, see another code  #include <stdio.h> int main() {      printf("I am a Programmer");      printf("I am a Programmer");      return 0; } the output will be:          I am a ProgrammerI am a Programmer The output is like this because we haven't use newline character to indicate the end of the line . So, the correction of the code will be:               printf("I am a Programmer\n");               printf("I am a
Recent posts

C Programming - 4.4 Escape Sequence

What?  Escape Sequence !!! Yeah, you heard that right There are some characters in C, which breaks the sequence of characters for formatting the output of a program, that's why these characters are called escape sequence. Most used escape sequences are         /n - this is also called newline character         /t - you can call it TAB character Yeah, you guess that right, the '\n' - newline character prints a newline when it is within double quotation("") of printf() function. Look at the top-left corner of your computer keyboard, you will find a button called TAB . Now, open an editor          start editing a file When you press TAB, it inserts 8 spaces by default. In some editors, you can modify the TAB size like Sublime Text, Code-Blocks etc. for my case, I am using 4 space TAB . So, in the editor, it depends upon your choice But, in C program output  '\t' - TAB character prints 8 spaces when it is withi

C Programming - 4.3 Header Files

Now, again see the first C program I wrote #include <stdio.h> int main() {      printf("I am a Programmer\n");      return 0; } Now, what #include <stdio.h> means actually  Here, stdio.h known as a Header file 😮, remember it's not studio.h 😜 . So many persons done that mistake when he/she first write C codes And, the coolest thing about header file is, it will give you a headache 😨 OK, I am just kidding  Header file term refers to that kind of file which contains C function declarations and macro definitions. A C header file contains .h extension. Like in this code stdio.h contains function declaration and definition of printf() that's why we had to include the  stdio.h  header file at the top of the code The basic syntax of including header files on top of the code #include <header_file_name> Now, you can wonder about printf() function, don't worry we will learn it gradually Some frequently used

C Programming - 4.2 The main() function

The main() function is the entry 🔑 point of a C program Now look at the code what I wrote #include <stdio.h> int main() {      printf("I am a Programmer\n");      return 0; } OK, I wrote, int main() here "int" represents the Integer number is, an Integer number is a whole number not a fraction one like 1,2,0,10,55 etc. now, the question ❓ is- Why I wrote int main() We all know mathematical function right. for example :                         f(x) = bx+c this function  f(x)  has a return value, let's say it's Integer , then for C it is int C functions are quite similar to mathematical functions , the basic format of a C function is return_type function_name() { } by writing int main(), we indicate that this main() function will return an int number. that's why we write return 0 at the end of the code because 0 is an int number int main() {      printf(&quo

C Programming - 4.1 First C program

First C program #include <stdio.h> int main() {      printf("I am a Programmer\n");      return 0; } Output:                    I am a Programmer In the next tutorials, we will understand this code point by point. Semicolon Issue we have to remember one important thing always end of every statement in C we have to put a semicolon From the first code, there are two statements        printf("I am a Programmer\n");        return 0; and both of them have a semicolon at the end of the line or statement Some people find this annoying 😒 but like it or  not we have to be careful about this Happy Coding See you in next tutorial Next Post: https://coderavens.blogspot.com/2018/05/c-programming-42-main-function.html

C Programming - 3. Bits & Bytes

Bits Bits means the measurement of computer memory where we can store binary number or word. N-bits memory can store n-bits binary number or words for example :          1-bit memory can store either  1 or 0 because 1 and 0 are 1-bit binary numbers          2-bit memory can store:                                                   00                                                   01                                                   10                                                   11         3-bit memory can store:                                                  000                                                  001                                                  010                                                  011                                                  100                                                  101                                                  110                                                  111

C Programming - 2. Environment Setup

In Windows machine Follow these following steps- Step 1: go to this link: https://filehippo.com/download_codeblocks/ Step 2: Download the code-blocks software Step 3:           Install it step 4:              If you run it the first time it will ask you to set gcc default compiler.               Just Click "OK" Button Step 5:            create a new file step 6:          save it as any name you want but with .c extension          example : first.c step 7:          type this code and save it.          #include<stdio.h>          int main()          {               printf("Welcome\n");                              return 0;          } step 8: Run the Program          by pressing F9                               or          clicking "Build and Run" button  on the code-blocks window Now if the code runs without any error then you are all set 😎 In Linux machine Step