Problem in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Problem in C

Enter an array of max 100 elements (two-digit integers). The N value that determines the size of the array is read from the keyboard. Write a C program to reverse the element numbers of the input array, forming a new array according to the following example: original array: 25 71 84 ..., new array: 52 17 48...

17th Nov 2022, 12:38 PM
Elvian Covalciuc
10 Answers
+ 3
Thanks very much)),it works
17th Nov 2022, 7:03 PM
Elvian Covalciuc
+ 1
Elvian Covalciuc please attempt the code, if have any doubt or get an error we try to solve it.
17th Nov 2022, 12:57 PM
Sakshi
Sakshi - avatar
+ 1
#include <stdio.h> int main() { int a[100],n,i,nr1,nr2,result; int b[100]; printf(" enter the array size:\n"); scanf("%d",&n); for(i=0;i<n;i++) { printf("a[%i]=",i); scanf("%d",&a[i]); } for(i=0;i<n;i++){ nr1 = a[i] % 10; nr2 = a[i] /10; b[i] = 10 * nr1 + nr2; } for(i=0;i<n;i++) printf("b[%i]=\n",i); return 0; }
17th Nov 2022, 1:33 PM
Elvian Covalciuc
+ 1
here works the size of the Matrix, but I'm not sure that it changes the numbers with the correct place and does not display them
17th Nov 2022, 1:34 PM
Elvian Covalciuc
+ 1
But array 2 didn't work
17th Nov 2022, 8:03 PM
Elvian Covalciuc
+ 1
Elvian Covalciuc , why do you think it doesn't work?
17th Nov 2022, 8:15 PM
SoloProg
SoloProg - avatar
+ 1
I check it again,program works, sorry
17th Nov 2022, 9:32 PM
Elvian Covalciuc
+ 1
And thanks
17th Nov 2022, 9:32 PM
Elvian Covalciuc
+ 1
I fixed the print format i replaced %d with the %02d Because to display the opposite of 30 as 03 and not 3
17th Nov 2022, 9:49 PM
SoloProg
SoloProg - avatar