Initializing an Array

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 128

  • @sahilanower9189
    @sahilanower9189 5 лет назад +51

    Great sir. Neso Academy's way of explanation is really exciting. Would love to see you get more views by people such as me❤

  • @tiwaritejaswo
    @tiwaritejaswo 3 года назад +11

    Videos from Neso Academy are absolute gold. Pure concept.

  • @elaounisalman4028
    @elaounisalman4028 5 лет назад +10

    thank you so muuuuch from Germany Sir

  • @shankarbhandari3901
    @shankarbhandari3901 4 года назад +5

    i m from nepal & its helping us a lot! thank you very much sir

  • @rgeeteshsaravanan1787
    @rgeeteshsaravanan1787 3 года назад +7

    found this after my mid sem , hopefully ill ace my end sem by learning from this , hats off to u sir, ur infinite times better than my teacher !

  • @sumansahoo4433
    @sumansahoo4433 2 года назад +5

    Programming can't be more easier how you making this!❤️❤️❤️

  • @soumi6720
    @soumi6720 2 года назад +2

    Sir u are a genius in explaining and this channel is great

  • @buragapuvenkataratnam2395
    @buragapuvenkataratnam2395 Год назад +2

    Thanku for ur clear voice and explanation sir

  • @ayonmitra4767
    @ayonmitra4767 5 лет назад +6

    Also please upload pointers, structures and data structure implementation in c(tree, stack, queue, link list, malloc etc..) Thank you

  • @KavyasriKinjarapu
    @KavyasriKinjarapu 4 месяца назад

    Great sir we are lucky to have a teacher like you ❤

  • @charansuvvari
    @charansuvvari 6 месяцев назад +1

    I m now doing my 1semister of my CSE the best explanation...that I have seen

  • @upgradojha
    @upgradojha 4 месяца назад +1

    A small correct at 5:20 The statement `int arr[10] = {};` is legal in C, but its interpretation and behavior might not be immediately clear to all compilers, depending on the C standard they adhere to.
    Explanation:
    1. **C99 and later**:
    - In C99 and later standards, you can initialize an array with `{}`. This is called a "universal zero initializer". It means that all elements of the array will be initialized to zero.
    - The statement `int arr[10] = {};` will initialize all elements of `arr` to `0`.
    2. **Pre-C99**:
    - In C89/90 (the earlier C standard), the empty braces `{}` as an initializer might not be explicitly supported, and this could lead to a compiler error or warning.
    - Instead, you would typically initialize an array explicitly or with `{0}`:
    ```c
    int arr[10] = {0}; // All elements initialized to 0.
    ```
    Example in Code:
    ```c
    #include
    int main() {
    int arr[10] = {}; // Legal in C99 and later
    for(int i = 0; i < 10; i++) {
    printf("%d ", arr[i]);
    }
    return 0;
    }
    ```
    Compatibility:
    - If you are using a compiler that supports C99 or later, the code should compile and run without issues, initializing all elements to zero.
    - If using an older compiler that does not support C99, you may get an error or warning. In such cases, use `int arr[10] = {0};` for compatibility.
    ### Conclusion:
    - `int arr[10] = {};` is legal and initializes all elements to zero in C99 and later.
    - For maximum compatibility with older C standards, use `int arr[10] = {0};`.

  • @sungchulyonseiackr
    @sungchulyonseiackr Год назад

    5:00 int arr[10] = {}; works in 2023. The c complier may be updated. I tested this using both gcc and clang. Here is the test code : #include
    int main()
    {
    int a[10] = {};
    for ( int i = 0; i < 10; i++ ) printf("a[%d] = %d
    ", i, a[i]);
    return 0;
    }

  • @RanjanaChamanlalSoni
    @RanjanaChamanlalSoni Год назад

    Thanks a lot sir... I barely got any doubt in this topic now

  • @sadiqabdulrahimzai4915
    @sadiqabdulrahimzai4915 4 года назад +1

    Thanks teacher your very helpful ..

  • @ashishsinha8893
    @ashishsinha8893 5 лет назад +8

    Sir it's my heartiest request plz upload regularly my interview are near

    • @gaurav_10108
      @gaurav_10108 Год назад +1

      What are you doing now? Any job aur interview ka kya hua 😮

  • @nexusbeing6403
    @nexusbeing6403 3 года назад

    Hey, at 3:45 the garbage value at first gives 0 for the length if it exceeds by 1 but if I use more memory for rest of the unspecified bits it gives/allocates some garbage value to the array.

  • @chinua2518
    @chinua2518 3 года назад +3

    Great lectures Sir, this is so detailed.
    Is it possible to declare a 1D array like so;
    int arr[] = {0};

    • @anubhavsur1441
      @anubhavsur1441 2 года назад

      yes of course it is a valid element. 0 is of data type int so it is a valid array arr[]

  • @naveedishtiaq938
    @naveedishtiaq938 3 года назад +1

    Write a program that initialize array of size 10, and prints all Armstrong and Palindrome numbers in array. Your program should ask user about their choice of printing. If user press ‘A’ or ‘a’ then program should display all Armstrong numbers in array and if user press ‘P’ or ‘p’ then it should display all Palindrome numbers in array.

  • @bharathi1337
    @bharathi1337 4 года назад +1

    Perfect explaination 👌👌

  • @23_rehanahassan7
    @23_rehanahassan7 3 года назад

    Very well explained.. Thank u

  • @Aabara_ka_dabara
    @Aabara_ka_dabara Год назад

    Awesome content an d good explanation too..

  • @foramtrivedi7648
    @foramtrivedi7648 3 года назад

    thank-you so much sir you help a lot of people by this video

  • @daiaikyrmenmajaw3531
    @daiaikyrmenmajaw3531 2 года назад

    Sir you are the best with your wonderful explaination and clear👍👍🤗

  • @luckyrawat5656
    @luckyrawat5656 3 года назад +1

    Doing great job brother 👍

  • @prettyangel2530
    @prettyangel2530 3 года назад +1

    Thank you so so much sir😊👍

  • @smp2221
    @smp2221 3 года назад

    Sahi insaan ko pakda maine ab c sikhne ke liye 🤗thank u soo much 💖

  • @pazzy4501
    @pazzy4501 Год назад +1

    You are excellent man, keep up the good work 👍👍

  • @aryatamang5766
    @aryatamang5766 5 лет назад +2

    will you please provide the tutorials of Design analysis and algorithm?

  • @kamransaif2929
    @kamransaif2929 3 года назад

    Very Helpfull Lecture

  • @NarendraKumar-yr5ox
    @NarendraKumar-yr5ox 5 лет назад +1

    Thanks for the uploaded this video🙏

  • @Nicole-jw9jn
    @Nicole-jw9jn 4 года назад +1

    thank you so much i enjoy programming bc of you!!!

  • @shannukichatpatikhabrein7867
    @shannukichatpatikhabrein7867 5 лет назад +1

    Nice video sir.. If possible plz upload video fast

  • @kunalsoni7681
    @kunalsoni7681 5 лет назад +5

    sir that's truth.. sir you are genius on c programming.. sir your explanation is awesome for students.. 😊

    • @akwpython
      @akwpython Год назад

      please checkout my channel i teach C in hindi with codes i make and i will make them in front of you not any presentation.

  • @tails_the_god
    @tails_the_god 3 года назад

    thank you so much sir greetings from usa this is the exact quick answer i was looking for! :D

  • @shaikmohammed2444
    @shaikmohammed2444 5 лет назад +1

    Really it helps me a lot

  • @HelloWorld40408
    @HelloWorld40408 Год назад

    Thank You Sir

  • @damayanthibandara4695
    @damayanthibandara4695 Год назад

    Great sir❤

  • @stanleymartin1772
    @stanleymartin1772 Год назад

    in the topic Initializing Array @5:17 to 5:25. you mentioned that you cant add more elements to an array than the specified size of the array. This happens to not be the case as C actually allows you to add more elements than the size array which of course could lead to a lot of problems but I think its worth noting as it appears to be a weakness with the c programming language

  • @parbatbudha1150
    @parbatbudha1150 5 лет назад +1

    Very nice sir

  • @techys4335
    @techys4335 3 года назад

    verry verry nice video sir thanks.

  • @onnojogot9014
    @onnojogot9014 3 года назад

    Thanks a lot sir

  • @hitishapatel2407
    @hitishapatel2407 2 года назад

    Thank you

  • @Dayhmian
    @Dayhmian 5 лет назад +1

    Nice, keep up the good work.

  • @crafterpriyasharma3444
    @crafterpriyasharma3444 Год назад

    Sir, first of all, thank you that you make such good videos for us free of cost, but sir, I have a request that along with understanding, please provide us notes to write in the exam, because i dont know how to write in the exam.

  • @samirgiripunje9202
    @samirgiripunje9202 3 года назад +1

    Sir at 3:40 my sir told that it store garbage value instead of 0's to save time and working 🙄
    Other please correct me🙏all who ever know this

  • @sanusihassan7125
    @sanusihassan7125 2 года назад

    if you write
    int arr[SIZE] = {0};
    Only the first element will get the value zero and the rest are filled automatically by the compiler, try changing 0 to 1 and see the difference

  • @mugurukadanson8282
    @mugurukadanson8282 8 дней назад +1

    why increment in method 4 in initialising a 1d array

  • @Salamanca-joro
    @Salamanca-joro 5 месяцев назад

    4:51 its not illegal it works actually it will be filled by value of zero

  • @praveenkumarraghubharathi7045
    @praveenkumarraghubharathi7045 5 лет назад

    waiting for u r next videooo....if u fastly upload u r videos it will helpfull for those people who are now learn c...

  • @abhikumar4332
    @abhikumar4332 4 года назад

    Very useful for me.

  • @dawsonshi3767
    @dawsonshi3767 2 года назад +1

    int arr[10] = {}; is legal when compile by GCC

  • @deepan9155
    @deepan9155 Год назад

    Sir ur much better than my hod

  • @true4189
    @true4189 4 года назад

    Thank u

  • @amansoni6152
    @amansoni6152 3 года назад

    Please Make Such Courses for C++ !!

    • @akwpython
      @akwpython Год назад

      please checkout my channel i teach C in hindi with codes i make and i will make them in front of you not any presentation.

  • @brokendreamz1140
    @brokendreamz1140 4 года назад

    simple explanation👍

  • @kevalpatel1470
    @kevalpatel1470 5 лет назад

    Thanks sir

  • @umakothalikar8907
    @umakothalikar8907 2 года назад

    You r just awsome!!🤯

  • @meenakshis7798
    @meenakshis7798 3 года назад

    Can you make lectures on python and it’s data structures too

  • @newariya8965
    @newariya8965 5 лет назад

    Very good dada,,,,,

  • @sanjayprabhushetty4309
    @sanjayprabhushetty4309 4 года назад +4

    int a[5]={}; still initializes all array elements to zero why is this illegal?\

  • @kukuabass798
    @kukuabass798 Год назад

    You are good, sir, I am just smiling😁

  • @sabahoudini
    @sabahoudini 4 года назад

    If I declare an array of type float and initialise the first value as 0.0f. Will the rest of the values also be initialised as 0.0f? Example: float array[5] = {0.0f}; The reason I ask is because I'm working with a microcontroller and calculations on a float value will be done with double precision and not single precision unless I specify 0.0f and I don't need the extra accuracy but need to save computation time.

  • @annakudriavtseva6660
    @annakudriavtseva6660 5 лет назад +2

    in method 1 and 2 how can you initialize array not at declaration?

  • @maheliahmed3013
    @maheliahmed3013 3 года назад

    Can you explain about global array? please

  • @pulipatialekhya7512
    @pulipatialekhya7512 Год назад

    Sir , by keeping array size empty we can store any number of values

  • @harsh_t
    @harsh_t Год назад

    The illegal cases that u explained are not illegal at all. They are working just fine

  • @thamiesongxaka605
    @thamiesongxaka605 4 года назад +1

    hi! just came across this video while roaming around, am very interested in learning programming, and was looking for definition of an array, any advise where can I start ?

    • @flamousz
      @flamousz 2 года назад

      maybe you can start with learning c language

  • @priyankabehera8288
    @priyankabehera8288 3 года назад +1

    ❤❤❤ from odisha

  • @sainadhreddysyamala9933
    @sainadhreddysyamala9933 2 года назад +1

    can u give a example for this int arr[10]={0}; code

  • @officegaming-23
    @officegaming-23 4 года назад

    Please explain the 4method of array please🙏🙏🙏🙏🙏

  • @novelmania2319
    @novelmania2319 4 года назад

    Oh Man you are Great

  • @simasaha81
    @simasaha81 3 года назад +34

    Will cops invade my house if I add more elements than mentioned?

    • @hanmayujiro9491
      @hanmayujiro9491 9 месяцев назад +8

      Yes you are sentenced to watch 10 hour skibbidi toilet

    • @jonathan-gx9oc
      @jonathan-gx9oc 6 месяцев назад

      Due to your good behaviour you are now released

  • @darkcrow9319
    @darkcrow9319 2 года назад

    How can i get numbers in a array string if the numbers are between spaces?
    Example:
    Array string = { "12 3 20"}

  • @parbatbudha1150
    @parbatbudha1150 5 лет назад

    How to use pointer aary in function ?please make video on it sir.

  • @omprakashnarsale1334
    @omprakashnarsale1334 3 года назад

    sir in 1st and 2nd method you didnt declare type of an array it is correct or not?

  • @venkatchenam6981
    @venkatchenam6981 5 лет назад

    nice sir

  • @sakshirathoree2908
    @sakshirathoree2908 4 года назад

    sir but when input is greater than the length of the array,it's workinf fine It's not showing any error

  • @akshayrode3546
    @akshayrode3546 5 лет назад

    In method 2, there should be data type involved...

  • @muskaan1537
    @muskaan1537 4 года назад

    Good

  • @teenarana3744
    @teenarana3744 4 года назад

    Nice

  • @opst1704
    @opst1704 5 лет назад +1

    flower brackets :'D 5:50

  • @piykum7
    @piykum7 Год назад

    arr[10]; will also make all elements zero;

  • @kiminotoriko6178
    @kiminotoriko6178 3 года назад

    How to initialize array of string?
    string arr[] = {a, b, c, d};
    I do this but it's error

  • @anushkathakur6531
    @anushkathakur6531 2 года назад

    How can we write if we want to initialise all elements of the array with a number other than zero

  • @sheikhmohdarmaan1484
    @sheikhmohdarmaan1484 3 года назад

    what happens when we directly print an array.. please reply

  • @madhiranagender6758
    @madhiranagender6758 3 года назад

    Why was rest of the elements are zero.is there any chance the rest of the elements becomes garbage values?

  • @carloschen9791
    @carloschen9791 5 лет назад

    The automatic inicilization with value = 0, does it work only with global variables o with locals also?

  • @ZafarIqbal-xs1pn
    @ZafarIqbal-xs1pn 4 года назад

    Sir what means by creating of array

  • @ganamcyanskamcna4317
    @ganamcyanskamcna4317 4 года назад

    int arr[10]={0};
    int arr[10]={1};
    if all ten elements are 1,can i express the way above?

    • @anjaliverma7949
      @anjaliverma7949 4 года назад

      No 1 value will allocated to first block other will get 0 values

    • @_tan2112
      @_tan2112 2 года назад

      @@anjaliverma7949 any way to initiate the array with -2 of size 1lack

  • @sonusambharwal8828
    @sonusambharwal8828 5 лет назад

    Gjb sir

  • @rohitkhetan278
    @rohitkhetan278 3 года назад +1

    1) int arr[5];
    arr[5]={1,2,3,4,5};
    Why is this code showing error?
    2) int ar[5]={};
    Sir, even this code works fine in VS code.....in fact, this is the easiest way to initialize an array with all zero.

    • @meowrbius
      @meowrbius 3 года назад

      We cannot initialize and declare arrays separately like that. U can do only if u are assigning one element at a time.
      Ex :
      int arr[5];
      arr[0] = 1;
      arr[1] = 2;
      arr[2] = 3;
      arr[3] = 4;
      arr[4] = 5;

    • @darshanjaviya4770
      @darshanjaviya4770 3 года назад

      @@meowrbius arr[5] means you are accessing the 5th index of arr array(actually not initialising the array), If you have already declared array then you have to use method-3,4 not 1, to declare, define and intialize you can do int arr[5] = {1 ,2, 3, 4, 5}

    • @meowrbius
      @meowrbius 3 года назад

      @@darshanjaviya4770 yea.
      And in the video, he is saying no need to write data type in method 1. That's wrong actually

    • @darshanjaviya4770
      @darshanjaviya4770 3 года назад

      @@meowrbius yes I also noted that

  • @SanePius
    @SanePius 9 месяцев назад

    What's index means

  • @akshpreetsingh36
    @akshpreetsingh36 4 года назад

    what if we add more values than the size of the array

  • @sainadhreddysyamala9933
    @sainadhreddysyamala9933 2 года назад +1

    please make it fast

  • @gaurabchan2171
    @gaurabchan2171 4 года назад

    I am beginner. Sadly unable to find series of lectue

  • @meowrbius
    @meowrbius 3 года назад +2

    1:33 In method 1 and 2, data type for array is not written. But is it possible to declare and initialize arrays separately like that ?

  • @souravray8891
    @souravray8891 5 лет назад

    I like this channel.. 👍👍👍

  • @YassinOmer360
    @YassinOmer360 2 года назад

    How about that, is that legal?
    👇
    int arr[ ] = {0}

  • @lukusasmartmtambo2743
    @lukusasmartmtambo2743 5 лет назад

    sir can you kindly add links to the source code