size of char datatype and char array in C Last Updated : 15 Oct, 2019 Comments Improve Suggest changes Like Article Like Report Given a char variable and a char array, the task is to write a program to find the size of this char variable and char array in C. Examples: Input: ch = 'G', arr[] = {'G', 'F', 'G'} Output: Size of char datatype is: 1 byte Size of char array is: 3 byte Input: ch = 'G', arr[] = {'G', 'F'} Output: Size of char datatype is: 1 byte Size of char array is: 2 byte Approach: In the below program, to find the size of the char variable and char array: first, the char variable is defined in charType and the char array in arr. Then, the size of the char variable is calculated using sizeof() operator. Then the size of the char array is find by dividing the size of the complete array by the size of the first variable. Below is the C program to find the size of the char variable and char array: C // C program to find the size of // char data type and char array #include <stdio.h> int main() { char charType = 'G'; char arr[] = { 'G', 'F', 'G' }; // Calculate and Print // the size of charType printf("Size of char datatype is: %ld byte\n", sizeof(charType)); // Calculate the size of char array size_t size = sizeof(arr) / sizeof(arr[0]); // Print the size of char array printf("Size of char array is: %ld byte", size); return 0; } Output: Size of char datatype is: 1 byte Size of char array is: 3 byte Comment More infoAdvertise with us Next Article size of char datatype and char array in C C code_r Follow Improve Article Tags : C Programs C Language C-Data Types Similar Reads How to Find the Size of an Array in C? The size of an array is generally considered to be the number of elements in the array (not the size of memory occupied in bytes). In this article, we will learn how to find the size of an array in C.The simplest method to find the size of an array in C is by using sizeof operator. First determine t 2 min read ASCII Value of a Character in C In this article, we will discuss about the ASCII values that are bit numbers used to represent the character in the C programming language. We will also discuss why the ASCII values are needed and how to find the ASCII value of a given character in a C program.Table of ContentWhat is ASCII Value of 4 min read How to Create an Array of Structs in C? In C, a structure is a user-defined data type that can be used to group items of different types into a single entity while an array is a collection of similar data elements. In this article, we will learn how to create an array of structs in C. Creating an Array of Structs in CTo create an array of 2 min read Find the Length of Character Array in C In C, a character array is a collection of elements of the âcharâ data type that are placed in contiguous memory locations and are often used to store strings. The length of a character array is defined as the total number of characters present in the array, excluding the null character ('\0') at th 2 min read Advantages and Disadvantages of Array in C An array is a data structure that stores a collection of elements, all of the same data type, in a contiguous block of memory. Each element in the array is identified by an index, which is a numerical value that represents the position of the element in the array. The first element in the array has 8 min read Like