0 thích 0 k thích
6.7k đã xem

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

 

[Exercise] Coding (C) - đã hỏi trong Chapter 3: Branching, Looping and Functions bởi (5.9k điểm)
ID: 29618 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 6.7k đã xem

17 Trả lời

0 thích 0 k thích
Hidden content!
* * * ** **** ** ***
** * * *** **

/* 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 trả lời bởi (221 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 thích 0 k thích
Hidden content!
#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 trả lời bởi (183 điểm)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (183 điểm)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 thích 0 k thích
Hidden content!
#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 trả lời
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 thích 0 k thích
Hidden content!
#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 trả lời bởi (283 điểm)
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 thích 0 k thích
Hidden content!
#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 trả lời bởi (220 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
#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 trả lời bởi (273 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 thích 0 k thích
Hidden content!
* * **** *** *
**** ** ** * *** **

* ** ** ** * ** ** ** ** 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 trả lời bởi (153 điểm)
hiện lại bởi
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 thích 0 k thích
Hidden content!
***** *** ******* *** *
*** *** ***** ** * **

** * ** ** * 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 trả lời bởi (153 điểm)
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 thích 0 k thích
Hidden content!
**** ** ****** ***
** * *** * *

/* 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 trả lời bởi (290 điểm)
hiện lại bởi
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:162.159.115.31
©2016-2026

Những câu hỏi liên quan

0 thích 0 k thích
13 trả lời
[Exercise] Coding (C) - đã hỏi ngày 27 tháng 10 năm 2017 trong Chapter 3: Branching, Looping and Functions bởi nat236919 (5.9k điểm)
ID: 29558 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 4.7k đã xem
0 thích 0 k thích
24 trả lời
[Exercise] Coding (C) - đã hỏi ngày 2 tháng 11 năm 2017 trong Chapter 3: Branching, Looping and Functions bởi nat236919 (5.9k điểm)
ID: 30241 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 7.6k đã xem
1 thích 0 k thích
23 trả lời
[Exercise] Coding (C) - đã hỏi ngày 20 tháng 10 năm 2017 trong Chapter 3: Branching, Looping and Functions bởi nat236919 (5.9k điểm)
ID: 28130 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 7.9k đã xem
12,783 câu hỏi
183,442 trả lời
172,219 bình luận
4,824 thành viên