0 like 0 dislike
12.8k 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 | 12.8k views

57 Answers

0 like 0 dislike
Hidden content!
#include ** * **
#include ** * * ** * *
#include * *********

int main()
{
* * ** * * char * ** **
** *** * * ** * *** 1000, stdin);
* *** ** ** ***** ** * *
** * * ** int i;
* * ** * for(i = 0; **** ****** ++i)
** * ** * * {
* *** **** * *   ***** * * * * **** ** *** * * ** * * * ** * * * * *** * ** * **
* * ***       {
** * *   *** ** *** * ** ***** ***** *** * *** **
**** * ** * * ** {
** *** * * *** ** * * *** * * ** ** * * **
* ** ** *** ** * *** **** * * * ** **** }
** * * * ** **** *** **** else
** **** * * * ***** ** ****** * * {
** * ** * **** * * ** ** * * * *   * ** *** * * * *
*** ** * * * ** * *   ** **** ****** }
*** ** ** * * **** * }
* * *** * }
* * * ***** *** * ****** *
* ** ** return 0;
}
answered by (-249 points)
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 like 0 dislike
Hidden content!
#include *** *
#include * ** * * *
#include *** * **

int main()
{
* ** **** char ** ** **
**** * 1000, stdin);
* * * * * ** **** ** ** ';
* * **** int i;
*** * * * for(i = 0; * ** * ++i)
** * ** *** * {
*** **       * ** *** ')
* * ** * ** ** * * *** {
* ** * * ** * *** * * *** * * * * **** ***** ** * * *
** * * *** * * ** * *** ***** * ** * {
* * * ** *** **** ***** * * ** * * * * **** * ** * * * **** *
* * *** ** * * *** ** ** **** }
*** ** * ***** * * ** ** * * * * else
* * ** *** *** *** * ** * *** * * {
* ** **   ** *** * * * *** ** ** ** * ** ** * **
** ** ** ** ** * ** ** *** * }
** * * * ** * *** * }
** * * * * }
* *** ***** ** ** * *** *** * ** * *
}
answered by (-249 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include * *** **
#include ******* ** * *
#include * * **** * * *

int main()
{
* * *** * *** char *** ****
* * ** * * ** ** **** * 1000, stdin);
****** * int i;
*** ** ***** for(i = 0; * * ** * ** * * * *** * *** ** * ++i)
* * * ** * ** {
*** ** *** * ** * * * ** * ')
*       {
***** * ** * * ** * ***** * * ** * * **
**** *** * *** * ** * * * * ** *** * {
*** ** * *** * * ** * * ** * * *** * ***** * ** ** ** * *
** ** * * * * * ** ** * * ***** }
* * ** **** ** * * ** * **** * * *** * else
* * * * *** * **** * * * * {
*** ** ** *** * * **** *   * *** * * * * *****
* ** *   ** * * * * }
* * * ** * * ****** * ** ** }
** * * * * ** }
*** * *** * ** *** * ** * * ** ****** * * * ***
}
answered by (-249 points)
0 0
prog.c: In function 'main':
prog.c:24:12: warning: field precision specifier '.*' expects argument of type 'int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]
  printf("%.*s", strlen(sentence)-1, sentence);
            ^
0 like 0 dislike
Hidden content!
#include *** * * *
#include * * ** * **

int main()
{
* ** * * ** *** char **** *
* * * *** * ** 1000, stdin);
** * int i;
* * ** * ** for(i = 0; * ** ** ** * *** * * ** **** ** ++i)
** *** {
* ** * ******* *** * * ** * * * ** *** ')
* * * *       {
*** * ***** **** * * ** * ** *** ** ***
** ** * ** **** * *** **** * * * * * ** ** {
* * * ** * * * * ** *** * * ** ** * * **********
* * **** ** *** * * * ***** * * }
**** **** ** *** *** ** **** * ** else
** ** ** * ** ** ** * * * * * * {
*** * ** * **** ** *   ** *** ** * * * * * *
*** * **   * ** * * ** * *** }
** * * * * *** * }
*** ** }
*** * ** * *** * * * * * * ** * * ** * **
}
answered by (-249 points)
0 0
prog.c: In function 'main':
prog.c:23:17: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
  printf("%.*s", strlen(sentence)-1, sentence);
                 ^~~~~~
prog.c:23:17: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:23:17: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:23:12: warning: field precision specifier '.*' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
  printf("%.*s", strlen(sentence)-1, sentence);
            ^
0 like 0 dislike
Hidden content!
#include * ** * ** *
#include *** ***

