0 like 0 dislike
5.4k views

Please write a program using an array to receive 5 numbers, then output those inputs in reverse order as examples shown.

Input (i)

1 2 3 4 5

Input (ii)

1
2
3
4
5

 

Output (i) acceptable

54321

Output (ii) acceptable

5 4 3 2 1 

 

More information

https://www.tutorialspoint.com/cprogramming/c_arrays.htm

 

[Exercise] Coding (C) - asked in Chapter 4: Arrays by (5.9k points)
ID: 35804 - Available when: Unlimited - Due to: Unlimited
| 5.4k views

17 Answers

0 like 0 dislike
Hidden content!
#include * ** * * *
* **
int main()
{
* ** * *** **** * n = 4, c, d, a[100], b[100];
* **
* * *** *
*** * * ** * ** (c = 0; c * * * n ; c++)
**** * ** ** *** **** * * * * * * ***** * * **
*** **
** * *** * ***
** *
* **** ** **** ** * (c = n , d = 0; c * 0; c--, d++)
* **** **** ** **** **** ** * * * *** * * = a[c];
* *
*** **** *** * *
* * * *
** ***** *** *** ** (c = 0; c * n; c++)
* ** *** *** ** * * ****** * * * = b[c];
** * *
** *
**** **** * ** **** * (c = 0; c * * n; c++)
** ***** * * * ** * * * *** *** ** * ***** a[c]);
*****
* * * ** ** ***** * ***
* * ** * * ** 0;
}
100/100 answered by (192 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include * * * * ****

int main()
{
** ** *** * ** ** * n = 4, c, d, a[100], b[100];
* *
** ** *** *** * **
* * * * ** * * (c = 0; c **** * n ; c++)
*** * ***** * ** ********** * ** * * ** * *** * *** *** * * **
** *
* * ** ** ***
*****
* * * * * (c = n , d = 0; c *** 0; c--, d++)
** **** * ** * *** ** * * * *** = a[c];
***** *
* ** ** * ******
* ****
* * *** * * (c = 0; c * * * n; c++)
** * * ** * * ****** * ** **** *** = b[c];
* * *
* * *
******* **** ** ** * (c = 0; c *** * n; c++)
* * ** ***** **** * * * ** **** ** * * ****** ** * **** a[c]);
* * *
*** *** * * * * ** *
*** * * **** *** 0;
}
100/100 answered by (183 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** * * ** ****** * * ** * ** * tab[5],i;
** ** ** * *** ** * ** ** ********
** ** * ***
* * * *** *** **** ** ** * ***** * ** *** * * **** ** * *
** * ** ** * ** ** **
* *** ******* * *** ** * (i=4;i>=0;i--)
* * ** *** *** **** *** *
***** * ** ***** *** * ***** *** ** ***** **** ******* * * ",tab[i]);
*** *** * *** *
* *** * * ** * * * * * * 0;
}
100/100 answered
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
*** * ** *** * **
****** *** * ****

