0 like 0 dislike
5.2k views

Please write a program that receives an input number, then decreases the input by 1 until it reaches '0'. But instead of showing '0', it will output 'zero'.

Example(template)

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

int main(int argc, char *argv[]) {
	int a;                             //can be changed

	printf("Enter your input:");       // DO NOT change
	scanf("%d",&a);

    // Your conditions start from here

	return 0;
}

 

Input

Enter your input:10

Output

Enter your input:10
10987654321zero

 

** No need to put a space between numbers

[Exercise] Coding (C) - asked in Chapter 3: Branching, Looping and Functions by (5.9k points)
ID: 30222 - Available when: Unlimited - Due to: Unlimited
| 5.2k views

20 Answers

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

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

* * **** ***** your ** ** * * ** * * ** * * * ** DO NOT change
*** ** * ** * ** ****** * ***

*** * * *** ** ***** * Your ***** * start from here
* * ** * ** * * **** * i;
* **** ** * * * **** ** * = a; i >= 0; i--){
** **   * * * ** * * *** **** if(i == 0){
***** * **** ** * * * ** * * ***
** * * ** * * * * * else
* * * ** ** ** * * * * * * * * * * * ** * *
*** * ** * * * * }
* ** * * * *
* * ** ** *



***** * * * return 0;
}
100/100 answered by (221 points)
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
#include *** * ** * * *
#include * ** * * *

int main() {
* * ** * * * int a;

* * * * * *** ***** *** your * ** *
* ** * * * * **** * * * *
* * ***
* * ** *** for(int *** * * *
***** * * ** * *** ** *** ** * if(i==0){
** *** * ** ** *** ** ** * ** *** ** * * ****** *** ** *
* *** * *** * * * ** * ** }else{
*** * * *   ** * *** * *** ** * ** * * ***
* * * ** * * * ** }
* ** * }

****   return 0;
}
100/100 answered by (244 points)
0 0
Case 0: Correct output
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[]) {
* * ** ** **** **** * * * **

* * ** * ** ** **** ***** ** your ***** ** * ***
**** *** * * ** * = getchar();
* ** *** ***** *** ** = *
* ** * * ** ** * = getchar();
***** * * * * * * = getchar();
*** *** * * * * = *
* *** * ** *** * ***** * = ******
* * ***** *** **** * * * *** = getchar();


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

** * ** ** * *** q >= 'a' * * *** * * q <= 'z' )
** * * * * ** ** * * * ** * * * * * *** ** ** * * ** q + * ******* - 'a'));
** **** **** * * *** * * *** * * * *** w >= 'a' **** *** ** w <= 'z' )
* ***** * ** * *** ** ** *** ** * * * * ****** ** *** w + * * ** *** - 'a'));
* ** * **** ***** ** ** ** * ** * e >= 'a' ****** * ** * e <= 'z' )
**** * * * ** * ****** *** * * ***** ** *** * *** * * *** e + ** ***** - 'a'));
* * *** *** * * * ***** * ** ** * ** * * * ** r >= 'A' * * *** r <= 'Z' )
*** ** **** *** * * *** * ** * ****** * * * ** ** ** ** r - *** * - 'a'));
*** ** ** **** ** * * ** ** ** ** *** * * * * *** t >= 'A' ** * * t <= 'Z' )
* ** * * *** **** * * ***** ** * **** * *** * * * * t - * ** * - 'a'));
* * * ******* * ** ** * * * * * y >= 'A' * * * * y <= 'Z' )
******** ** **** *** * ** ** * *** ** **** * * * *** * *** y - * *** * - 'a'));
** * * * **** * *** * * * **** * * *** u >= 'A' *** ** ** ** u <= 'Z' )
* **** * * * ** * * * * * * * ** * ***** * * *** * * * u - * ** ** - 'a'));
* * ** ** * *** * * * *** ** * ** **
* * **** ** * * *