int main()
{
**** ** ** * char * ** **
* * **** * * *** * 1000, stdin);
** ** * ** * int i;
*** **** * *** *** for(i = 0; * ** *** *** ** * *** * ++i)
* * * * * {
* *** ** * * ** * * *** ' )
** * *     ** * * {
* * * * ** * *** ** * * * *** * ** * ** **
** ** ** ** * * * * *** ** {
* ** * * * * * * * * * * **** ** ** * ** * ** ** * ** * ** *
** * ** * * ** * * * * * ** **** ** }
** * * **** * * * * ** * * * else
* * ** ** ** ****** ** ** *** * * {
*** * * *** * ** * * ** * ** * * ******   *** * **** * *
*** **** *** *** *     }
* * * * * * ** ****** }
*** ** * ** ** * * *
** * *** ** }
** ** * * * **** **** ** * * *
}
answered by (-249 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include ** ** * * * *
#include ***** ** **

int main()
{
* * * ** ** char ** *
*** * * *** *******
* **** * int i;
* *** * * *** *** for(i = 0; ** ** * * * ++i)
*** ****** * {
**** * ** ** * * ** * ******* ')
*** *       {
*** ** * ** **** * * ** * **** * * * * ****
* * * * * ** ** * **** ** * * **** * {
*** *** * * ** ** * * * ** **** * * ** ** *** ***
* * ** * ** * ** * ** *** }
* * ** * * * * ** *** else
* * *** * * * * * ** * * ** * * *** {
** ** * ** ** **** ** ** ** *   * * * ** * * ** **
* ** *** **   * *** ** * *** }
* * *** **** * *** }
** * * * * * }
** ** ** * ***** ** * ** * *
}
answered by (-249 points)
0 0
prog.c: In function 'main':
prog.c:7:2: warning: 'gets' is deprecated [-Wdeprecated-declarations]
  gets(sentence);
  ^~~~
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/ccDU99TE.o: In function `main':
prog.c:(.text+0x25): 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()
{
*** * * * * ** *** * *** str[1000];
** * * *** ***** ** * i;
** * * *** *** ** ** * ** length;
    
* * ** ** * **** * **** ** * * ***
* *** ** ** * **** *
** *** ** ** ** * * * = (unsigned)strlen(str);
** **** * * **** ** * ****
** ** * * ** ****** *
* * * * * * * **
** * * ****** * *** ***** * * * * ** ** *** **** && str[i]<='z')
* * *** ******* * * * * * *** ** *** ***** * *
* *** ** * * ** * *** **** ***** * ** * * ** **** * * ** * * * ****
* * * ** * * * * * ** *** * * *
* ** * *** * ** ** ** * * ** * ** **** * * if(str[i]>='A' && str[i]<='Z')
* ** *** * * * ** ** * * **** ** ** *
* * * * *** * ** *** ** * ** * * ** * * * *** ** **** *** **** ** *** *** *
* * ** *** * *** ** *
**** ** * * * * ** ** *
** * * * * * ** * **
**** * *** * **** *** * * ***** * ** ***** *
    
* ** ** * * ***** ** **** * * * 0;
}
answered by (-193 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()
{
* **** ** * * * * ** *** ** **** str[1000];
* * * * * *** *** * * ** i;
* * * * * * * ** * length;
    
* * * **** ***** * ** * * ** any string :: ");
*** * ** ** * * *** * * **** * * * *** *
**** ******* *** ** *
** ** * ***** * ** * * = (unsigned)strlen(str);
* ** *** * * * ***
*** * * *** * *** * * ***
* * *** * ** * **
* * * *** **** * *** * *** *** *** ** * * *** * * * * * * && str[i]<='z')
****** ** ** * * * * * **** *** *** *** * **
**** * * * ** *** * * * * * * * * * *** *** *** * * ** ** ** ****
*** * *** * * ** ** * ** *** * **** **
* * ***** *** * ********** ** ** ** * ********** if(str[i]>='A' && str[i]<='Z')
*** *** ** ** * * ****** ** *** *** * ** *****
*** * * * *** * ** *** * * ** * * *** * ***** *** *** ** * ** *
****** ** * *** * **** * * * * * * ** *
* * * * ** * ***
** * * * * * * **
* ** * * * * * ** ** ** * * * ** ** ***
    
* ** ** * * ** * **** ** 0;
}
answered by (-193 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include ** * ******
#include *** * *
#include * * * ** **

int main()
{
** * * * * * ** * * * sentence[1000];
*** * * *** * *** *** count, ch, i;
* ** ** ** ********* *
* * * * *** **** *** * ** * 1000, stdin);
****** * **** * ** ** *** **** = * ** * * * ** *
* * *** * ****** * * (i = 0; i < count; i++)
*** ** **** * ** * * **** ****
** ** ** * * * * * * * ** * ** * ** = islower(sentence[i])? toupper(sentence[i]) :
* * * * ******* * **** * ** * ** ** * *** ** ***
*** * * ** ** *** ** * *** * ** * ** * *** * * * *** *
** * ** * * ** ** *
}
answered by (323 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;
    char a[1000];
    fgets(a,1000,stdin);
*** * ** * ** ***** ** * * ***** *
** * * * ** *** * * * * * *** *** **
*** * * **** *** * *** * * *** ** * * *** * * * * *** * *** * * ** && a[i]<='z')
***** * * * * *** * **** * * *** ** * *** ** * * * ** * * * ** *****
***** ** * * * **** * ** ** * * * ** *** * * ** ***** * ** ** *** * * ** * ** * ** ** ** *** ** * ***
** * *** * *** * * * ****** *** ** *** ** * ** * **** ** * *** ** * ** * * * ** ****
*** * **** * * * ** * * * * * ** ** ** **** **** * * * * * * *** * if(a[i]>='A' && a[i]<='Z')
* * ** **** * * *** * * **** ** * ** * * *** * * ** *** ** ** *** ** * * *** * *
*** ** ** *** * * ** **** ** * ** *** * ** * * *** ****** ** *** * *** *** * ** **** * * ** * * * ** *** ***** * *
* * ** * **** ** * * * * *** **** * ** *** * * *** ** * ***** **** ** * * * ***
* * ** **** ** ** *** **** *** * ** ***
* * * * *** * * *** * ** ** * * * ** * *** **** * ** **
}
answered by (-301 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.8
©2016-2025

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
| 8.8k 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
| 8.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users