Day#2 [ 21 Days — C Programming ]

CS IITIAN
4 min readOct 5, 2021

Today we will learn variables , keywords and data-types in C , most important we will make out first C Program which is to print “Hello World!!!” .

So be ready with pen and paper and make proper notes so you can revise easily .

If you are not familiar to these don’t worry we will see one by one .

Print “Hello World!!!”

You are familiar with this code except 3rd line .

Line-3 : printf is a function and it is used to show output . Whatever you want to print write in printf with double quote .

Example:

printf(“Tick-Tick”) -> It will show Tick-Tick to the console/Output.

All functions are defined in particular header file . printf function is defined in “stdio.h” header file , So if you don’t include “stdio.h” it will give you error that printf function is not defined .

We will see more header files and their functions .

Assignment : Print your name .

you can try to print more things like .

“\n” is used to move cursor in new line , try yourself by using \n at different places and see the results .

Variables and Datatypes in C

Variable is the name given to a memory location . It store the value and we can modify value .

Since value can be your name, your age or any number so there are different-different datatypes which defines the types of variables . So let’s see datatypes used in C Programming -

  1. int : Store Numeric Value
  2. char : Store Character
  3. float : Store Floating value with single precision
  4. double : Store Floating value with double precision

So let’s see some variables -

  1. int a = 2;
  2. float b = 3.14;
  3. char c = ‘A’;
  4. double d = 22.12;

Keywords in C

Keywords are reserved words that you can’t use in your program for any other purpose because they are defined for specific purpose .

There are total 32 keywords in C .

Here is a list of Keywords -

  1. auto
  2. break
  3. case
  4. char
  5. const
  6. continue
  7. default
  8. do
  9. double
  10. else
  11. enum
  12. extern
  13. float
  14. for
  15. goto
  16. if
  17. int
  18. long
  19. register
  20. return
  21. short
  22. signed
  23. sizeof
  24. static
  25. struct
  26. switch
  27. typedef
  28. union
  29. unsigned
  30. void
  31. volatile
  32. while

Print Variables

Previously we have printed Hello World!!!, name etc.

we use special format specifiers to print variables which starts with % and then type of variables .

Here are format specifiers -

  1. int : %d
  2. float : %f
  3. char : %c;
  4. double : %lf
  5. long : %ld
  6. long long : %lld
  7. long double : %Lf
  8. octal : %o
  9. hexadecimal : %x
  10. unsigned int : %u

printf(“c =%c\nf = %f”,c,f); first %c will be replaced by value of c and second %f will be replaced by the value of variable f.

If you find the content of this website interesting and helpful, use the “Buy HW Programmer a Coffee” link below to buy me a coffee. Your generosity will keep me caffeinated and Inspire me to keep the website up and running .

Thank you so much for your consideration.

https://ko-fi.com/hwprogrammer

Let’s Connect with us :

Instagram : https://www.instagram.com/hwprogrammer/

Facebook Page : https://www.facebook.com/hwcoder

Facebook Group : https://www.facebook.com/groups/838100380386300

--

--

CS IITIAN

Funny Grand Son | Good Son | Supportive Brother | Software Engineer | Philosopher | Consistent | Non Reactive | The Man from India ( Country of Sages )