• Welcome to Web Hosting Community Forum for Webmasters - Web hosting Forum.
 

Recommended Providers

Fully Managed WordPress Hosting
lc_banner_leadgen_3
Fully Managed WordPress Hosting

WordPress Theme

Divi WordPress Theme
WPZOOM

Recent Topics

Forum Membership

Forum Membership

different types of variable in C ?

Started by kavitajain9782, June 26, 2019, 12:49:40 PM

kavitajain9782

Hello Dear,

              Please Tell Me What are the different types of variable in C ?

Zolgains

Quote from: kavitajain9782 on June 26, 2019, 12:49:40 PM
Hello Dear,

              Please Tell Me What are the different types of variable in C ?
First of all, what you probably meant was data types. The standard data types in C are:

  • char
  • int
  • float
  • double

With also their long, short, signed and unsigned prefixes.

grofee

Types of Variables in C
1. local variable
2. global variable
3. static variable
4. automatic variable
5. external variable

Akshay_M

In the C programming language, variables are used to store and manipulate data. There are several types of variables based on the data they can hold and their memory requirements. Here are the main types of variables in C:

int: Stands for integer. It is used to store whole numbers (positive, negative, or zero). For example: int age = 25;

float: Used to store floating-point or decimal numbers. For example: float pi = 3.14159;

double: Similar to float, but can store larger decimal numbers with higher precision. For example: double salary = 50000.75;

char: Used to store a single character. For example: char grade = 'A';

_Bool: Represents a Boolean value, which can be either 0 (false) or 1 (true). C99 introduced the _Bool type, but you can also use int for Boolean values.

short: Stores smaller integer values than int. It takes less memory but has a smaller range. For example: short num = 100;

long: Stores larger integer values than int. It takes more memory but has a larger range. For example: long population = 8000000L;

long long: Introduced in C99, it is used for storing very large integer values. For example: long long bigNumber = 123456789012345LL;

unsigned int: Stores only positive integer values, effectively doubling the range of positive values for an int. For example: unsigned int count = 10;

unsigned char: Stores positive character values only, extending the range of characters that can be stored compared to the regular char.

unsigned short: Similar to unsigned int, it stores only positive short integer values.

unsigned long: Similar to unsigned int, it stores only positive long integer values.

unsigned long long: Similar to unsigned int, it stores only positive long long integer values.

These are the basic data types in C, and they can be modified using qualifiers like signed, unsigned, short, and long to create variations of the basic types. Additionally, the typedef keyword allows you to create custom type names based on existing data types. Remember that the memory size and range of each data type can vary based on the system you're using.