C Programming – HackerRank Solution | FIRST NAME AND LAST NAME |

(HackerRank) Write a Modular C Programming code to solve FIRST NAME AND LAST NAME, Write a UDF to read the first name and last name.

A new user on gmail enters a first name in one text area and last name in another text area during sign up process. After login user observes that first name and last name appears in a same text area on screen.

MODULAR TASK:

  1. Write a UDF to read the first name and last name.
  2. Write a UDF to combine the first name and last name in first text area. NOTE: first name and last name should be stored in first text area.

Input Format

First name of user Last name of user

Constraints

Names should be characters.

Output Format

A welcome message along with first name and last name.

Sample Input 0

Ramesh
Mishra

Sample Output 0

Welcome Ramesh Mishra

Refer : C Programming HackerRank all solutions for Loops | Arrays | strings | Data Structures | Linked lists | Stacks | Queues | Binary Trees

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main() {
    char first[50];
    char last[25];
    int i=0,j=0;
    scanf("%s ",first);
    scanf("%s ",last);
    while(first[i]!='\0')
        i++;
    first[i]=' ';
    i++;
    while(last[j]!='\0')
     {
        first[i]=last[j];
        i++;
        j++;
     }
    printf("Welcome %s",first);
    return 0;
}

OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

Ramesh
Mishra
Your Output (stdout)

Welcome Ramesh Mishra
Expected Output

Welcome Ramesh Mishra

 

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, Stacks, Queues, Binary Trees, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!