FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
367 views
in Tutorial & Interview questions by Goeduhub's Expert (9.3k points)

 Define array and access array element

1 Answer

0 like 0 dislike
by Goeduhub's Expert (9.3k points)
 
Best answer
#include <stdio.h>

#define ARRLEN (10)

int main (void)

{

int n[ ARRLEN ]; /* n is an array of 10 integers */   

size_t i, j; /* Use size_t to address memory, that is to index arrays, as its guaranteed to                   be wide enough to address all of the possible available memory. Using signed integers to do so should be considered a special use case, and should be restricted to the uncommon case of being in the need of  negative indexes. */

   /* Initialize elements of array n. */           

for ( i = 0; i < ARRLEN ; i++ )   

{      

n[ i ] = i + 100; /* Set element at location i to i + 100. */   

}      /* Output each array element's value. */   

for (j = 0; j < ARRLEN ; j++ )   

{      

printf("Element[%zu] = %d\n", j, n[j] );   

}

   return 0;

}

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...