Write a program for string array.
C Program
#include <stdio.h>#include <string.h>int main(){char str[100][100];int n;printf("Enter number of strings: ");scanf("%d", &n);printf("Enter %d string\n", n);for (int i = 0; i < n; i++){scanf("%s", &str[i]);}printf("String array is\n");for (int i = 0; i < n; i++){printf("%s\n", str[i]);}return 0;}
Input:
Enter number of strings: 4
Enter 4 string
hello
world
code
fun
Output:
String array is
hello
world
code
fun
No comments:
Post a Comment