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

Please write a program using at least one function to receive a number '2018', then outputs Happy_New_Year_2018!!  For other numbers received it will show those numbers instead.

Input 1 

2018

Output 1

2018
Happy_New_Year_2018!!

 

Input 2

69

Output  2

69
69

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

22 Trả lời

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

int readNumber();
void **** number);

int main(int argc, char *argv[])
{
* * ****
** * * * * ** a;
******* * * = readNumber();
* * * *** *
***** * * *
* * * ** * *
* ** * 0;
}

void *** * * number){
*** ** * * ** * ** * ***** a;
* **** * ** *** *** ** * * (a == 2018){
* * ** * * * *** ** * *** * * ** **** * * ** *** * ** * ** ****
**** ** ** * ** * * * * else
* * ** ** ** * * * * * * ** ** * *** ****** *
* ** **** *** * **** ** *** * * ** * *
}

int ** ** **
* ** * *** * ** ** ** ** x;
* *** **** * * * *** **** **** * *** &x);
*** ** ** *** ** * * * x; * * * *** ***
}
75/100 trả lời bởi (192 điểm)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
#include * ** ** * *
#include * ** ** ***

int readNumber();
void *** * number);

int main(int argc, char *argv[])
{
* * *** ** * *
* * * * * ** a;
* ******* = readNumber();
** **** ** *
* * * * * * ***
********** ** ** *** *
* * * * *** 0;
}

void ** * *** number){
* * ** *** * ** a;
* *** *** * * * (a == 2018){
******* * ** * ** *** * * * * ** * *** ** ** * * ** ** ****
** ** *** * ****** * ** else
** * * ** *** * * *** * * * * **** ** * * **
* * * ** *** ***** * * ** *
}

int * * **
** ** * ***** *** *** ** x;
* ** * * ** * **** * * * *** **** * ***** * &x);
* ** * * * ** * * * x; * **** * * **
}
75/100 trả lời bởi (192 điểm)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
#include *** * ** * * **
#include * **** ** *** *

int readNumber();
void ** * number);

int main(int argc, char *argv[])
{
** ***
** ** * *** * ** a;
** ** * * * * = readNumber();
** ** * * *
****** *
** * * ** * * * **
** * ** * *** * * * 0;
}

void *** * number){
* * * ** *** * * ** a;
** ** ***** * ** (a == 2018){
* ****** * * * *** ***** *** * * * *** *** * * * * *** * * * ** * ** * ******
* * * * ** ** * * else
** * * * * *** ** ** *** * ***** * ***** * ** *
*** * ** ** * * ** ** * **** * ***
}

int ** *****
** ********* * * * * * * * x;
*** *** ** ** ** * ** ** * ** ** ** &x);
* * * *** * *** **** *** x; * * ** ****** **
}
75/100 trả lời bởi (183 điểm)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
#include * * * ** ** *
#include * ** ** ****

int readNumber();

int main(int argc, char *argv[])
{
*** *** * ** *
* * * * * a;
**** * * *** = readNumber();
** * * ** a == 2018)
***** **** **** * *** * *** ** * * * ** *** * * **** * * *
* *** *
**** ** * * * * ** * *** ** * * ** ** ** ** * a);

* * *** ** **
* *** ** * * * * *** * * *** *** * * * * *
** *** *** * * * 0;
}


int * **
** * ** ** ** ** * * * x;
***** *** * ***** ***** * ***** ** * ** ** &x);
** ** ** * ******** * x; ** * * **
}
100/100 trả lời
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
** ** * ** *
* ** ** * ** **

int main(){
**** **   int n;
* * *  
  **** * ** **** * * * * ** ***
** * ** * *
** * * *** * ***** *
** * * * ** ** * *** ** * * ******* * ** *
** **** }else{
** *** **** **** **** * ** * * * * **
**** * * }
}
50/100 trả lời bởi (244 điểm)
0 0
prog.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
 include<stdio.h>
        ^
In file included from prog.c:2:0:
/usr/include/stdlib.h:100:8: error: unknown type name 'size_t'
 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
        ^~~~~~
/usr/include/stdlib.h:427:22: error: unknown type name 'size_t'
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
                      ^~~~~~
/usr/include/stdlib.h:429:22: error: unknown type name 'size_t'
 extern void *calloc (size_t __nmemb, size_t __size)
                      ^~~~~~
/usr/include/stdlib.h:429:38: error: unknown type name 'size_t'
 extern void *calloc (size_t __nmemb, size_t __size)
                                      ^~~~~~
/usr/include/stdlib.h:441:36: error: unknown type name 'size_t'
 extern void *realloc (void *__ptr, size_t __size)
                                    ^~~~~~
/usr/include/stdlib.h:716:9: error: unknown type name 'size_t'
         size_t __nmemb, size_t __size, __compar_fn_t __compar)
         ^~~~~~
/usr/include/stdlib.h:716:25: error: unknown type name 'size_t'
         size_t __nmemb, size_t __size, __compar_fn_t __compar)
                         ^~~~~~
/usr/include/stdlib.h:725:34: error: unknown type name 'size_t'
 extern void qsort (void *__base, size_t __nmemb, size_t __size,
                                  ^~~~~~
/usr/include/stdlib.h:725:50: error: unknown type name 'size_t'
 extern void qsort (void *__base, size_t __nmemb, size_t __size,
                                                  ^~~~~~
/usr/include/stdlib.h:823:36: error: unknown type name 'size_t'
 extern int mblen (const char *__s, size_t __n) __THROW;
                                    ^~~~~~
/usr/include/stdlib.h:827:34: error: unknown type name 'size_t'
      const char *__restrict __s, size_t __n) __THROW;
                                  ^~~~~~
/usr/include/stdlib.h:834:8: error: unknown type name 'size_t'
 extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
        ^~~~~~
/usr/include/stdlib.h:835:32: error: unknown type name 'size_t'
    const char *__restrict __s, size_t __n) __THROW;
                                ^~~~~~
