W e b t u t o r i a l s

Programing Approach

Algorithm, Flow Chart

Define C

Define Programming

C - Syntax

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

Control Structure

Control Structure - if

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Constant Variable

C - Escape Sequence

C - Arrays 1D, 2D

C - Sorting

ASCII Value

Character I/O Function

C - Strings

Ex: Strings

Array of Strings

C - Math Functions

C - Functions

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

Typedef File Handling

Command Line Argument

MCQ

Array of Strings in c

A string is a 1-D array of characters, so an array of strings is a 2-D array of characters.

Just like we can create a 2-D array of int, float etc; we can also create a 2-D array of character or array of strings.

Syntax for declaring a 2-D array of characters:

char prg[3][12] = {
   {'c', 'o', 'd', 'i', 'n', 'g', '\0'},
   {'l', 'e', 'a', 'r', 'n', 'i', 'n', 'g', '\0'},
   {'p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g', '\0'}
};

This above initialization is equivalent to:

char prg[3][12] = {
   "coding",
   "learning",
   "programming"
};

Exercise questions on Array of Strings

  1. Input 10 names and print them.
  2. Input 10 names and find largest word (take ASCII value for comparing).
  3. Input 10 names and find smallest word (take ASCII value for comparing).
  4. Input 10 names and sort them in ascending order.
  5. Input 10 names and sort them in descending order.