emergency please fast........
do this program in easier way.....
question no. 30
Answers
Function strlwr in C
#include <stdio.h>
#include <string.h>
int main()
{
char string[1000];
printf("Input a string to convert to lower case\n");
gets(string);
printf("The string in lower case: %s\n",strlwr(string));
return 0;
}
Function strupr in C
#include <stdio.h>
#include <string.h>
int main()
{
char string[1000];
printf("Input a string to convert to upper case\n");
gets(string);
printf("The string in upper case: %s\n",strupr(string));
return 0;
}
Change string to upper case without strupr
#include <stdio.h>
void upper_string(char []);
int main()
{
char string[100];
printf("Enter a string to convert it into upper case\n");
gets(string);
upper_string(string);
printf("The string in upper case: %s\n",string);
return 0;
}
void upper_string(char s[]) {
int c = 0;
while (s[c] != '\0') {
if (s[c] >= 'a' && s[c] <= 'z') {
s[c] = s[c] - 32;
}
c++;
}
}
Explanation:
Strlwr function converts a string to lower case, and strupr function converts a string to upper case. Here we will change string case with and without strlwr, strupr functions. These functions convert case of alphabets and ignore other characters which may be present in a string.
Function strlwr in C
#include <stdio.h>
#include <string.h>
int main()
{
char string[1000];
printf("Input a string to convert to lower case\n");
gets(string);
printf("The string in lower case: %s\n",strlwr(string));
return 0;
}
Function strupr in C
#include <stdio.h>
#include <string.h>
int main()
{
char string[1000];
printf("Input a string to convert to upper case\n");
gets(string);
printf("The string in upper case: %s\n",strupr(string));
return 0;
}
Change string to upper case without strupr
#include <stdio.h>
void upper_string(char []);
int main()
{
char string[100];
printf("Enter a string to convert it into upper case\n");
gets(string);
upper_string(string);
printf("The string in upper case: %s\n",string);
return 0;
}
void upper_string(char s[]) {
int c = 0;
while (s[c] != '\0') {
if (s[c] >= 'a' && s[c] <= 'z') {
s[c] = s[c] - 32;
}
c++;
}
}