0 like 0 dislike
13.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 | 13.8k views

57 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char a[1000];
* * ** *** * *** *** * *** * * * * * * *
    for(i=0;i<strlen(a);i++)
*** ***** * ** ** ** * * * **** * * * *
***** ** * * * * * * *** *** * ** * * * ** * * ** **** * ***** && a[i]<='z')
* ** * ******** *** ****** * * ** ** **** ** * * * * ** ** * *** * ** ** * * **** *
** * * ** ** ** * ** **** ***** * * * * * * * * * * ** * * ****** * * * ****** ** ***** * * ** ** ***** * * * *****
* * * * * ***** * **** * * * ** * * ** * ** ******** * * * * * *** * ** ***** *
* * *** * ** * * ** ***** ** * ** * ** ** * *** ** ** * * * * if(a[i]>='A' && a[i]<='Z')
* * * * ***** *** *** *** * * * * * * ** **** ** ***** ** * *** * *
** * * * ****** **** **** * * ***** ***** * * * ** *** * ** * ** ** ** ******* ** * * ** **** *** *** ***
**** * *** * * ** * ** * * * * ** * ** ** * * *** *** **** * * * ***
* * **** *** ** * ** * ** * * * ***
* *** *** ***** ** * * **** ** ****** ******* ***** * **** ** *
}
answered by (-301 points)
0 0
prog.c: In function 'main':
prog.c:7:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&a);
             ^
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    char a[1000];
* * ****** *** * *** ** **** ******
    int i=0,l1;
