0 喜歡 0 不喜歡
2k 瀏覽

Please write a program that can identify a value's characteristic based on ASCII table. It must identify:

  1. 0-9 is a digit
  2. A-Z is a capital character
  3. a-z is a small character
  4. Besides those conditions, it shows '%c is unknown'.
     

Kindly use the given template to finish the task. Be advised that your outputs must be exactly the same as the shown outputs below.

Example(Template)

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	char a;
	printf("Define:\n");
	scanf("%c",&a);
	
// Your condition starts from here
	
	return 0;
}

 

Input#1

Define:
6

Output#1

6 is a digit

 

Input#2

Define:
A

Output#2

A is a capital character

 

Input#3

Define:
f

Output#3

f is a small character

 

Input#4

Define:
/

Output#4

/ is unknown

 

Suggestion

It's time to use your favourite table: ASCII

 

[練習] Coding (C) - 最新提問 分類:Chapter 3: Branching, Looping and Functions | 用戶: (5.9k 分)
ID: 29618 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2k 瀏覽

17 個回答

0 喜歡 0 不喜歡
內容已隱藏
* ** *** ** *
** ** *** ** **** *

/* run this * * the *** ** or add * own * *** * * * or * loop */

* * ** char * {
* ** * a;
** * * ** ** ****** *** ** **** *
* *** * ** ** ** **** *** * ** ** **
* ** ** *
// * * * ** * *

** * * * **** if( a ***** '0' * *** * a * '9' ){
* * * * * *** * *** * *** **** * is a ** * *** *
** * ** * * ** }
* ** * ** **
* * ******* ** else if( a ** ** 'a' *** * * a **** * 'z' ) {
* * * * **** * ****** ** * ** * is a * ********** * * *
* **** * * * }
* * * * * *** * * **
* *** * * if( a **** 'A' * ** a 'Z' ) {
* **** * ** ** * ** * * ** * *** ** is a * ** **** ****
* * ** * * * }
* * * *** else
**** ****** * * ** ** * ** ** ** * is * *** ** * *** a);
** ****
* * ** ** * ** 0;
}
100/100 最新回答 用戶: (221 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * * **
* * ** ** ** ****

/* run this program using the console pauser or add your own getch, * * ** ** ** * *** or input loop */

int main(int argc, char *argv[]) {
**** ** *** * ** ** c;
**** ** * ** ** *** ** ****** capital;
* ** ** * * * * ***** * *****
** * * * ***** * **** ** *
* ** ** * *** ** *
** ** ** ** *** *** ** * * * * operator = is ** from equality == */
* **** ** *** ** ** = ***
** *** ** ******
** * * ***** * * *** * ** * * * ** * input * ** is %c * ** * * c);
** * *** *** **** ***
* * ***** * ** ** * c '0' * *** c <= '9' ) // we know all the digits are in some range in the ascii table
* ** * * ** ** * * * ** * ** ** ** **** ***** * %c is a * c);

* * * * * * * * *
* ** * * * *** * ** * ** c *** 'a' ** *** * * c <= 'z' )
* ***** *** ** ** * ** * * ** * * * * ** * * ** *** *** *** %c is a small * *** ** c );

* * * ****** * ** * * ****** ** * * **********
* ** * ** **** * * * * * * * *
* *** *** * * * c ** ** 'A' * * ** c <= 'Z' ) // c is a capital letter
** * *** ** ** *** ***** ** * ** ** *** *
* * ** ** *** * * ** * * * * * * ** ** *** *** * ** * **** *** ** %c is a **** * * c );
* ** **** * * ** *** ** * * ***** * * * ***
** * ** * * * * * == '/')
****** * * * *** ***
** * * ** * * *** * * * *** ** ** * * * * *** %c is *** * ***** c);

