Professional Documents
Culture Documents
{
char name[30];
int i,j,l;
char n;
printf("enter your name:\n ");
gets(name);
l=strlen(name);
for(i=0;i<l-1;i++)
{for(j=i+1;j<1;j++)
{if(name[i]>name[j])
{n=name[i];
name[i]=name[j];
name[j]=n;
}
}
}
printf("\n Name in alphabetical order:\n %s", name);
return 0;
}
//a program that allow user to enter text(include space, characters,...). The program will
be terminated if user press ENTER key. Display number of words that entered form user.
{char a[1000];
int i, count=0;
printf("enter text:\n");
gets(a);
for(i=0;a[i]!='\0';i++)
{if(a[i]=' ' ||a[i]='\n'||a[i]='\t')
count++;
}
printf("\nNumber of words: %d", count+1);
return 0;}
//a program to change all the characters prompted from users to UPPER CASE
{ char a[100];
printf("enter text:\n");
gets(a);
strupr(a);
printf("\nThe text to upper case:%s",a);
return 0;}
//a program to allow user to prompt their name; then display the name in Pascal case.
{
char name[100];
printf("enter your name: ");
fgets(name, sizeof(name),stdin);
printf("\nPascalcase Name: ");
int i=0;
while(name[i]!='0'){
//check for the first character of each word
if(i==0||name[i-1]==' '){
printf("%c", toupper(name[i]));
}
else {printf("%c", tolower(name[i]));
}
i++;
}
return 0;}
//homework
char inputString[80];
char searchText[80];
char searchChar;
int Count = 0;
return 0;
}