** ****** * * **** *
** * * * ** *** ** * * ******* * *
** * * * *** ** * * * ** * * *** ***** * * * *** * * ***** *
*** * * * *** ** * * * * ** * ** ** *
** *** ** * * ***** ***** * * ***** *** ** ******** * *
* * * * * ***** ***** ** * * *** **** ** *** ** **
*** *** * ** *** ** ** ** ** * *** ** * * * if(a[i]>96&&a[i]<123){
* *** ****** ** * *** * * * * * ***** *** * *** ** *
** ** **** ** ** * *** *** ** * *** ***** ** * * * ** * * **
** *** ** ** * ** * * * ****** ***** * *
* ** * **** * * * * * * *** * * * ****** * * **
* * ** ** ** * * *** *** ***** ** * * ** * **** *** ** * *** * * * ** ** *
** *** * * ** * * * * * ** * ** ****** * *
    }

}
answered by (-329 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()
{
* *** *** * * * * string[1000];
** ******* * ** * * * * * i=0;
**** *** * * * * ** **** ***** * ** *
* * * ** * ** ** ** * ** **
    {
* * *** * ****** * *** ****** * ** * * ** * *** && string[i]<='z')

****** **** ** ** ** **** * ****** * ** ** * ******** * * *** **** * ** * * *

* * *** *** **** * * *** ** ** * ****** *** ** if(string[i]>='A' && string[i]<='Z')

** *** * **** * **** * ** * * * *** * * ** ** ** * * * ** = string[i] + 32;

** * *** ** **** ** * * ** ** ** *** *** ** *

**** ***** *** * * *
* *** * ** *** ** ** * * * ** * * ***** **
* * * * **** **** * ** ** * * *
*** * ** * * *** * * ** * ** * * **
* ** * * * * * ***** *
* **** * * * * *** ** ***** * * * ** ***
** * * * * * ** * * ** 0;
}
answered by (-323 points)
edited by
0 0
prog.c: In function 'main':
prog.c:7: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/ccuYke74.o: In function `main':
prog.c:(.text+0x2f): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:21:15: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<strlen(string);i++)
               ^~~~~~
prog.c:21:15: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:21:15: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
prog.c: In function 'main':
prog.c:21:15: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<strlen(string);i++){
               ^~~~~~
prog.c:21:15: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:21:15: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
prog.c: In function 'main':
prog.c:21:15: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<strlen(string);i++)
               ^~~~~~
prog.c:21:15: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:21:15: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:24:5: error: expected '}' before 'else'
     else
     ^~~~
prog.c: At top level:
prog.c:26:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:27:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
prog.c: In function 'main':
prog.c:24:5: error: expected '}' before 'else'
     else
     ^~~~
prog.c: At top level:
prog.c:26:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:27:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
prog.c: In function 'main':
prog.c:21:15: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<strlen(string);i++)
               ^~~~~~
prog.c:21:15: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:21:15: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
** * ** *** * * * *
int main(void)
{
* * * ** * ** ** **** * * str[1000];
* * * * * **** * i,temp;
** * * * *** * * * **** * *
**** * * ** * * ** n = strlen(str);
** * ****** ** * ****** * * * *
** * * * * ********
*** *** ** * * *** * * * * **** ** *** **** ** && str[i] <= 'z')
** * ****** * * ** * ** ** ** * * * ** * * * **
*** * * * * **** * * ***** * ** **** *** *** if(str[i]>='A' && str[i] <= 'Z')
***** * * *** * **** ** * * ** * * ** * ** ** **** * ** **** ** ***** *
* ** * * * * *** ** * * * * * * * *** * *
*** ** ****** ****** * * *
*** * * **** * ** * * * * ** ****** 0;
}
answered by (-281 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 <stdlib.h>
#include <string.h>

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

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

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

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

** ** * ** ***** *** * * = 0; i < len; i++)
*** ** * * ***** *** * *
*** ******** ** **** ** ** *** ****** * * *** * * * *** >= * * * * **** <= 'Z'))
* ** * * ** * * ** ** * * *** *** **** *
***** * * ****** ****** ** ***** * *** ** * * * ** ** * * * ** **** += 32;
* ***** * * * * * ** * * ** * * * ** * ** * *
** *** * * ** ** * * ** ** ** * ** ***** if ((array[i] >= *** ** * **** ***** <= 'z'))
**** ** * * * * * * * **** ** *** * * * *
* *** ***** * **** * ***** * ** * * * ** ** *** ** *** ******* ** **** * -= 32;
* **** ** * * ** *** * *** * **
** * * * * ** ** ** * * ** ** * *** *** * *** ** * **
*** *** **** * * * **
** ** **** * * **** ** 0;
}
answered by (-284 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 <stdlib.h>
#include <string.h>

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

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

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

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

* * ** ****** * ** * * ** = 0; i < len; i++)
***** *** ** * ******* ***
* * * * * * ***** * * * **** *** * *** ** >= * ****** ****** ** <= 'Z'))
* ** *** * * * * * * **** * * * * ** ***** **
* * ******* * ** ** * **** ***** * ** * * * ** ** * * **** *** ** * * * += 32;
**** *** ** *** ** *** **** * * *** * * ** * *
*** ** * *** * ** *** * * *** * ** *** if ((array[i] >= *** ** * * ** * <= 'z'))
**** * * * * * ************ * ** * * * * *
** * *** *********** * * *** ** *** * *** *** ** ** ** * * -= 32;
** *** ** **** ** * ** * *** *** ** * *
* * * ** ** * **** * ** ** * ** * *** ******** * * ** *
* ** * * * *******
** *** *** * ** ** 0;
}
answered by (-108 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 <studlib.h>
#include <string.h>

int main()
{
* * * *** *** * *
* * **** **** array[1000]={0};
** * ** * * ** ** * ** i = 0;
** ** * ******** * *** * 1000, stdin);
* ****** ****** ***** * len = strlen(array);
* **** * * * ***** * * * * i<len; i++)
* * ** * * * * ** ***
** * **** * *** * **** * ** * * * * * * **
* * * ** * * ** ** * * * * ** ******** *** ** * >= * * ** * * * <= 'Z'))
* ****** * *** ** * * **** ***** * * * * ***
* *** *** *** * ***** ******* *** **** ** * * ********* ***** **** *** * * += 32;
** * * ** * * * * * * * ***** ****** ** *** **
* ** * * ******** * * **** ** * * * * *** * * * **
** **** * *** ** * * * **** * * ** ** * if((array[i] >= 'a')&&(array[i] <= 'z'))
* ** ***** ****** * ** *** * ** ** *
** * * ** * * * * ** ** ** * * ** ** ** * * * **** ***** -= 32;
* * * *** * * * * ***** * * * ** **
* * *** ** ** ** * * * ** * * *** *********** * ** ** ** **
*** **** ** * *** * *
* ** * ** * ** ** * *** *** 0;
}
answered by (-284 points)
0 0
prog.c:2:21: fatal error: studlib.h: No such file or directory
 #include <studlib.h>
                     ^
compilation terminated.
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>

int main(){
** ** **** * * ** ** str1[1000];
* ** * ** ** * * ** a,b,c,d;
* **** * * **** ** * ** *** * ** * ** * *
* * * ** * * * * *
* * * * ***** ** * *** * * *
*** * * * *** * * ** * ** * ** ** ** ******* ** &&str1[a]<='Z')
** * **** * * * * * ***** ** ****** * ** ** * * * * * * ** ** ** *
** * * *** ** ** * ** * *** *** * *** * * * ** * **** * * * *** * * **** *
* * * * * * * * **** * ****** * * ** ** ** * *** **** ** ** * *
    }
*** * **** ** ** * ***** ** ** *
*** ** * ** * ** * ** ** 0;
}
answered by (-498 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct 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()
{
** ** * **** * ** * * * * ** str[1000];
    int i;
**** ** * * * * * ** * * * *
** ** *** ** ***** ** * * * * **** **
    {
** ** *** *** * * * ** ***** * *** * *** * * * ** **** *
**** * ** * * ** * *** * **** ** * ****
* ** **** ***** * ** * ***** ****** * * * * *** * * * * ** ** * * ** * **
*** ***** * * * ** * * * * ** * *** * ***
* * * * ** * * * ** * * ** * * ** * * if * * ** *** ** ** *** ** *
** * ** ** * *** *** * * ** * * *** ** *
* * *** * * * *** * * *** **** * * ***** ***** ** ****** * * * *** ** **
* * ** ** *** ** **** * **** ** ** ******** *
    }
** ** ** * *** * **** **** *** ** *** *** ***

**** * ** * * * ****** *** 0;
}
answered by (-196 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()
{
    char a[1000],b[1000];
    int i,j,len;
****** * *** * ** ***
    {
** ** ** *** ** * * ** * * * * *
    }
** * * * *** * ** ** *** **
** * ********** ** * ** ** * *
*** * ***** * ***** * *** ****** ** * * *
    {
**** * ** *** * ** ** **** * ** * ** **** ** ** * **** ** ***
* * * * ** **** * ** * ** ** * * **** ****** *
** * ****** ** ** * *** * *** **** * ** ** * * *** ** * ** *** ********
***** ** ***** *** * * * * ** ** * ****** *** ** ** *** ***
* * * * ** * * * ***** * * ** * * *** * * *** ***** * ** * * * * * ** **
*** *** ***** * * ** * * ** **** * * * ** ** ** * ** * * *
* * * * * *** ** * **** *** ***** * ***** ** ******** * * * ** * * if(a[i]==97+j)
* *** * * **** * * * * ** * * * * * ** * *** * * *
*** **** * ** ** * * * ** *** * * * ** * ****** * *** ** * * ** *** ** * **
* ***** * * ** ** * * *** * *** * *** * * * * ** ** *
* * ***** * * * * * * * ** **** *** * *
* *** * * * * ** * * * * ** ** * * * * *** * *** ** **
    }
}
answered by (-255 points)
0 0
prog.c: In function 'main':
prog.c:11:9: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     len=strlen(a);
         ^~~~~~
prog.c:11:9: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:11:9: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.190.205
©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
| 9.6k 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
| 9.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users