• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C » Types and Variables

Storage of Signed Integers

By Dinesh Thakur

To store signed integers, we need to reserve one bit for the sign of the integer. It is usual convention to use a 0 bit to indicate positive sign and a 1 bit to indicate a negative sign. [Read more…] about Storage of Signed Integers

Pre-Processor Directive in C

By Dinesh Thakur

Macros are small functions (generally single line functions) which may be dealt with the help of preprocessor directive #define. Here, we shall discuss only the directive #define which is also used to define constants. A macro may or may not have parameters. An advantage of using a macro is that if a program involves a large number of the function calls of a small function the overburden of function calls can make the program inefficient; in case of macro, the code is substituted wherever the macro occurs. Thus, a programmer does not have to repeat the code again and again in the source code of the program while the function call is eliminated. However, a disadvantage of using macro is that data types are not included in the macro nor are these checked by the compiler. A few illustrations of macros are given below. [Read more…] about Pre-Processor Directive in C

Precision for Characters and Strings in C

By Dinesh Thakur

The field width and precision setting may be used for characters and strings as well. However, these have different meaning. See the following code: [Read more…] about Precision for Characters and Strings in C

Explicit Display of + and – Signs in Output in C

By Dinesh Thakur

In general, the sign is not displayed with positive values. However, if we desire to display the + sign, we may add it in the control string. If the display is desired to be left justified as well as with+ sign, add + or ++between the % sign and the conversion character; for example, the following code for integers. [Read more…] about Explicit Display of + and – Signs in Output in C

Precision Setting in C

By Dinesh Thakur

Precision is specified by the number of digits after the decimal point for the outputs for float as well as double numbers. If precision is not specified, it would be according to the default setting in the computer which is generally 6 digits. The precision may be specified by a period(.) followed by a positive number equal to the number of digits desired. An illustration is given below. [Read more…] about Precision Setting in C

Type Casting in C

By Dinesh Thakur

Type casting or type conversion refers to change of type of variables or pointers or user-defined objects from one type to another type. The need for type conversion arises in some operations involving two operands of different types, or even of same type. The example given below illustrates this concept. [Read more…] about Type Casting in C

C storage class Specifiers

By Dinesh Thakur

An object is a space in memory with a name or an identifier. The lifetime of an object is the storage duration of the object in a program, that is, lifetime is the portion of program execution during which the object exists with a constant address in the program and retains the last stored value. Three types of storage durations are defined in C, that is, automatic, static, and allocated. [Read more…] about C storage class Specifiers

Data Types in C

By Dinesh Thakur

Data types in C are specified or identified as the data storage format that tells the compiler or interpreter how the programmer enters the data and what type of data they enter into the program. Data types are used to define a variable before use in a program. Data types determine the size of the variable, space it occupies in storage. [Read more…] about Data Types in C

Function of printf and scanf in C

By Dinesh Thakur

The input into a program and output from a program is the basic requirements of any useful program. For input from standard input device, i.e., keyboard, the function scanf () is used and for output to the standard output device, i.e., monitor, the function printf () is used. Both these functions can take any number of arguments. The first argument is the formatting string enclosed between double quotes and consists of conversion characters. For printf () function, the formatting string may also contain any text that needs to be displayed on the monitor along with the values of variables. For example, if we want to display the value of an integer variable n, we may write the code as [Read more…] about Function of printf and scanf in C

Identifiers in C Language

By Dinesh Thakur

When we declare a variable name and its type, the compiler allocates a block of memory for placing its value. In fact, for the computer, this allocated block of memory is the variable and it recognizes it by its name. The sizes of memory blocks allocated for different types of data may vary on different computers depending on the hardware, the operating system, and the compiler used. The names of variables or identifiers should be carefully selected. The general guidelines are as follows: [Read more…] about Identifiers in C Language

typedef in c

By Dinesh Thakur

The typedef feature allows us to give an alternative (possibly short and more meaningful) name to an existing data type and improve program readability. For example, instead of using the int data type to declare variables to represent marks in three subjects, we can associate a more meaningful name (say Marks)for the int data type using typedef as: [Read more…] about typedef in c

Enumerated Types in C

By Dinesh Thakur

Consider that we need to work with the colours in a rainbow, e. g., to paint a rainbow on the screen. We thus have to work with seven colours, namely, violet, indigo, blue, green, yellow, orange and red. These colours can be represented using integer values starting with 0. This enables us to use various program constructs such as conditions or loops to process these colours. However, programs written using such code often become difficult to understand as can be seen from the statement given below. [Read more…] about Enumerated Types in C

How to Formatted Output using the printf Function

By Dinesh Thakur

The printf function allows the values of argument expressions to be printed in various formats. A large number of conversion characters are provided for printing expressions of different types. Also, the possibility of using several optional fields along with these conversion characters makes printf a very powerful and complicated function. [Read more…] about How to Formatted Output using the printf Function