** ******* * * * * * ** **** *** **** ***
** **** *** * * * *
***** * *** **** * 0;
}
50/100 最新回答 用戶: (183 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include * ** *****

/* run this program using the console pauser or add your own getch, ** * * * **** or input loop */

int main(int argc, char *argv[]) {
* * ** * ** * *** * * n;
* **** ** ** * * * * * ** * * * * the what is your country?: ");
** * *** ** ** * ** * **
** **** **** * ** *** ** *** * * * &n);
* ** ** *** ** * * *
** * ********* ** * * ****** * n ==886)
* ****** * ** * * * * *** * *** *** ** * **** * * * *** * * * *
* * ** * * *** ** ** * if( n == 976 )
* * ** * *** * * * * * * ** * ** ** ** * *** * ** *** * ** * * *
** ****** ****** *** ** ** * if( n == 66 )
** *** * * * ** ** **** * * ** ** ** * * * ** **
*** *** * **** * **** if( n == 62 )
*** ***** ** *** *** * **** * * ** ** * * * ** ** * ** * ***
* ** *** * *** * * * *
* * ****** * ** ** * * ** ** ** * ** * * * * * ** *** * *** *
* * *** * * ** *
**** *** * ********
* *** ****** ***** * 0;
}
最新回答 用戶: (183 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include **** ****
* * *** * ** **

/* run this program using the console pauser or add your own getch, *** * ** ** * * or input loop */

int main(int argc, char *argv[]) {
******* * * **** **** * * c;
******* * ***** * *** * capital;
* * ** * *** ** * * * * ** *
** * *** ** * * **** * ** *
* ** * * * ** * *
** * * * ** ** * * ** * * * ** * * ** operator = is ** ** from equality == */
* * ** * ** ** ** * ** = *****
* ** *** * *********
** **** * **** *** **** ***** input * * is %c ** * ** c);
* ** * * * ** * *
*** ** *** ***** * *** c * * * '0' * * ** * c <= '9' ) // we know all the digits are in some range in the ascii table
* * * ******** ***** ** * ********** * ** * * ** ***** %c is a * * ** c);

* ** * ****** * *
* * ** * * * * ** c ** * 'a' *** ** **** c <= 'z' )
* * ******* *** *** ***** ** * *** * ** ******* **** %c is a small ** c );

**** * * **** **** **** ** * ** *** ***
** ** ** * * * * ** ******* ** * * * * ****
** * ***** *** ***** * c * 'A' * **** * c <= 'Z' ) // c is a capital letter
* *** ** * ***** ** ** * * * ***** * **** * **
*** * **** * * ** **** * ** ** * * * * * *** ******* ** ** *** %c is a * *** c );
*** ** * *** * * * ***** * *** ** * * * **
** * ** * * *** * *** ** == '/')
** * * ** ** * **
* * ** * **** * * ** ** ***** * * *** ** ******* *** ** **** * ** %c is * * * **** c);

* * * ** ** *** * ** * * * * ** * **
* * * *** * ***** * **
*** * * ****** * * 0;
}
100/100 最新回答
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * *** *


int main(int argc, char *argv[]) {
* *** * ** * * * a;
*** * * ** * * ****** * * ** *** * **** *** * **
** *** *** * * * ** **** *** ** * * *
** ** **** * *****

*** **** ** ** * * a >= '0' *** * * a <= '9' ){
* ** **** ******** * * * ** * ** * * ** * ***** ** is a digit ",a);
* *** *** ** * *
** **** ** * *
* * * * * * * * * * ***** ** if( a >= 'A' ** * *** a <= 'Z' ) {
* ** ** * * * * ** * * ** ** * * ** * * * * ** * %c is a capital character ", a);
* *** * ** * * ****** * **
* * * *** *** *
* * *** * * * * * * * * if( a >= 'a' && a <= 'z' ) {
*** * * ** **** ** * * *** * * ** ** * * **** %c is a small * * * ** a);
*** * * * * ***** ****
* * ** **** * * ** **
** ** ***** ** ** * * * ** {
** ** ** ** * * * *** * * *** *** * *** **** ** %c is ** *** ** a);
* * * * *** ****** ** **
** * * * * ** ***
* * * ** * * * * ** * * 0;
}
100/100 最新回答 用戶: (283 分)
0 0
prog.c:28:2: error: stray '#' in program
 }#include <stdio.h>
  ^
prog.c:28:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
 }#include <stdio.h>
           ^