* ** ** * *** ** ** ****
******* * * ** ** *** * *** 0;
}
0/100 answered
reshown by
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
0 like 0 dislike
Hidden content!
* ** * **
***** ** * *****
int main(int argc, char *argv[])
{
*** ***** ******* **** * * * i, a;
* * *** ** ** ** * ** * * your input:");
* * ** ** *** *** *** *** ***** *** *** * **** &i);
* * ** **** * ** ** ***** * * a<i; i--)
** ***** ******* ** ** * * * * * * * * ** * * ** * i);
* ** * * ** * * ** (i=1)
**** * * *** ** * * * ** * * * ** ** * *** ***
* * **** ** * * ** ** 0;
}
100/100 answered by (220 points)
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
int main(){
int i;
    printf("Enter your input:");
    ** * ** * *** ** ***** * * *
* ** ** *** * **** * * * * * * ***** ** *** ** * * *** * * * *
*** * * * * *** * * * **** * ** **** ** * ** * * ** * ***
* * * *** * ** ** ** * ** * * * * ** * * * ** * * ** *** * *** ** * * * * * **** ** * * *
* ** * ** *** * *** * **** * * * * * * *** ***** ** * * *** * ** ** * *
** * ** **** ** ** ****** * ** * ** ** * ** * *** * * *** * * **
* * * ** *** * ** ***** ** * * *********** ***** * ************* *** * * ***** * **** ** ** * * * ** ***
* * * ** * * *** * * * * ** * * * *** * * ** * * **
*** * **** * * **** * * * * ** *** * * * **
    return 0;
}
100/100 answered by (243 points)
0 0
prog.c: In function 'main':
prog.c:6:14: error: 'number' undeclared (first use in this function)
  scanf("%d",&number);fflush(stdin);
              ^~~~~~
prog.c:6:14: note: each undeclared identifier is reported only once for each function it appears in
0 0
prog.c: In function 'main':
prog.c:6:14: error: 'number' undeclared (first use in this function)
  scanf("%d",&number);fflush(stdin);
              ^~~~~~
prog.c:6:14: note: each undeclared identifier is reported only once for each function it appears in
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    int number;
  int i;
*** ** *** **** * your input : ");
* * * *** * ****** * ** * *** * * ** ** * * * * * *** *** * * * ** * *
*** * *** ***** ** ** ** *** * *** * *** ******** *****
*** ** * * * ** * * ** **** ** * ** * * * * * * ** ** * * ****** * *
** * ** **** * * * * ** * * **** * * * ** ** * **** * * ** **** * * * * * * * ** * *** *
* ** * *** * * *** ** * * * * * ** * *** * * ** * *** ** *
** * *** ** * ** ** * ** ** * *** ** ** ****** * ** *****
* * ** * * ** * * *** * * *** * * * * ** * * * * * * ** * * ** ******** ***
* ** *** **** * ** ** * * * ** * *** ****** * ***** *** * * *
* ** * ***** ** * ***** ** * * ***** *** *** * ***
* * * *** ***

    return 0;
}

Input
10

Output
Enter your input:10
10987654321zero
50/100 answered by (269 points)
edited by
0 0
prog.c: In function 'main':
prog.c:22:1: error: expected declaration or statement at end of input
 }
 ^