/usr/include/stdlib.h:837:8: error: unknown type name 'size_t'
 extern size_t wcstombs (char *__restrict __s,
        ^~~~~~
/usr/include/stdlib.h:838:38: error: unknown type name 'size_t'
    const wchar_t *__restrict __pwcs, size_t __n)
                                      ^~~~~~
prog.c: In function 'main':
prog.c:7:2: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
  scanf("%d",&n);
  ^~~~~
prog.c:7:2: warning: incompatible implicit declaration of built-in function 'scanf'
prog.c:7:2: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:10:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   printf("Happy_New_Year2018!!");
   ^~~~~~
prog.c:10:3: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:10:3: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:12:3: warning: incompatible implicit declaration of built-in function 'printf'
   printf("%d",n);
   ^~~~~~
prog.c:12:3: note: include '<stdio.h>' or provide a declaration of 'printf'
0 0
# is missing
0 thích 0 k thích
Hidden content!
***** * ******** *
** * ** * * *** ** **

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

int *** argc, char **** {
int a;
*** ** ** *** *** * *** ** * * ** *
* * ** * *** * * * **
* * * *** * *** * * * ** ******* *
**** ** * ***** * }
*** * * ** * * ** * *
* ** * ****** * ** *** ** * *** ** * ** * * **
* * * * * * **** * ** *
* ** * * ** ** *
*** ** * 0;
** * ** * ***

** * * * * *
100/100 trả lời bởi (227 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
* ** * *** *** ** *
* ** ** * **

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

int ** * argc, char * *** {
int a;
*** * * * * * * * ****** * **
* *** ** ** * * *
* * *** ** * ** *** ***** * * * * * * * *****
** * ** ***** **** * * **** * *** ** *** * ***** * ** *
**** * * }
*** * * * *** * ** **
** ** * * ** * ** **** * * * * ** * * *** * ** *
*** * * * * * * * **** * *
* ** * * * *** * ** *
*** ****** return 0;
* *** * **
trả lời bởi (227 điểm)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
***** ** ** * **** *
* ** * * * *

/* run this * ** the **** ** or add your own * * * *** ***** ** or ** ** loop */

int * ** ** char * {
*** ** ** ***
*** * ** * int *
* *** ******* ** ** * *** *
** * * **** * * == * **
* *** * ** *** * ** * ******** * * * * **
}
*** ** **** else
* * * *** * * ***** * ** * * * **
** * ** *
* **** ****
*** *** * *** *
* * * ** * 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
0 0
Nice job. However, considering using at least one function would satisfy the question.
0 thích 0 k thích
Hidden content!
* * * * *** *

int **** argc, * argv) {
* * * **** int n;
***** * **** * * ** *** * * * **** ***** **
* * *** ** ** if(n == **
* * * ****** * * * * * ******** * *
*** ** * * * }
** * ** * * **** else * *** **** ***
***** * * * * return 0;
}
100/100 trả lời bởi (220 điểm)
đã sửa bởi
0 0
prog.c:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 thích 0 k thích
Hidden content!
#include <stdio.h>
#include *** * * **

int xyz(){
** ******* * * * **** a;
**** * *** * ** * ***** ***** ** * &a);
***** **** ** * * * * a;
* * ********** **

int main(int argc, char *argv[])
{
    int a = xyz();
* *** * **** ** * **
****** * * * ***
* * **** * * * *** == 2018){
** * ** ***** **** * *** *** ** * *** * * *** * * ** * ***** *** *** ** * *** * * a);
***** ** ** *** ** * *
*** * * * ** * * ** **
******* ** * * * ** * * * * * * * * ** *** * * ** ****** *** a);
** * ** * *** *

* ** * * * **** * ** *** *
80/100 trả lời bởi (269 điểm)
0 0
prog.c: In function 'main':
prog.c:12:2: error: stray '\302' in program
  \xc2\xa0 \xc2\xa0int a = xyz();
  ^
prog.c:12:3: error: stray '\240' in program
  \xc2\xa0 \xc2\xa0int a = xyz();
   ^
prog.c:12:5: error: stray '\302' in program
  \xc2\xa0 \xc2\xa0int a = xyz();
     ^
prog.c:12:6: error: stray '\240' in program
  \xc2\xa0 \xc2\xa0int a = xyz();
      ^
prog.c:22:3: error: expected declaration or statement at end of input
   system("PAUSE");
   ^~~~~~
0 0
The program doesn't end yet. Something is missing.
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.39.118
©2016-2024

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

0 thích 0 k thích
18 trả lời
[Exercise] Fill in the blank - đã hỏi ngày 23 tháng 12 năm 2017 trong Chapter 3: Branching, Looping and Functions bởi nat236919 (5.9k điểm)
ID: 39813 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 646 đã xem
0 thích 0 k thích
16 trả lời
[Exercise] Coding (C) - đã hỏi ngày 23 tháng 12 năm 2017 trong Chapter 3: Branching, Looping and Functions bởi nat236919 (5.9k điểm)
ID: 39810 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 873 đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên