part A:
write your own version of the function isalpha which is described in 8.1 in your book. the function prototype is int isAlpha(int c);
part b:
write a recursive function named firstAlpha that takes a single string as its argument and returns a pointer to the first alphabet (letter) in the string. the function prototype is: char * firstAplha (char*);
use the function written in part A to check for the letters. in addition, use recursion and pointer notation to solve this problem.
هذي محاولتي
# include<stdio.h>
# include<ctype.h>
# include<string.h>
int is_alpha (int);
char *firstalpha(char*);
int main()
{
char x[]="123kdd";
is_alpha(x);
firstalpha(x);
printf("%c ",x);
return 0; }
int is_alpha (int c)
{
if (char (c>='a' && c>='z') || (c>='A' && c>='Z'))
return 1;
else
return 0;}
char *firstalpha(char *a)
{
if (*a=='\0')
return '\0';
else
if (isalpha(*a))
return a;
else
return firstalpha(a+1);
}*Write a function named sort_Names_In_Line that should take a line consist of words (names) separated by one blank.The function should return a new line of text contains the words in the line sorted in ascending order. The maximum number of charactersin the line is 80. Use array of pointer to char to point to the words in the line for the sorting operation. The prototype of the function is:char *sort_Names_In_Line(char*); If the line is "Moha Nader Ahmed Faten Eman"
The returned line should be "Ahmed Eman Faten Moha Nader"
*write a main function to test youre function
وهذه محاولتي
# include <stdio.h>
# include <string.h>
char *sort_Names_In_Line(char*line);
void main ()
{
char line[100];
printf ("Enter a line consists of words (names) separated by one blank:");
gets (line);
if (strlen (line)<=80)
printf ("%s",sort_Names_In_Line(line));
}
char *sort_Names_In_Line(char*line)
{
int count=0;
char nsent [100]={" "};
char *token=strtok (line," ");
char *psn[10];
psn[0]=token;
while (token!=NULL) {
count++;
token=strtok (NULL," ");
psn[count]=token; }
char *temp;
for (int i=0;i<count;i++) {
for (int j=0;j<count;j++)
if (strcmp (psn,psn[j])>0 && i!=j)
{
temp=psn;
psn=psn[j];
psn[j]=temp;
}
}
for (i = 0; i < count; i ++)
{
strcat (nsent, psn );
strcat (nsent, " ");
}
return nsent;
}