0 like 0 dislike
3.6k views

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

22 Answers

0 like 0 dislike
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 answered by (192 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
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 answered by (192 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
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 answered by (183 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include ** * * ****
#include ******* **

int readNumber();

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

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


int ** * **
** **** * **** * * * ** * x;
** ******* **** * ** **** ** * *** * ***** &x);
** * ** * ** *** * * ***** ** x; ***** ** * *
}
100/100 answered
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
** * **** *** * ** *
******** * * *

int main(){
* * **   int n;
**  
  ** ** **** **** * ** * * ** * *
* * * ****
*** ** **
** * * * ** ** ** ** * * ** ** ** *
* ** * *** ** }else{
*** * * * * ** ** ** * ****** ** * *
*** * ** }
}
50/100 answered by (244 points)
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 like 0 dislike
Hidden content!
*** * * *****
*** * * * * **** *

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

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

* * ** ** ***
100/100 answered by (227 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
** * * **
* *** ** * * *

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

int ** * * argc, char **** * {
int a;
** **** * * * * **** ** *
****** * **** * *
** *** * * **** ** * ****** * ** * ** * * *
* ** * * * * * ** *** * * * **** * *
* ** * ** * * }
* * *** * *** * *
* *** ** * **** * * * ** ** * * * * ** * ***
* ** * * * *** * * ***
** ** * ** * ****
* ** **** ** return 0;
* *
answered by (227 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
* * * *** ***** ***
* ** * *** *** **

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

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

int ** * argc, * * argv) {
*** ** int n;
******** * ** ** *** ** ** *** **
*** ** * * * if(n == ** *
* * ** * * ** *** ** * * * *
** * ***** }
* * ** else ** ** * * * **
* ** * * return 0;
}
100/100 answered by (220 points)
edited by
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 like 0 dislike
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 answered by (269 points)
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.69.17.59
©2016-2025

Related questions

0 like 0 dislike
18 answers
[Exercise] Fill in the blank - asked Dec 23, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 39813 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
0 like 0 dislike
16 answers
[Exercise] Coding (C) - asked Dec 23, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 39810 - Available when: Unlimited - Due to: Unlimited
| 3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users