Write a program that asks for the user's last name and first name and then displays the total length of the name without counting spaces. Use the strlen function.
Example:
Enter your first and last name : Mickey Mouse
Hello Mickey Mouse!
Your name is made up of 11 letters.
Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
#define SIZE 200
void main() {
char firstname[SIZE], lastname[SIZE];
printf("Enter your first and last name : ");
scanf("%s %s", firstname, lastname);
printf("Hello %s %s\n", firstname, lastname);
printf("Your name is made up of %d letters.\n"
, strlen(firstname) + strlen(lastname));
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Iterative DFS traversal of a graph using an adjacency list