Posts

C Data Types

Image
 Each variable in C has an associated data type.  It specifies the type of data that the variable can store like integer, character, floating, double, etc.  Each data type requires different amounts of memory and has some specific operations which can be performed over it.  The data type is a collection of data with values having fixed values, meaning as well as its characteristics. The data types in C can be classified as follows:   Integer Data Type The integer datatype in C is used to store the integer numbers(any number including positive, negative and zero without decimal part). Octal values, hexadecimal values, and decimal values can be stored in int data type in C.  Range:  -2,147,483,648 to 2,147,483,647 Size: 4 bytes Format Specifier: %d Syntax of Integer We use int keyword to declare the integer variable: int var_name; The integer data type can also be used as unsigned int : Unsigned int data type in C is used to store the data values from zero to positive numbers but it can’

Tokens in C

Image
A token in C can be defined as the smallest individual element of the C programming language that is meaningful to the compiler. It is the basic component of a C program. Types of Tokens in C : The tokens of C language can be classified into six types based on the functions they are used to perform. The types of C tokens are as follows: Keywords Identifiers Constants Strings Special Symbols Operators 1. C Token – Keywords : The keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. You cannot redefine keywords. However, you can specify the text to be substituted for keywords before compilation by using C preprocessor directives. C language supports 32 keywords which are given below:  auto              double           int   

State the use of printf() and scanf() with suitable example

 The printf() function is used to display output and the scanf() function is used to take input from users. The printf() and scanf() functions are commonly used functions in C Language. These functions are inbuilt library functions in header files of C programming. printf() Function: In C Programming language, the printf() function is used for output. printf() function can take any number of farguments. First argument must be enclosed within the double quotes "hello" and every other argument should be separated by comma (,) within the double quotes.  Important points about printf(): printf() function is defined in stdio.h header file. By using this function, we can  print the data or user-defined message on monitor (also called the console). printf() can print a different kind of data format on the output string. To print on a new line on the screen, we use "\n" in printf() statement. C language is case sensitive programming language. For example, printf() and scan