Assignment
Element Assignment
#include<stdio.h>
#define TOTAL_SIZE 5
int main(){
int a[TOTAL_SIZE], current_size = 0, i = 0;
// Assignment of Array Elements
a[0] = 10;
current_size++;
// current_size of the Array will increase by 1 after each element insertion
a[1] = 20;
current_size++;
a[2] = 30;
current_size++;
a[3] = 40;
current_size++;
a[4] = 50;
current_size++;
// Atmost 5 (TOTAL_SIZE) Element can be Inserted in the above Array
/*
a[5] = 50; // Invalid Assignment
current_size++; // Current is more than the TOTAL_SIZE of the Array
*/
for(i=0; i<current_size; i++){
printf("%d ", a[i]);
}
printf("\n");
return 0;
}Alternative Approach
Alternative Approach Using Loop
Element Update
Last updated