0 like 0 dislike
19.2k views

Write a program that reads strings of up to 1000 characters continuously and displays them, after replacing the lower letters with upper letters and vice versa.

寫一個程式 輸入一個字串(最多1000)  把小寫轉大寫大寫轉小寫

Example input:

With the rise in GLOBAL warming and increasing POLLUTION levels, it is becoming essential to find a viable alternative to the internal combustion engine petrol powered CAR.

Example output:

wITH THE RISE IN global WARMING AND INCREASING pollution LEVELS, IT IS BECOMING ESSENTIAL TO FIND A VIABLE ALTERNATIVE TO THE INTERNAL COMBUSTION ENGINE PETROL POWERED car.
[Exercise] Coding (C) - asked in Chapter 13: Strings
ID: 41431 - Available when: Unlimited - Due to: Unlimited

edited by | 19.2k views

57 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    char a[100];
    int i;
** ** * * * * ** *
* * * * * ** * *** * * ** * * * *
*** ** **** * ** ** * ** ** * * **** * * * * * * *** ** *** *** * * * * * ** *
* * * **** * ** *** * * ** ** *** **** ** * * ** ** *** **** * *
*** * * ** *** **** ** * ** *** * * **** * **** ** * *** **
*** * * * * *** *** * * *** * * *** * *** **** * * ******* * * *
* * * * * * * * **
* * * * ** * * * 0;
}
answered by (-284 points)
0 0
prog.c: In function 'main':
prog.c:6:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(a);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccsN5nEo.o: In function `main':
prog.c:(.text+0x1f): warning: the `gets' function is dangerous and should not be used.
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{

***** *** * *** * * **** i;
* ** * * * ** *** ***** str1[1000],str2[1000]={0};
** * ** * * ** *** ***** ** * a sentence to convert upper to lower and vice versa\n");
* * ****** * * * **** *

* * ** ** ** * * ******* ** * ** *
* ** * ** ** * *** *
** ****** ** * * ** *** * ** * * * * * * **** * ** &&str1[i]<='z')
* * * *** * * *** * **** ** *
* * * * * ****** * ** ****** *** ** ** *** *** ** * **** * ** * * ** *
* *** * * ** **** * ****** * * ** *
** * *** ** * **** * * * ***** * ****** * * **** ** * * *** *
**** * * * * ** ** ** *** ******* * * * ** ** ** **** *** * * * ** ***** **** ***** *
* ** ** ***** ** *
** * * *** ** * *
** * * * * ** ** ** ** ** **** *** * * ** * * *** *
* **** ** * * ** * * ** *
}
printf("%s\n",str2);
return 0;
}
answered by (-167 points)
0 0
prog.c: In function 'main':
prog.c:9:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(str1);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cc2ji0XA.o: In function `main':
prog.c:(.text+0x3d): warning: the `gets' function is dangerous and should not be used.
0 like 0 dislike
Hidden content!
#include * *** ** ***
#include * * ***** * *
#include * ** * * * *

int main()
{
* **** * * ** * * *** array[1000] = {0};

*** *** * * * *** i = 0;

*** * * ** *** ****** * * *** 1000, stdin);

* * * ** * ** ** * * len = strlen(array);

*** **** * **** * ** = 0; i < len; i++)
*** ***** * * ** *
***** ** *** ** **** * * * * *** * ** >= 'A') && (array[i] <= 'Z'))
* ** * ** *** * * ** * ** * * * **** * *** ***** *
* * **** *** *** ** ** ** ** * * * * *** * **** * * * ** * * ** * * * * * += 32;
** *** ** * * * ** * * *** **** *** * *** * ** * **
** * *** * * **** *** ** * ** * **** if((array[i] >= 'a') && (array[i] <= 'z'))
******* ** *** * ** *** * ** **** *** *******
* * * ** ** * * *** * * * * * * * **** **** * * * * ** * * -= 32;
*** * ** * *** ** ** ** * ***** * * *

*** *** * ** * **** **** * ** * * ***** * * ** ** array[i]);
** * ** ** *** * * *
********* * *** * ******** * 0;
}
answered by (-285 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include * * * * **
#include * ** *** *
#include * ** ** **

int main()
{
* * * ******* **** * * * * a[1000];
** * **** *** * * ** ** i;
* **** *** * *** * * * **

* ** * ** * * *** *** *** len = strlen(a);
* * * *** *** * * ** = 0 ; i < len ; i++)
* * ** * * ** ** ***
** * * ******* * * * **** * ***** * * ***** * >= 'A' && a[i] <= 'Z')
** ** * *** *** * *** * * *** ******** * * * ***** ** ** * += 32;
** ****** *** ** *** ****** *** ** ** * * *** if(a[i] >= 'a' ******* * a[i] <= 'z')
* ** * ** * ** *** * * *** * ** * ** * * ** * * *** ** **** -= 32;
***** * * * *** * ******* * * * *** * ** ** **** *** * *
** * ** ** * * ***

*** *** ****** ****** **** 0;
}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
* * ** * ** * ***
** ** **** *

