The kids need to clear a simple test to secure admission in the nursery class. They need to spell their name and they also need to tell the number of letters in their name. Some of the kids had very long names and the interview panel members found it time-consuming to count the number of letters in the name. One of the panel members has just started to learn programming and she decided to write a C++ program to count the number of charaters in the name. She knew that it was an easy task as the good old strlen function is availabe in C++. Can you help her out in this task? Write a C++ program to find the number of characters in the string. Input Format: Input consists of a single string. Assume that the maximum length of the string is 50 and it contains only alphabets. Output Format: Refer sample input and output for formatting specifications.
Answers
Answered by
6
Answer:
#include<iostream>
#include<string.h>
using namespace std;
int main ()
{
char str[50];
int len;
gets(str);
len = strlen(str);
cout << "The number of letters in the name is " << len;
return 0;
}
Explanation:
Answered by
0
Answer:
C++ PROGRAM-
It is a programming language with this general purpose coding language which has been used for -
- game programming,
- software engineering,
- data structures,
- developing browsers,
- operating systems,
- applications, and more for over forty years.
The C++ program is as under-
Explanation:
A C++ program to count the number of charaters in the name.
The C++ program is as under-
Enter the name
Riya
The number of letters in the name is 4
Program Code:
#include<stdio.h>
int main()
{
char str[100];
int i=0; int l=0;
printf("Enter the name");
scanf("%s",str);
while(str[i]!='\0')
{
l++;
i++;
}
printf("\nThe number of letters in the name is %d",l);
return 0;
}
Similar questions
Computer Science,
5 months ago
History,
5 months ago
Math,
11 months ago
History,
11 months ago
English,
1 year ago