Formatted Input – the scanf Function

By Dinesh Thakur

The scanf standard library function is used to read one or more values from the standard input (keyboard) and assign them to specified variables. A typical call to the scanf function takes the following form: [Read more…] about Formatted Input – the scanf Function

Formatted Output – the printf Function

By Dinesh Thakur

The printf (print formatted) standard library function is used to print the values of expressions on standard output (i. e., display) in a specified format. A typical call to the printf function takes the form of a C statement as [Read more…] about Formatted Output – the printf Function

Arithmetic Expressions in C

By Dinesh Thakur

An arithmetic expression contains only arithmetic operators and operands. We know that the arithmetic operators in C language include unary operators (+ – ++ — ), multiplicative operators (* / %) and additive operators (+ – ). The arithmetic operands include integral operands (various int and char types) and floating-type operands (float, double and long double). [Read more…] about Arithmetic Expressions in C

What is Expressions ? Type of Expression

By Dinesh Thakur

An expression is a combination of variables constants and operators written according to the syntax of C language. In C every expression evaluates to a value i.e., every expression results in some value of a certain type that can be assigned to a variable. Some examples of C expressions are shown in the table given below.  [Read more…] about What is Expressions ? Type of Expression

What happens when a variable is not declared in function definition

By Dinesh Thakur

Generally in C program the function definition and calling takes the form as given below: [Read more…] about What happens when a variable is not declared in function definition

How to assign values during declaration of variables

By Dinesh Thakur

Declaring variables tells the compiler the data type the variable is assigned and no storage area is allocated during this stage. It is possible to assign values during declaration itself. In order to see how this can be done let us see an example. [Read more…] about How to assign values during declaration of variables

What’s the best way to declare and define global variables

By Dinesh Thakur

First, though there can be many declarations (and in many translation units) of a single “global” (strictly speaking, “external”) variable or function, there must be exactly one definition. (The definition is the declaration that actually allocates space, and provides an initialization value, if any.) [Read more…] about What’s the best way to declare and define global variables

What happens when a variable is not initialized in main function

By Dinesh Thakur

when a variable is not initialized in main function it contains garbage value. This can be well seen from the example below. [Read more…] about What happens when a variable is not initialized in main function

What is scope & storage allocation of register, static and local variables

By Dinesh Thakur

Register variables: belong to the register storage class and are stored in the CPU registers. The scope of the register variables is local to the block in which the variables are defined. The variables which are used for more number of times in a program are declared as register variables for faster access. [Read more…] about What is scope & storage allocation of register, static and local variables

What is scope & storage allocation of extern and global variables

By Dinesh Thakur

Extern variables: belong to the External storage class and are stored in the main memory. extern is used when we have to refer a function or variable that is implemented in other file in the same project. The scope of the extern variables is Global. [Read more…] about What is scope & storage allocation of extern and global variables

Where is an Auto Variables Stored

By Dinesh Thakur

Main memory and CPU registers are the two memory locations where auto variables are stored. Auto variables are defined under automatic storage class. They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block execution. [Read more…] about Where is an Auto Variables Stored

What is a Register Variable

By Dinesh Thakur

Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable is local to the block in which it is defined. Lifetime is till control remains within the block in which the register variable is defined. [Read more…] about What is a Register Variable

Static Variable in C

By Dinesh Thakur

Static variable in C is a special variable that is stored in the data segment unlike the default automatic variable that is stored in stack. A static variable can be initialized by using keyword static before variable name. As the name indicates, the static variables retain their value as long as the program executes.

This is useful if we want to isolate pieces of a program to prevent accidental changes in global variables. You can declare a static variable by using the static storage class access specifier. For example, [Read more…] about Static Variable in C

Difference Between Declaring a Variable and Defining a Variable

By Dinesh Thakur

Declaration of a variable in C hints the compiler about the type and size of the variable in compile time. Similarly, declaration of a function hints about type and size of function parameters. No space is reserved in memory for any variable in case of declaration. [Read more…] about Difference Between Declaring a Variable and Defining a Variable

What is a Variables? Declaration of Variables.

By Dinesh Thakur

A variable is an object whose value may change during execution of a program. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Variable names are case sensitive. Others are constants whose values cannot be changed during the execution of the program. However, their values have to be declared. In a program a variable may be declared as below. [Read more…] about What is a Variables? Declaration of Variables.

How do You Decide Which Integer Type to Use

By Dinesh Thakur

