All articles
c

A program to print table of strings

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 073

  • Write a program to print table of strings

Program

#include <stdio.h>
 
void main()
{
    char names[5][5];
    int i;
 
    for (i = 0; i < 5; i++)
    {
        scanf("%s", names[i]);
    }
    printf("\nNames are:\n");
 
    for (i = 0; i < 5; i++)
    {
        printf("%s\n", names[i]);
    }
 
    printf("\n");
}

Result

Alice
Bob
Carol
Daniel
Esther

Names are:
AliceBob
Bob
CarolDanieEsther
DanieEsther
Esther

Comments