int main(){
* *** *   int * ** * *
** * *** *
** * * for(int * * **** *
**** * * * *** * * * * ** * * * ******* ** *
* * ***** }
}
100/100 answered by (244 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include ** * * *****
* ** ** ** ** ** **

int main () {

* * * * * * ** * n[5];
*** * * * *** **** i,j;
*** * *** * * ** size=5;
*** **
** ** *** * * elements of array n to 0 */ ****** ***** ** ** * ** *** * ** ** **** *
** *********** ( i = 0; i < size; i++ ){
**** ** *** * ***** **** * * ******* **** * * *
*** * * ** * ****
* ** *** * **
** *** * * * ** * * * output each array **** value */

for(j = 4; * *** * j--){
* ** ** * **** * *** * ***** ** * * *** *
** ** ** ** * *****

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

** ** ****
100/100 answered by (221 points)
edited by
0 0
prog.c: In function 'main':
prog.c:16:13: warning: too many arguments for format [-Wformat-extra-args]
      printf("%d", j, x[j]);
             ^~~~
0 0
ERROR:         printf("%d", j, x[j]);
0 0
prog.c:29:2: error: expected identifier or '(' before 'return'
  return 0;
  ^~~~~~
prog.c:30:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include ** *** *

int main(int argc, char *argv[]) {
* ** **** * ** * **** * a[5],i;
* * * *** * ****** ** * **** * {
** **** * * ** *** * ** * * *** * * * ***** ** * * * * &a[i]);
** * * ** ***** **
* * *** * * * ** * ** *** * * {
** * *** ** **** ****** * *** * * ***** * ** ** *** ", a[i]);
* ** * *** *
}
100/100 answered by (273 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include * * * ** **
int main(){
* **** ** * x[5], i;
* ** **** *
*** * * ** * ** * * *
* * * ***** * * ** * * * *** ******* * ** * &x[i]);
* ** ** *
** * *** * **** i--){
** ** ** * * ** * ** **** * x[i]);
**** *** *
** * ** *
* **** *** * ** ** 0;
* * * *
}  
100/100 answered by (254 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** * ** * ** * *** * tab[5],i;
** * * * ******* ** ** ** ** * *
** ** *** * ** ** * *
* * ** *** *** * ** * * * **** * * ********* * * * * ** * *** *
* ** ** ***** **
* * * ** **** * * (i=4;i>=0;i--)
* ** * * **** * ** *****
** *** * **** * ***** * ** * * *** * * * ",tab[i]);
**** * ** * ***
*** * * **** *** * * ** 0;
}
100/100 answered by (283 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include * ** ****
* **
int main()
{
** * **** * * * * * n = 4, c, d, a[100], b[100];
*** *
** ** **** * *
* **** **** *** (c = 0; c n ; c++)
******* ** ** * ** * * ** **** * ** * *
* *
**** ** ******
*
* ** *** * * * * (c = n , d = 0; c **** 0; c--, d++)
* * ** * * ** ***** *** ****** **** = a[c];
** ** ** *
* ** *
* **
* ** * ***** (c = 0; c * ** n; c++)
* * **** * ** * * ***** * **** * * * = b[c];
** *
* * **
**** * * ** *** (c = 0; c * ** n; c++)
***** *** * * * *** * ********* *** * * * *** a[c]);
* *
** * ** *** ** **
**** ** * *** * 0;
}
100/100 answered by (153 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include ** ** ** *
***
int main()
{
* ** ****** * **** n = 4, c, d, a[100], b[100];
** *
**** * *** *** *
**** *** * *** (c = 0; c * n ; c++)
* * * *** * ** ** * ** ** * * *** ***** ** * * *
*** *
* ** * * *****
**
* **** * **** * * (c = n , d = 0; c ** 0; c--, d++)
** * * ** * *** ** * ** = a[c];
***
* **** ** * *** * *
* *** *
*** ** * **** ** * * (c = 0; c ** *** n; c++)
* *** * * *** *** * *** ***** = b[c];
***
* ***
* ** * *** ** ** ** (c = 0; c * n; c++)
** * *** ** **** * ** ** * ** **** * * *** * * a[c]);
** * **
* ** *
* * ** * * ** 0;
}
100/100 answered by (268 points)
0 0
prog.c: In function 'main':
prog.c:26:3: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
   system("PAUSE");
   ^~~~~~
0 0
prog.c: In function 'main':
prog.c:25:3: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
   system("PAUSE");
   ^~~~~~
0 0
prog.c: In function 'main':
prog.c:25:3: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
   system("PAUSE");
   ^~~~~~
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
Case 4: Wrong output
Case 5: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.241.185
©2016-2025

Related questions

0 like 0 dislike
18 answers
[Exercise] Coding (C) - asked Jan 5, 2018 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 41054 - Available when: Unlimited - Due to: Unlimited
| 6.2k views
0 like 0 dislike
46 answers
[Exercise] Coding (C) - asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37580 - Available when: Unlimited - Due to: Unlimited
| 9.7k views
0 like 0 dislike
20 answers
[Exercise] Fill in the blank - asked Dec 15, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 37578 - Available when: Unlimited - Due to: Unlimited
| 3k views
0 like 0 dislike
18 answers
[Exercise] Fill in the blank - asked Dec 7, 2017 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 35798 - Available when: Unlimited - Due to: Unlimited
| 2.7k views
0 like 0 dislike
0 answers
[Resource] asked Jan 5, 2018 in Chapter 4: Arrays by nat236919 (5.9k points)
ID: 41053 - Available when: Unlimited - Due to: Unlimited
| 13 views
12,783 questions
183,442 answers
172,219 comments
4,824 users