int main()
{
int i,txtlen;
char sentence[1000];
** * *** * * * ***

* ** ** *

* * * * ****
{

* * ** *** ** *** * * ** (sentence[i]>=65 && sentence[i]<=90)
* * * * *** ** *** ** ** **** ** * * ***
* ** ***** *** ** *** **** ** * *** ** * ****** ***** *** *** ** *
* ** * *** * ***** ***** * **** *** * ***** ** * * * ** && sentence[i]<=122)
* * **** * * * **** ** * * ** ***
* **** *** * ***** ** ****** ** * * * *** * **** * *** * *** ***
* ** ** * ****** * * * * * ** * * * ** * *
* * * * ******** ******** **
}


}
answered by (-336 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
*** * * * * *** **
* ******* * ****

int main()
{
int i,txtlen;
char sentence[100];
*** *** **** **

* ** * *

* * * ** ** ***
{

* * ** * *** * * (sentence[i]>=65 && sentence[i]<=90)
**** * * * ** * *** * *** *** ***
** ** * **** ** ** ** * * * * * * ** *** * ** ** *** **** ****
* ** * * * ** * *** ****** * *** **** **** *** **** && sentence[i]<=122)
* ** * ** * ** * ** ** ** * * **** ****** **
** ** *** * * *** **** * ** ** * *** * * * ****** * * * * *
**** * * ** * *** * *** * * ** * * *
** *** * ********** ** * **
}


}
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include * * *

int main()
{
* * ** * ** ** *** array[100] = {0};

* * * * * ** **** * i = 0;

* * ** ** *** ** * *** = 0; i < 100; i++)
** ** * * * * * * * ** **** *
** * * ** ** ****** * **** * *** ***** ** * ***** ** * * * * *** ** **** * &array[i]);
* ** ** **** ** **

* * * * *** * ** ****** = 0; i < 100; i++)
* ** * ** *** *
* * *** ** *** ** **** * * *** *** * * * ***** * *** >= 'A') && (array[i] <= 'Z'))
** * ** ** * * * ** ** * ** ** * ** * *
**** * *** * ** * * ** *** ***** * ******** ** *** **** * *** * * * *** += 32;
* ****** ** * * * ****** *** * ** *******
** *** *** ** * ** * * * ****** ******* * if((array[i] >= 'a') && (array[i] <= 'z'))
**** * * * *** * ***** * * * * * * * *
* * * ***** ** * * * ***** * *** * ***** * ** * * * ** ** * * * -= 32;
*** * *** * * * **** *** ** * ** * * *** *** ***

*** ******* * ** *** **** * **** * *** ** ** **** * * * array[i]);
* * * ** ** ** *** ** ***
** * * * * 0;
}
answered by (-285 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include ** *** *
#include ** * ** * **
** * ** ** * * * * *
int **** * *
{
* * * *** int c,sws, sayac;
* **** * *** *** * * * * * ** *
* * * ***** ******** ** ** 1000, stdin);
* * ***** * ** ** * * *** = * ***
* * *** * *** ** * ** * (c = 0; c< * *
** ** ** ** * * * * * *** sws = ** ** * * *** *** * : * * * * ** * }}
answered by (-304 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
prog.c: In function 'main':
prog.c:9:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(string);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccfLRc9i.o: In function `main':
prog.c:(.text+0x2f): warning: the `gets' function is dangerous and should not be used.
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
prog.c:2:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
int main()
{
    int i,t;
    char a[300];
** ** **** * * * ** *** * **
** * ** * **** * * * *** *** *
******* * * ** ** * ** ** ****** *** * *
* ** * ** * * ***** *** *** * * * *** * **** ** ***** * ** * *
* ** * * * *** ** ** ** **** * * * ** * * * *** && t>64){
* * * * ** * * * ****** * *** **** * ** * * ** **** ** ** * *** * ***
* * * ** * * *** * ** ** * * * * * **** * ** * * **
****** *** * *** *** * * ** *** *** * * * * * **
* ** * * * * * ** * *** * * * * ** * **** ** if(t<123 && t>96){
* ***** ** ******* *** * *** ****** * * * ** ** ** ** * ** * * *
****** **** *** * * *** * ** * ** * * * *** * * * * * ****
* * ** * ** * * * ** * * * ** ** * *
** *** *** ** * ** ** * ** ** * ** * * **** * ** * **** *
    }
** * ** ** ** * ** **** * ***** * * * * *
* * * * * ** * * ** ** * * 0;
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
int main()
{
    int i,t;
    char a[200];
**** ** *** * *** * * * * * * *
* * * ** * * * * * **** * * * ** * *****
* ** * ** ** ** *** ** ** ***** ****** *
* * *** **** * ** ** ******** ** * * * * * ** * ****** **** * * * *
**** *** * * * ** * ** * *** ********* **** ****** *** * && t>64){
** ** * **** **** ****** **** **** * * * **** *** ********* ***** * * ** * **
* ***** **** ** *** ** *** * * * ** ** *** *** **** ** * *** * * *
**** * ** **** * ** * **** *** *** ** * * ***
*** ** * **** * * *** * * * ** ** * ** ****** * * if(t<123 && t>96){
* * ** * **** **** *** * ************* * * ** ** * * *** *** ** * *
** * *** ** * ******** ** *** * ****** ******* ** * * * * *****
**** * * ** ** * ** * * * * ***** * * ** **
** * *** * ******* ** * *** ** * ** * * * * *** * ** ******* ** * * * *
    }
* * ** ** *** * * *** ** * ** * *
** * ** * * ** ** *** * 0;
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.9
©2016-2026

Related questions

0 like 0 dislike
27 answers
[Exercise] Coding (C) - asked Jan 11, 2018 in Chapter 13: Strings by thopd (12.1k points)
ID: 41439 - Available when: Unlimited - Due to: Unlimited
| 13.1k views
0 like 0 dislike
29 answers
[Exercise] Coding (C) - asked Jan 11, 2018 in Chapter 13: Strings by thopd (12.1k points)
ID: 41436 - Available when: Unlimited - Due to: Unlimited
| 12.5k views
12,783 questions
183,442 answers
172,219 comments
4,824 users