main.c 1 #include«stdio.h? 2 int etseries int 1 \'p); 3 int nain) Please input a
ID: 3739600 • Letter: M
Question
main.c 1 #include«stdio.h? 2 int etseries int 1 'p); 3 int nain) Please input a sequence ended by 8: 1 2 3 4567 8 The reverse sequence of the nunbers entered is: 19426848 19426848 19426848 19426848 19426848 19426843 19426848 19426848 5 set up array a with 18 spots and declare variables The maxinum nunher of then is:8 [e 8 int i,nun,nax; 1? //Ask for sequence 11 printfnPlease input a sequence ended by n 12 or i-9;1-9:1++) 13 14 / Gets sequence of nunbers end breaks after e is entered 15 scanf("%d",&a;[i]); 16 If(a[1]:0) 17 break 18 28 sets num variable to i nun-i; 23 prints reverse nubers to screen 24printf( The reverse sequenice of the nuTbers entered is:n") 26 Begins for loop that prints nunbers in reverse arder 27 for(1-nun-1;1%6; i-) 20 29 printf(*? ",&a;[e]); 30 31 32 fcode for finding max number out of the sequence , 34 /sets nax variable to whats stored in ale] 35 nax-a[] 36 37 Goes through for laop of the sequence 38 ari-a;i-nun-1;i-) 4 if what is stored in a[i] is nore than variable nax, a[i] changes to variable nax 41 if(a[i]> max) 42 43 max-3[1]; 45 46 /prints maxinum number (max) to screen 47 printf"nThe maxinum nunber of then 1s:,ax): 18 49 58Explanation / Answer
#include <stdio.h>
int main()
{
int n,a,max=0;
int *rev,*rem,*temp;
printf("Enter any number: ");
scanf("%d",&n);
a=n;
temp=&n;
*rev=0;
while(*temp>0){
*rem=*temp%10;
*temp=*temp/10;
*rev=(*rev)*10+*rem;
}
printf("Reverse of %d is %d",a,*rev);
if(n > max){
max=n;
}
printf("Maximum of %d is",max");
return 0;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.