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

17 Answers

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


int main(int argc, char *argv[]) {
** *** **** ** * ** **** a;
*** * ** * * ** * * ** * * *** ***** ****
* * ** * *** ** * * ****** **** *** * **
** * * * **** * *
********* ** *** * *** >= 'a' **** * a <= 'z')
**** *** * **** *** **** ** ** ** * ** * *** **** * * is a small * *** * ** a);
* ***** * * * * ***** if(a >= 'A' && a <= 'Z')
** * ** * * **** **** * ***** ** ***** * ** * ** * ** *** * is a capital * *** * a);
* * ****** *** *** * * if(a >= '0' ** *** ** a <= '9')
*** ** * * ** * * ** * * ** ** *** ****** * * **** * * is a digit", a);
** ** * * *** * * * ** *
* * * *** * * ** ** * * *** *** * ** * * * ** * ** * * * * *
*** ***** * *** * ***
** ** * ** * *
* ** ** * ** **** * ** 0;
}
100/100 answered by (243 points)
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include * * * ** * **
#include ***** * ***** *


int main(int argc, char *argv[]) {
** *** ** *** * ** ** * a;
***** * ** ******* ** ***** * ** ****
* * * ** * * ** ** ** ** **
* * **** ** *** ** * *
*** * ** ** ** * * ** >= 'a' * ** * * a <= 'z')
* * ** * * * ** * ** * ***** *** * **** ****** **** is a small * *** **** a);
** * **** * * * ** * * * if(a >= 'A' && a <= 'Z')
*** ** * ** * ** ** * * * * **** ** * ** ***** * is a capital ** * ** * a);
** * *** ** ** ****** ** * * if(a >= '0' ***** * a <= '9')
* * * * * * ** *** * * * ** *** * * * * is a digit", a);
* ** * * *** ** * ****
* *** *** * * ** * ** ** *** ** * **** *** ** * ***
** * * * * * * ** *
* *** ** ** ***** * *
**** **** * * **** * * * 0;
}
100/100 answered by (269 points)
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
* * * * * ** ***
** ** ** ** * **


int ****** argc, char * {
** *** * * ** * char a;
*** * ** * ** * * * * *****
** * * * * **** * * **** *** *
****
*** * ***** if(a * ** * 'a' ** ** * a * 'z')
* ** ** * * * ** * ** ** *** is a small ** * * * * a);
* * * * else if(a ** * * 'A' * ** a **** 'Z')
* * * * * * ** * * * * ** ** * is a * ** ** ** * a);
*** * * * else if(a * * '0' * * ** ** a *** '9')
* * * * * * **** * **** * * * * is a * ***** * a);
* * ** ** * * else
** ** * * * * **** * ** ** * * *** * ** *
* ** *****
** ****
*** * * *** ** 0;
}
100/100 answered by (269 points)
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
**** * ** ***
** ** ** ******* *
* * * ***
int main(){
*** ** ***** char a;
** **** ****** *** * *** *** : * * ****
**** ** * *** * * * * * * * * *
*** ** *
***** * * * ** ****
** *** ** * * * * * is a * * * ***
** *** * }
***** ** * else *** * * ***
*** * *** * * * *** ** ***** * * is a ** * * ** * ****
* * }
* *** * ** ** else ***
* ***** * *** ** ** *** ** * *** * is a small ******* *** **
** * *** * }
*** ** ** * else{
** *** * * *** ** * * * *** is * * ** *
** ** * *** }
* * * *** *
* * ** *
**** *
****** **** return 0 ;
}

*** **
* *
//6

* *
//6 is a digit

***
*****
//A

** * *
//A is a *** *** *

* **
** ***
//a

* *
//a is a small *****

* ** *
* * *
// /
// / is **
100/100 answered by (271 points)
0 0
prog.c: In function 'main':
prog.c:19:12: warning: format '%c' expects a matching 'int' argument [-Wformat=]
   printf("%c is unknown");
            ^
