0 like 0 dislike
2k views

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) - asked in Chapter 3: Branching, Looping and Functions by (5.9k points)
ID: 29618 - Available when: Unlimited - Due to: Unlimited
| 2k views

17 Answers

0 like 0 dislike
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 answered by (221 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 like 0 dislike
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 answered by (183 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
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;
}
answered by (183 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
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 answered
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 like 0 dislike
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 answered by (283 points)
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 like 0 dislike
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 answered by (220 points)
edited by
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 like 0 dislike
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 answered by (273 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
0 like 0 dislike
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 answered by (153 points)
reshown by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
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 answered by (153 points)
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 like 0 dislike
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 answered by (290 points)
reshown by
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:108.162.216.18
©2016-2024

Related questions

0 like 0 dislike
13 answers
[Exercise] Coding (C) - asked Oct 27, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 29558 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
0 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 30241 - Available when: Unlimited - Due to: Unlimited
| 2.2k views
1 like 0 dislike
23 answers
[Exercise] Coding (C) - asked Oct 20, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 28130 - Available when: Unlimited - Due to: Unlimited
| 2.7k views
12,783 questions
183,443 answers
172,219 comments
4,824 users