Wednesday, June 10, 2020

HOW TO INTIALIZE AN ARRAY WITH ZERO IN CPP

HOW TO INTIALIZE AN ARRAY WITH ZERO IN CPP

first way


int arr[5]={0};
it will intialize your array with 0;

DISCLAIMER-IT IS NOT VALID FOR OTHERS NUMBER 
                              
                                 FOR EXAMPLE IF YOU WILL TRY TO INTIALIZE ARRAY WITH 1
                                
                                LIKE THIS int arr[5]={1}; so it will not intialize whole array with 1.
                                   
                                it will intialize first element as 1 and others as 0;

                
SECOND WAY
GOOD NEWS -> THIS IS VALID FOR EVERY NUMBER✌
        

                            int arr[size];
                             for(int i=0;i<size;i++)
                                            arr[i]=number_with_which_you_want_to_intialize

                                                            ðŸ˜‰







No comments:

Post a Comment

Infosys HackWithInfy Coding Round 1 Experience 2020

                              Round 1 was scheduled on 15th march but due to technical issues it got shifted to 30 march. college classe...