2d array

📊 Arrays C Hard
✅ Solved
Asked by Jariwala Jil Feb 03, 2026 at 11:23 Subject: Programming Skills

Question:

Write a program to take input of 5 names and surnames in different two dimensional arrays. Then concatenate (join) names with their surname in a third 2D array.

💬 0 Comments 💡 1 Solution(s)

💡 Solutions (1)

Super Admin

Admin

Feb 03, 2026 at 11:27

👍 0

upvotes

#include <stdio.h> #include <string.h> int main() { char name[5][20]; char surname[5][20]; char fullname[5][40]; int i; // Input names printf("Enter 5 Names:\n"); for(i = 0; i < 5; i++) { scanf("%s", name[i]); } // Input surnames printf("\nEnter 5 Surnames:\n"); for(i = 0; i < 5; i++) { scanf("%s", surname[i]); } // Concatenate name and surname for(i = 0; i < 5; i++) { strcpy(fullname[i], name[i]); // copy name strcat(fullname[i], " "); // add space strcat(fullname[i], surname[i]); // add surname } // Display full names printf("\n----- Full Names -----\n"); for(i = 0; i < 5; i++) { printf("%s\n", fullname[i]); } return 0; }

👍 Login to Vote

Want to add your solution? Login to contribute!

💬 Comments (0)

Login to post comments

No comments yet

Be the first to comment!