0 like 0 dislike
Hidden content!
char a;
* * * ***** *
* *** * ** * ** * ***** ****
* ** **** ** * ** ** *** **** *

** ** **
** ** if( a * ** '0' **** *** ** a **** '9' ){
**** * *** * * * *** ** ** * ****** is a * * a);
**** * * *** * }
* **** ** ** else if( a * 'A' *** * ** ** a * * 'Z' ) {
* * * ** * ** * ******** * is a * * ****** * a);
* ** * *** }
*** * * * * * if( a * ** 'a' ** * ** a * 'z' ) {
* ** ** ** **** * ** **** * * is a * *** ** * **** a);
* * * ** }
* * **** * else
* * * * * * **** * *** * *** *** is * * * **** * a);
50/100 answered by (252 points)
0 0
prog.c:3:9: error: expected declaration specifiers or '...' before string constant
  printf("Define:\n");
         ^~~~~~~~~~~
prog.c:4:8: error: expected declaration specifiers or '...' before string constant
  scanf("%c",&a);
        ^~~~
prog.c:4:13: error: expected declaration specifiers or '...' before '&' token
  scanf("%c",&a);
             ^
prog.c:7:2: error: expected identifier or '(' before 'if'
  if( a >= '0' && a <= '9' ){
  ^~
prog.c:10:2: error: expected identifier or '(' before 'else'
  else if( a >= 'A' && a <= 'Z' ) {
  ^~~~
prog.c:13:2: error: expected identifier or '(' before 'else'
  else if( a >= 'a' && a <= 'z' ) {
  ^~~~
prog.c:16:2: error: expected identifier or '(' before 'else'
  else
  ^~~~
0 like 0 dislike
Hidden content!
#include * * * * **
#include ** ** *** *** *

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

int main(int argc, char *argv[]) {
* ** * *** * *** * * q;
* * *** *** * * *
*** * * *** ***** *
* * ** * ** ***** * ****** * * *** **
** *********** * ** * ** ****** * *** **
*** *** *
* ** * * **
*** ** *** * * ***** *** q >= '0' * *** q * * '9' )
** * *** * * * * * * *** *** *** * * ** * * * * *** is a ** ***
* **** ** *** * * *** ** q >= 'a' * *** ** q <= 'z' )
* * * ******** *** * * * ** * * ** ** ** * **** * * ** is a small *** ***** q);
** ** *** ** **** * * * if( q ** 'A' ** **** ** q <= 'Z' )
** *** * * ***** ** * **** * * * *** * * * * * is a capital ********* q);
* * *** * * * ** * *
* ** * * ***** * *** * * * **** * ** *** ******* * * ** is * * *** q);
* ****** *** * * * ** *** ** ** * *
* ** **** * ** *
**** ** * *** ***** *** * 0;
}
100/100 answered by (268 points)
0 1
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 1
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
* * * * **** * ******
** * ** *

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

int ** *** argc, char * {
** **** * * * char a;
* *** * * * * * ** * *** * **
* * *** ** * *** *** * **** * ** *
* ***** * ***
*** * * if * * * * * ** *** *
*** * * * ***** *** * ** * ** *** * ********* * is a **** * **
* * *** }
**** * *** *
**** * ** * else if ** *** * * ** * ** ****** * *****
** * ** ** * *** * ** * ** * * * *** * ** *** *******
**** ** ** * *** ** * * ** * ** is a capital ***** ** * *** *
** * * ** * *** * }
** **** * *** ** ** else if ** ** * * * * ** * * *
* * * * * * * * ** * * * ** ** * * * is a small ****** *****
** * * * * * * ** }
* **
* * ** * ****** else
** * *** * ***** ** is * ** * * **

* * * ** * *
** * ** *** ** return 0;
}
answered by (5.9k points)
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.91
©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
| 692 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
| 1k 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
| 1.4k views
12,783 questions
183,443 answers
172,219 comments
4,824 users