If you might need large values (above 32,767 or below -32,767), use long. Otherwise, if space is very important (i.e. if there are large arrays or many structures), use short. Otherwise, use int. If well-defined overflow characteristics are important and negative values are not, or if you want to steer clear of sign-extension problems when manipulating bits or bytes, use one of the corresponding unsigned types. (Beware when mixing signed and unsigned values in expressions, though.) Although character types (especially unsigned char) can be used as “tiny” integers, doing so is sometimes more trouble than it’s worth, due to unpredictable sign extension and increased code size. [Read more…] about How do You Decide Which Integer Type to Use

Define the term Scope, Visibility And Lifetime of a Variable

By Dinesh Thakur

An object is recognized by the computer by either its identifier or name. The object may be a variable of basic type or a function, a structure, or a union. The macro names and macro variables do not figure in the scope because macros are replaced by the preprocessor token sequences before the semantic phase of program translation. An identifier may also represent different objects in different scopes. [Read more…] about Define the term Scope, Visibility And Lifetime of a Variable

Next Page »

Primary Sidebar

C Programming

C Programming Tutorials

  • C - History
  • C - Anatomy
  • C - Constants
  • C - Identifiers
  • C - Data Types
  • C - Libraries File
  • C - Header Files
  • C - Basic Language
  • C - Data Types Sizes
  • C - Header Files Importance
  • C - Escape Sequences
  • C - Main() Purpose
  • C - Program Procedure
  • C - Control Statements
  • C - Enumeration Constant
  • C - Add numbers
  • C - Return Statement
  • C - Avoid Goto
  • C - Command Line Arguments
  • C - Switch Case
  • C - Switch Case Limitations
  • C - getchar() and putchar()
  • C - Iteration Statements
  • C - Pass by Value and Reference
  • C - Structures and Unions
  • C - Structure
  • C - Dynamic Memory
  • C - Fgets and Fputs Functions
  • C - Gets() and Puts() Functions
  • C - Armstrong Number
  • C - Storage Classes
  • C - Fibonacci Series
  • C - Precision Setting
  • C - const Parameters

C - Variable & It's Type

  • C - Variables
  • C - Variable Lifetime
  • C - Static Variable
  • C - Register Variable
  • C - Global Variables
  • C - Auto Variables
  • C - Local Variables

C - Operator & Expressions

  • C - Operator
  • C - Boolean Operators
  • C - Bitwise Operator
  • C - Arithmetic Operators
  • C - Modulus Operator
  • C - Ternary Operator
  • C - Expressions
  • C - Arithmetic Expressions

C - Array

  • C - Arrays
  • C - Array Types
  • C - Array Characteristics
  • C - Static Arrays
  • C - Global Arrays
  • C - 3D Arrays
  • C - Dynamic Arrays
  • C - Pointer to 3D Arrays
  • C - Array Elements Hold
  • C - Arrays as Function Parameters
  • C - Accessing Matrix Elements
  • C - File Handling
  • C - Matrix Multiplication
  • C - Dynamic Memory Allocation

C - Searching & Sorting

  • C - Data Structures
  • C - Linear Search
  • C - Bubble Sort
  • C - Merge Sort
  • C - Linked List
  • C - Insertion Sort
  • C - Binary Search
  • C - Selection Sort
  • C - Quick Sort

C - Functions

  • C - Functions
  • C - Functions Advantages
  • C - Void Functions
  • C - Function Call
  • C - Default Return Value
  • C - String functions

C - Pointer

  • C - Pointers
  • C - Type Casting Of Pointers
  • C - Pointer Advantages
  • C - Pointers Initialization
  • C - Vectors and Pointers

C - Differences

  • C - C Vs C++
  • C - Formal Args. Vs Actual Args.
  • C - Keywords Vs Identifiers
  • C - Strings Vs Character Arrays
  • C - Address Vs Dereference Operator
  • C - Goto Vs longjmp
  • C - Declaring Vs Defining Variable
  • C - String Vs Array
  • C - Call by Value Vs Reference
  • C - Structure Vs Union
  • C - For Vs While loops
  • C - Compiler Vs Interpreter

C - Programs

  • C Program Standard Deviation
  • C Program Calculate Tax
  • C Program Sum Series
  • C Program Merge Arrays
  • C Program Euclid’s Algorithm
  • C Program Print Weekdays
  • C Program Sum of Digits
  • C Program Print a list
  • C Program Print Pythagorean
  • C Program Quiz program
  • C Program Display Table
  • C Program Print Comma-Separated
  • C Program Prints Prime Numbers
  • C Program for Print Integer
  • C Program Count Number
  • C Program Print Color Name
  • C Program Print Odd Numbers
  • C Program Calculate area
  • C Program for a Menu
  • C Program Add Two Vectors
  • C Program Array Addresses
  • C Program Division by Zero Error
  • C Program Compare two Dates
  • C Program Tower of Hanoi
  • C Program return 3 Numbers
  • C Program for Prime Numbers
  • C Program for Factorial
  • C Program for Palindrome

Other Links

  • C Programming - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW