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

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) - đã hỏi trong Chapter 3: Branching, Looping and Functions bởi (5.9k điểm)
ID: 30222 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 7k đã xem

20 Trả lời

0 thích 0 k thích
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 trả lời bởi (221 điểm)
0 0
Case 0: Correct output
0 thích 0 k thích
Hidden content!
#include **** * * *
#include *** * ***

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

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

** **   return 0;
}
100/100 trả lời bởi (244 điểm)
0 0
Case 0: Correct output
0 thích 0 k thích
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 trả lời
hiện lại bởi
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
0 thích 0 k thích
Hidden content!
* **** ****** * **
* * **** * *
int main(int argc, char *argv[])
{
*** * * ** ** * ** * * i, a;
* * * *** * * * * * * * * ** ** your input:");
*** * * * * * *** * ** * ** * *** ** &i);
**** ***** * * * *** a<i; i--)
*** ***** ** **** * * * * * * * * **** ** * ** ** ** i);
* ** ** * * ** * * (i=1)
* * * *** ** ** ** ***** * *** * ***** * * ***** *** * ** **
* ** * ** * *** * 0;
}
100/100 trả lời bởi (220 điểm)
0 0
Case 0: Correct output
0 thích 0 k thích
Hidden content!
#include <stdio.h>
#include <stdlib.h>
int main(){
int i;
    printf("Enter your input:");
    ** * * * ** *** * ***** *** ** **
** ** * ** *** * * ** ********** ** ** ** * * ** **** * * *
* *** * * * **** * ** ******* ***** *** * **** * *** ** ** ** * * **
*** *** * * * * ***** ******* * *** ** ** * *** *** ** * ***** ** * * * ** *** * * ** * **
* ** * ** * *** *** ** ** * * *** ** *** * * * * * * * ***
* ** ** ** * * * * * * **** ***** * * * * * *** * ** ** **** * *
** ** ** **** * *** *** * * ** **** ****** * * **** ** ** **** * ** **** ***** * ** ** * * * *** * *
* * ****** * * ** * * * * * ** * * ***** * * * *********
** *** * *** * *** ** *** * * ****
    return 0;
}
100/100 trả lời bởi (243 điểm)
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 thích 0 k thích
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 trả lời bởi (269 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
** * * ** * * *
*** * ** * * ** *
int main(int argc, char *argv[])
{
** *** ** * *** * ** *** i, a;
* * * * *** * *** **** * * *** * ****** your input:");
* *** * * * ****** ****** ** * &i);
***** ** * * * * * ** * ** a<i; i--)
* * ** * ** ** * * * * * *** * * * *** * *** * * * * i);
* * * *** **** *** ** ** (i=1)
*** ** *** ***** * * ** * * ****** * *** * ** ** * * * * **** *
** * * * **** ** **** * * 0;
}
100/100 trả lời bởi (283 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
* **** *** ******
* * * * *
int main(int argc, char *argv[])
{
* **** *** * ***** ** * i, a;
** ** ***** * ** ** ** ***** * **** your input:");
**** ** ** * * **** ** ** ** &i);
* * * *** * *** ** *** a<i; i--)
* * *** * ** ** * *** ** * ** * ** **** *** ** * *** i);
* ** * * ****** * * * * (i=1)
** ** * * ****** * * ** * * * ** * * * * * * * * *
* *** * * * * 0;
}
100/100 trả lời bởi (153 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
** * *** * * *
** **** * * **** ** ***

int * ** argc, char * ** {

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

* ***** ** do{
* * * * * *** * * ** ** * ** * * * your *
** * * *** ****** * **** **** * *
*** ** * ** * * *** **
* * *** ** a != 10 );
** * * *
** * * *** ** ** * * * 9 8 7 6 5 4 3 2 ** ** ****
*** ** * ** ** *
trả lời bởi (153 điểm)
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 thích 0 k thích
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;
}
trả lời bởi (153 điểm)
0 0
Case 0: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.95
©2016-2026

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

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
| 8k đã xem
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
| 5k đã 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
| 8.4k đã xem
12,783 câu hỏi
183,442 trả lời
172,219 bình luận
4,824 thành viên