0

I'm a beginner. Could you look at this question for me .

#include<stdio.h> int f(int *p,int n); int main() { int i,a[3]; printf("please input three whole number"); for(i=0;i<3;i++) { scanf("%d",&a[i]); } printf("\n"); f(a,3); } int f(int *p,int n) { int i,j,a,b,c; printf("The order you want from small to large is :\n"); for(i=0;i<n;i++) { a=i;b=*(p+i); for(j=i+1;j<n;j++) { if(*(p+j)<b) { a=j;b=*(p+j); } } if(a!=i) { c=*(p+i); *(p+i)=*(p+j); *(p+j)=c; } printf("%d ",*(p+i)); } printf("\n"); return 0; } I would appreciate it if you solved the problem.

2nd Nov 2020, 1:30 AM
[No Name]
[No Name] - avatar
5 Respuestas
+ 1
Hello, copy/paste the program in the code playground and then you can share it here with the community. Anyway there's an anomalous space in this printf: printf("The order you want from small to large is :\n"); Delete the space at the end, like that: printf("The order you want from small to large is:\n");
2nd Nov 2020, 1:46 AM
Davide
Davide - avatar
+ 1
devonasprouseho619@gmail.com your code is a mess. You don't need the variables a, b, c. Also it would be easier for you to work on it using array notation instead of pointers arithmetic. You should also learn to post your code properly! Paste it on your code bits and then edit your question adding the code.
2nd Nov 2020, 11:05 AM
Davide
Davide - avatar
+ 1
Ok.Thank you.
2nd Nov 2020, 11:23 AM
[No Name]
[No Name] - avatar
0
Your have a strange character in your 2nd printf call, just one character after "is".
2nd Nov 2020, 1:46 AM
Valmob101
Valmob101 - avatar
0
Ok.But when I entered 6 2 8, it was 3 2 8. How do I solve it
2nd Nov 2020, 2:23 AM
[No Name]
[No Name] - avatar