DEV Community


Posted on • Originally published at

Size of int array c++

Array size in c++

An array is a collection of variables of a particular data type that are introduced together or continuously in memory. Like other variables, an array needs to be introduced. Yes. It indicates the size of the array. The number given in brackets when using the array is the individual number of this member of the array. The numbers of the members of the array start from 0. Reading data from the array. The process of writing is performed through a loop, similar to the process of writing.

For example, if I use integer type arrays in my program. You can also create float arrays. And you can also use string data type. If I have input the integer data type in the array. The number was specific. What will be the number of members of the data to be inputted. So what do I have to do in such a situation. The first thing is that the array will be introduced. The number of members will be kept much higher than expected. It then uses the do-while loop instead of for to input data. The process will be subject to a logical expression. In order to display the integer data type in array in #define40, we have set the size of the array to 40 members.

Friends, many empty arrays are also introduced. But it can also happen that as soon as the arrays are introduced, the initial values ​​are given to its members. int george = 40; I have also created a program which I am telling you in kodlogs. In which you will give the price of something in money, then the program will tell you how much of that money is two rupees and how many rupees, how many fifty paise, how many twenty five paise.

Let's say I write 563 paise in my program. Then he will tell you that you will make two coins of two rupees, one of rupee, one of fifty paise and 13 coins of one paisa. Finally, the size of the compiler array is Will find out the number of quantities introduced.

Example program:

#include <stdio.h>
#include <conio.h>
#include <string. h>
Void main(void)
Char fname[60];
Int dex;
Int length;
Clrscr( );
Puts("/nEnter your name:");
Printf ("addr=%5u char='%c=%3u\n",
       &fname[dex],fname[dex],fname[dex] );
getch( );
Enter fullscreen mode Exit fullscreen mode


Enter your name:

Tania Ishfaq

Addr = 65442 char = 'K' = 75
Addr = 65443 char = 'o' = 111
Addr = 65444 char = 'd' = 100
Addr = 65445 char = 'l' = 108
Addr = 65446 char = 'o' = 111
Addr = 65447 char = 'g' = 103
Addr = 65448 char = 's' = 115
Addr = 65449 char = ' ' = 0
Addr = 65450 char = ' ' = 0
Addr = 65451 char = ' ' = 0
Addr = 65452 char = '●' = 65223
In this program you can see what happened after the end of the string. The program deliberately prints 3 characters longer than the length of the string. After the string ends, the first null character appears. Then the meaningless characters are printed. As a result, the blank space and its value are printed. Which may be data or program components after this array.

  1. Using sizeof( )

  2. Using pointer

  3. Using strln( )

Summary :
Today we understand kodlog website, I try to explain the size of int array in c++. I hope after reading this article you will be able to understand the size of int array in c++. I would like to have feedback from my kodlog site. Please post your feedback, question, or comments about this article.

Article Tags:
C#|Python |Python 3|pycharm |html|java|JavaScript |cpp|code|rubi|Network | Google |html5 |php|bootstrap |string |Microsoft |variable |syntax |Coders |Codinglove|
Xml|game| net| list | loop | integer |float | string | double |

Top comments (0)