Write a program VERIFY() in C++ which accepts a character as an argument
and cheeks whether it is a digit or not.
Answers
Answered by
3
Answer:
Output:
Alphabetic_letters = 3, Decimal_digits = 4
Explanation:
// C program to demonstrate working of isalpha() and
// isdigit().
#include<stdio.h>
#include<stdlib.h>
int main()
{
char str[] = "12abc12";
int alphabet = 0, number = 0, i;
for (i=0; str[i]!= '\0'; i++)
{
// check for alphabets
if (isalpha(str[i]) != 0)
alphabet++;
// check for decimal digits
else if (isdigit(str[i]) != 0)
number++;
}
printf("Alphabetic_letters = %d, "
"Decimal_digits = %d\n", alphabet, number);
return 0;
}
Similar questions