In file included from prog.c:29:0:
/usr/include/stdlib.h:826:20: error: unknown type name 'wchar_t'
 extern int mbtowc (wchar_t *__restrict __pwc,
                    ^~~~~~~
/usr/include/stdlib.h:830:31: error: unknown type name 'wchar_t'
 extern int wctomb (char *__s, wchar_t __wchar) __THROW;
                               ^~~~~~~
/usr/include/stdlib.h:834:25: error: unknown type name 'wchar_t'
 extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
                         ^~~~~~~
/usr/include/stdlib.h:838:10: error: unknown type name 'wchar_t'
    const wchar_t *__restrict __pwcs, size_t __n)
          ^~~~~~~
prog.c:33:5: error: redefinition of 'main'
 int main(int argc, char *argv[]) {
     ^~~~
prog.c:5:5: note: previous definition of 'main' was here
 int main(int argc, char *argv[]) {
     ^~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * ** ** * ***
#include *** ***** * *

int main(int argc, char *argv[]) {
* * ***** *** * * *** * a;
* * * * ** ** * * *** * * * * ****** ** * **
***** * * ** * * * ** *** * ** *** * **
**** **** * * * **
*********** * ** **** * * *
*** **** * * * * * * * a >= '0' && a <= '9' )
*** ** ** ***** ** * ** *** *** ** *** * * ** * *** *** %c is a digit", a);

* * ** ****** **
**** ******* **** **** * * a >= 'a' && a <= 'z' )
* ***** ** ** * * * * ** ** ** ** ** * ** ** *** %c is a small * ** * * ** a );

** *** ** * ** ** * ** * * ** * *** *
*** * ** * * ** ***** * * ** *** ** * *
*** * * ****** *** a >= 'A' && a <= 'Z' )  
** ** *** ** ** **** * * *** *** * ***
****** *** ** **** * ** ** * *** *** ** * * ***** %c is a capital * ** * ** a );
* * * **** * ****** * *** ** * *** *** *
**** * ** ** ** * * == '/')
** *** ** ** * **** ** *
* * * * * ** ** *** * ** * * ** * * * * *** * * %c is unknown", a);

* * * ** * *** * * **** ****** * * * * ** *
* * ***** **** * *
* *** * ** ** ** ** * *** 0;
}
100/100 最新回答 用戶: (220 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>

int main(int argc, char *argv[]){
* *** * ** * * * * * ** a;
* * * ** * *** * * ** ** * * **
* * **** * ****** ** ****** * &a);

* ** ** * * **** * ** ** * **** * * ** * * {
*** * * * * ***** **** ** ** *** *** * * ** * is a digit", a);
* * * * * * ***** **
* *** * ** * * ** * * *** * *** ** * * * ** * {
** * * * * ** * * * * * * **** * *** * *** ** ** * * ** is a capital character", a);
* * ** ** * * ****
* * * ** * ** ***** ** *** **** * ** * ** * {
******* * ******* ** * * * * ** * * * *** ** is a small character", a);
** **** * *** * * * *
* *** * * * {
* *** **** * * * * * * * * **** * * *** * is unknown", a);
* * * * * * * * ** * *
}
100/100 最新回答 用戶: (273 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
***** * *
* *** ** ** * * * *

** * ** * * *** or * * * * * * * *** * *** ***** or * * */

* * *** * ** *** ** {
** ** ** ** * * c;
**** * **** * ** *
** * * * * *
** * * ** * * * *
* * * *****
*** * * *** /* * ** ** * ** = is *** ** * * ***** == */
* * ** *** * c = * * *
* * ** *
* ** ** * ** *** ***** ** * * is %c * *** * c);
**** * ***
*** * ** ** if( c '0' ** ** * c * * ** '9' ) // we all the *** are in ** * in the ** **
** ** * * ** * * ** * * * ** * * %c is a * **** ** * c);

** ** **
**** ** if( c * * 'a' * ** * * c *** ** 'z' )
** ** * * * ** * * * * *** * %c is a ** * *** * c );

** * * * * *** ** *
* ** * ** * * * **
**** ** ** * * c * *** * ** ** **** * c ** 'Z' ) // c is a * **
** ** * *** *** * *
** *** * * ** * * * * * *** ** * %c is a * ** **** c );
* ** *** *** **
***** * * == *
* ** *
*** ** **** ** ******* * * * ** ***** ** ** * * %c is *** ** *

* * * *** * * * *** **
* * * ***
** * * ***** * 0;
}
100/100 最新回答 用戶: (153 分)
重新顯示 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
* * * * *
*** * * ** * **

