Write a C program using 2 different ways of that given of each question . i need
ID: 3750093 • Letter: W
Question
Write a C program using 2 different ways of that given of each question . i need this program written in a diffrent way but works the same, so it wont match with the solution i provided. If possible create 2 different ways..
2. Write a C program that receive a string from the user and convert all uppercase characters to lowercase and all lowercase letters to uppercase (Hint: there is a fixed difference or offset between each lowercase and uppercase character) 3. Write a C program to receive 10 words and sort them in dictionary order. For four words example, R, C, JavaScript, Java should be sorted as C, Java, JavaScript, R. You are allowed to use string libraries such as strcpy() and strempExplanation / Answer
If you have any doubts, please give me comment...
#include<stdio.h>
int main(){
char str[100];
printf("Enter a string: ");
scanf("%[^ ]s", str);
int i=0;
while(str[i]!=''){
if(str[i]>='A' && str[i]<='Z')
str[i] += 32;
else if(str[i]>='a' && str[i]<='z')
str[i] -= 32;
i++;
}
printf("result string: %s ", str);
return 0;
}
2)
#include<stdio.h>
#include<string.h>
int main(){
int i, j;
char inputStr[50][100], temp[100];
printf("Enter 10 words: ");
for(i=0; i<10; i++)
scanf("%s", inputStr[i]);
//using bubble sort
for(i=0; i<10; i++){
for(j = 0; j<10-i; j++){
if(strcmp(inputStr[j], inputStr[j+1])>0){
strcpy(temp, inputStr[j]);
strcpy(inputStr[j], inputStr[j+1]);
strcpy(inputStr[j+1], temp);
}
}
}
printf(" Lexicographical order: ");
for(i=0; i<10; i++){
printf("%s", inputStr[i]);
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.