I need to do the following:
input First and Last name
Output initials.
Output however many letters
Input Middle name
Output Full initials.

then redo the process.
input First and Last name
Output initials.
Output however many letters
Input Middle name.
Output Full initials.

Example:
Enter your first and last name with a space between: Melvin Mathew
Your initials are MM.
Your name has 12 letters.
What's your middle name: TOM
Your full Initials are MTM.

Enter your first and last name with a space between: Melvin Mathew
Your initials are MM.
Your name has 12 letters.
What's your middle name: - (no middle name)
Your full Initials are MM.

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


int main()
{
    int i;
    int countUC = 0;
    int countNmb = 0;
    char a[100];        /* declare array for storing string of characters */

    printf("Please enter a word or press q to quit. \n");
    scanf("%s", a);

    if((strlen(a)==1) && (a[0]=='q'))
        return 0;

    printf("Your word is: %s \n",a);
    printf("Number of characters: %d\n",strlen(a));     /* strlen(char_name) is a function from string.h */


    return 0;
}

What's the question(s)? The code you posted doesn't even start to do the assignment.

Hint: use fgets() instad of scanf() when you want to enter a string that contains spaces. For example:

char name[255];
printf("Enter your first name, middle name, and last name\n");
fgets(name, sizeof(name), stdin);

Another way to do it would be to use three different variables

char lname[80], fname[80], mname[80];
printf("Enter first middle and last names\n");
scanf("%s%s%s", fname,mname,lname);

Edited 4 Years Ago by Ancient Dragon

okay so thats how to input it, so where would I find the syntax to display the first letter of every char and also calculate how many letters are in each name

so where would I find the syntax to display

Think about it, look up printf() function in your textbook or online using google. Hint: strlen() returns the length of a string.

This article has been dead for over six months. Start a new discussion instead.