Basic of c programming language

22 Jul 2022 Balmiki Mandal 0 C Programming

Elements of c programming

Every language has some basic elements and grammatical rules. Before understanding programming, it is a must to know the basic elements of c programming. The basic elements are character set, variablescape sequence, keyword, Datatypes, variable Declaration, Expressions, statements, etc. all of these are used to construct a c program.

 

What is Character set in c 

The character that is used in the c program is given below there are three

     Alphabets
    A, B,C.......Z(Uppercase )
    a,b,c.......z(lowercase)

    Digits 
   0,1,2,3,4,5,6,7,8,9

 

What is Scape sequence in c programming

Characters are printed on the screen through the keyboard but some characters such as newline, tab, and backspace cannot be printed like other normal characters, c Support the combination of backslash (\) and some characters from the c character set to print these characters. The first character is "\" and the second character is from the C character set.

What are the Keywords\ Reserved Words in c

There are certain words that are reserved for doing a specific task. These words are known as keywords and they have standard, predefined meanings in C. They are always written in Lowercase. there are only 32 keywords available in c

which is given below:

 

Identifiers in C programming

All the words that we'll use in our C Programs will be Either keywords or identifiers. keywords are predefined and can't be changed by the user while identifiers are user-defined words and are used to give names to entities like variables, arrays, functions, structures, etc.

Rules for naming Identifiers

  • The name should consist of only alphabets, digits, and underscore signs (_).
  • The first Character should be an alphabet or underscore.
  • The name should not be a keyword.
  • since C is case-sensitive, the uppercase and lowercase letters are considered different. for example, code, code, and CODE are three different identifiers.
  •  an Identifier's name may be arbitrarily long. some implementations of C recognize only the first eight characters, Through most implementations recognize 32 characters

   
Datatypes in c programming language in c

A data type defines a domain of allowed values and the operations that can be performed on those values. storage representation of different datatypes in different memory.

Two categories of data

  • constant data
  • variable data

There are 4 types of data in c

  1. character (constant character, variable character)
  2. integer(constant integer, variable integer)
  3. real(float,double)(constant,variable)
  4. string(constant,variable)

There are four fundamental data types in C, 

  1. int
  2. char
  3. float
  4. Double.

Example

'1'      → char constant  

1       →  int constant

1.0    → double constant

1.0f   → float constant

"1"    → string   constant

When you want to deal with various types of data you need to declare variables.if a variable declared outside of the main() function it is called a a global variable and if it declares inside the function it is  called a a local variable 

syntax for declaring a variable:

 datatype variable_name;

There are two types of qualifiers-
1. Size qualifiers - Short, long
2. Sign Qualifiers -signed, unsigned


when the qualifier unsigned is used the number is always positive, and when signed is used number may be positive or negative/ if the sign qualifier is assumed. the range of values for signed data types is less than that of unsigned types. this is because in signed type, the leftmost bit is used to represent the value.

the size and range of different data types on a 32-bit machine is given in the following table. the size and range may vary on machines with different word sizes.

wht are the Basic data types in c   

Constant in c programming 

The constant is a value that can not be changed during the execution of the program.

  There are two types of constants in C programming:

  1. Numeric constants: These are constants that represent numeric values, such as integers, floating-point numbers, and character constants. Numeric constants can be expressed in decimal, octal, or hexadecimal notation.

  2. Symbolic constants: These are constants that are represented by identifiers, which are defined using the #define preprocessor directive. Symbolic constants are typically used to define values that are used repeatedly in a program, such as constant values or configuration settings.

Top Resources

 

C Program to find out the size and limits of data types

Further Reading:

 For further information and examples, Please visit[ C-Programming From Scratch to Advanced 2023-2024]

 

 

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.