Creates an array with 26 elements and stores the 26 lowercase letters in it. Also have it show the array contents. - C Array

C examples for Array:Array Value

Description

Creates an array with 26 elements and stores the 26 lowercase letters in it. Also have it show the array contents.

Demo Code

#include <stdio.h>
#define ALPHABET_LENGTH 26/*from  ww  w .j ava 2  s. c  o m*/

int main(void){
  char alphabet_lowercase[ALPHABET_LENGTH];
  char letter;
  int i;

  for (letter = 'a'; letter - 'a' < ALPHABET_LENGTH; letter++){
    alphabet_lowercase[letter - 'a'] = letter; // store letter in array
  }

  printf("The lowercase letters of the alphabet are:\n");

  for (i = 0; i < ALPHABET_LENGTH; i++){
    printf("%c ", alphabet_lowercase[i]);
  }
  printf("\n");

  return 0;
}

Result


Related Tutorials