0 0
prog.c: In function 'main':
prog.c:7:10: warning: missing terminating " character
   printf("Enter your input : );
          ^
prog.c:7:10: error: missing terminating " character
   printf("Enter your input : );
          ^~~~~~~~~~~~~~~~~~~~~~
prog.c:8:30: error: expected ')' before ';' token
          scanf("%d", &number);fflush(stdin);
                              ^
prog.c:8:10: warning: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
          scanf("%d", &number);fflush(stdin);
          ^~~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:364:12: note: expected 'const char * restrict' but argument is of type 'int'
 extern int printf (const char *__restrict __format, ...);
            ^~~~~~
prog.c:20:1: warning: format not a string literal and no format arguments [-Wformat-security]
 }
 ^
prog.c:20:1: error: expected ';' before '}' token
0 0
Case 0: Wrong output
0 0
prog.c:23:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
 10
 ^~
prog.c:27:1: error: invalid suffix "zero" on integer constant
 10987654321zero
 ^~~~~~~~~~~~~~~
0 like 0 dislike
Hidden content!
* ** * ** * ***
** * * *** *** * ****
int main(int argc, char *argv[])
{
* ** ** ** * ** * i, a;
** * * * * ******* ** ** ** ***** your input:");
*** *** ** **** ** * *** * ****** **** * ** &i);
**** * * ****** * ** * a<i; i--)
* * *** ** *** ** * **** * **** *** * * *** * ** ** * * i);
** ** * * ***** ** * ***** *** (i=1)
*** ** ** *** **** * * ******* *** * *** ***** * * *** *
** **** * * * * * * 0;
}
100/100 answered by (283 points)
edited by
0 0
prog.c: In function 'main':
prog.c:8:18: error: 'a' undeclared (first use in this function)
     for( i=0; i>=a; a--)
                  ^
prog.c:8:18: note: each undeclared identifier is reported only once for each function it appears in
0 0
prog.c: In function 'main':
prog.c:8:18: error: 'i' undeclared (first use in this function)
     for( a=0; a>=i; a--)
                  ^
prog.c:8:18: note: each undeclared identifier is reported only once for each function it appears in
0 0
Case 0: Wrong output
0 0
prog.c: In function 'main':
prog.c:8:21: error: 'a' undeclared (first use in this function)
     for(int i=0; i>=a; i--)
                     ^
prog.c:8:21: note: each undeclared identifier is reported only once for each function it appears in
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
*** * * * ** *
* * ** ********
int main(int argc, char *argv[])
{
* * ** * ** * ** **** * *** i, a;
** ***** ** * * ** * ** * * ** * ** * * your input:");
** ** ** * **** * *** * * * ** ** *** * * * &i);
* * ** * * ******* * ** a<i; i--)
* ** * * * ***** ** ** *** * * * * ***** ** ** **** * * i);
* * ** * **** * *** * (i=1)
* ** * * ** ** ***** * ** * * * ****** * ** * ** * **
* * ** ** * *** *** ** 0;
}
100/100 answered by (153 points)
edited by
0 0
Case 0: Wrong output
0 0
I recommend you use loop run numbers from 10 to 0, then use 'if' to change 0 into 'zero'
0 0
Case 0: Correct output
0 like 0 dislike
Hidden content!
****** ** * * **
** * * * * *

int * * argc, char * {

**** * * ** int a=10;

* ** * *** do{
**** ** ** ** ** ** ***** ** * your ****** ****
** *** *** * * * ***** ** * ********* ** ***
* ** **** *** * * *
* *** * ** a != 10 );
* ** * * *** *
** *** ***** * * ****** 9 8 7 6 5 4 3 2 ** ** *** *
* ** ** ** ** * *
answered by (153 points)
0 0
prog.c: In function 'main':
prog.c:15:2: error: expected expression at end of input
  return
  ^~~~~~
prog.c:15:2: error: expected declaration or statement at end of input
0 like 0 dislike
Hidden content!
* * *** ** **
*** * *** * * ** *

int * argc, char * ** {

* ** * * int ***

*** * * do{
*** * * ** * * * * * * * *********** your ** ** **
* ** *** * * * **** ** * * **** ** * * *
* * * * * ***** * * if( a * 10)
**** * * * * * * ** * ** * * ** * * * **** code is too low! * **
** * * ** * ** * * **
* * ***** * * * if( a ** *** 10)
* *** * * * * * ** *** * * * * ** * ** is too high! ***
* * * ** *** * *** a != 10 );
* *** ** *
** * **** * * ****** * 9 8 7 6 5 4 3 2 * * ** * **
******* *** * * 0;
}
answered by (153 points)
0 0
Case 0: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.176.105
©2016-2025

Related questions

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
| 5.9k views
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
| 3.7k 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
| 6.4k views
12,783 questions
183,442 answers
172,219 comments
4,824 users