* ** * * * * * * or ** ** * * * * * ** * * or * *** */

* ** *** ** * *** {
** * * * c;
* ** * ** * *** * **
** * ** * * * * *
** ** ** ****
* * * ** ** *
*** **** * /* * ***** ** * = is * * * **** * == */
* ** * * *** c = * ***
* * ***
* * * * * ** * ** * ** * is %c * * c);
** * *
* ** ** * * * if( c ** '0' * ***** * * c * **** '9' ) // we ** all the ** are in ** ** in the * **
* ** ** ** * * * ** * * * ** %c is a * * * * c);

** * *
*** * if( c * * 'a' *** c ** 'z' )
**** ** * * ** * * * * * * * %c is a * *** *** * *** c );

* * ** * ** * * ****
**** * **** * *** *
*** * ** * * c ***** * * * ** c * * 'Z' ) // c is a *** * *
*** ** ** * ** *
* ** * * **** * * ** * * * %c is a *** *** c );
* *** ** ** *******
* *** *** * == **
** * * *******
**** ** * ** * * * * * ***** * * * ** ** %c is * * * *

* * * * * *** ** * *
* *** ** * *
* * * * * * * * ** 0;
}
100/100 最新回答 用戶: (153 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
The out doesn't expect 'The input character is'

But the results are correct.
0 0
The output**
0 喜歡 0 不喜歡
內容已隱藏
* **** * **** *** **
* ** * * * * *** **

/* run this *** the *** * ** ** or add your own * **** * **** ** ** or input loop */

int ** **** char ***** {
**** ** * * char a;
* * * **** ** ***** ***
* * ** * *** * **** * * **** * ** * **
* ** **
** * ** * *****
* ** * * * ** * * ** *** * * * is a *** *** * a);
* * * * * }
** * * ** else ** *
** * *** * ** * **** ** *** ** is a * * * * * ******* a);
*** **** }
** * * * else **
** *** * * * * * * * * ** is a * * * ***** *** ** a);
* * * * ** }
* * * * else{
* * * * * ** ** * is * * * ***
* ** * ** * }
// Your * * *** from here
* * * * ***
* **** * ** ** * **** 0;
}
100/100 最新回答 用戶: (290 分)
重新顯示 用戶:
0 0
prog.c: In function 'main':
prog.c:11:5: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
  if(isdigit(a)){
     ^~~~~~~
prog.c:14:10: warning: implicit declaration of function 'isupper' [-Wimplicit-function-declaration]
  else if(isupper(a)){
          ^~~~~~~
prog.c:17:10: warning: implicit declaration of function 'islower' [-Wimplicit-function-declaration]
  else if(islower(a)){
          ^~~~~~~
prog.c:21:12: warning: format '%c' expects a matching 'int' argument [-Wformat=]
   printf("%c is unknown");
            ^
0 0
prog.c: In function 'main':
prog.c:11:5: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
  if(isdigit(a)){
     ^~~~~~~
prog.c:14:10: warning: implicit declaration of function 'isupper' [-Wimplicit-function-declaration]
  else if(isupper(a)){
          ^~~~~~~
prog.c:17:10: warning: implicit declaration of function 'islower' [-Wimplicit-function-declaration]
  else if(islower(a)){
          ^~~~~~~
prog.c:21:12: warning: format '%c' expects a matching 'int' argument [-Wformat=]
   printf("%c is unknown");
            ^
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.202
©2016-2024

相關問題

0 喜歡 0 不喜歡
13 回答
[練習] Coding (C) - 最新提問 10月 27, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 29558 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.5k 瀏覽
0 喜歡 0 不喜歡
24 回答
[練習] Coding (C) - 最新提問 11月 2, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 30241 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.3k 瀏覽
1 喜歡 0 不喜歡
23 回答
[練習] Coding (C) - 最新提問 10月 20, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 28130 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.8k 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