Program 33 - CSU1128 - CSE 2026 - Shoolini University

Program to take the full name entered by the user and store it in an array. Example: dmj.one

Explanation

The program takes the full name entered by the user and stores it in a character array. It then prints a greeting message with the entered name.

Header

The code begins with including the standard input-output header file using #include <stdio.h>.

Variable Declaration

The main() function is defined, and a character array d of size 100 is declared to store the full name entered by the user:

  • char d[100];: Declares a character array to hold the user's full name.

Program Description

The program prints a description message for the user to understand its functionality.

User Input

The user is prompted to enter their full name. The input is read using fgets(d, sizeof(d), stdin); to include spaces:

  • fgets(d, sizeof(d), stdin);: Reads the full name including spaces and stores it in the character array d.

Output Result

The program prints a greeting message with the entered name:

  • printf("Nice to meet you %s", d);: Prints the greeting message followed by the full name stored in d.

Program End

The program ends with return 0; to indicate successful execution.

Code

                    
/*
 * -----------------------------------------------------------
 * Logic Building with Computer Programming (CSU1128)
 * Instructor: Dr. Pankaj Vaidya | Author: Divya Mohan
 * 
 * This code is a part of the educational initiative by dmj.one
 * with aim of empowering and inspiring learners in the field of
 * Computer Science and Engineering through the respective courses.
 * 
 * (c) 2022, Divya Mohan for dmj.one. All rights reserved.
 * -----------------------------------------------------------
 */

#include <stdio.h>
int main()
{
    char d[100];

    printf("\n\n Program to take the full name entered by the user and store it in an array. Example: dmj.one \n\n");

    printf("Enter your full name: ");
    fgets(d, sizeof(d), stdin); // Read the full name, including spaces

    printf("Nice to meet you %s", d); // The name already includes a newline character

    return 0;
}
                    
                

Output

Program to take the full name entered by the user and store it in an array. Example: dmj.one

Enter your full name: Divya Mohan
Nice to meet you Divya Mohan