J
John
Hi,
I am also new with C.I am studying the C in course.
I performed this solution just as Practice to me.
I found this Problem among messages from this page on Dec.27.
The Problem says:
Declare an array a[10], insert the first element of the array into the
position specified by a following integer and print the contents.
output Example:
1 2 3 4 5 6 7 8 9 10
4
2 3 4 1 5 6 7 8 9 10
I tried .the result showed the error in output and it print the
different output and not the same as said.
then what would be the best way to do that?what is the most proper
alternative way to pay for this problem?
Thanks for all.
My Proposed solution is as follows:
#include <stdio.h>
int main ()
{
int a[10], x;
int i;
for(i=0; i<10; i++){
scanf(" %d", &a);
}
putchar('\n');
for(i=0; i<10; i++){
printf("%d ",a);
}
putchar('\n');
x = a[0];a[0]= a[1]; a[1]=a[2];
a[2]=a[3];a[3]=x;
for(i=0; i<10; i++){
printf("%d ",a);
}
putchar('\n');
return 0;
}
I am also new with C.I am studying the C in course.
I performed this solution just as Practice to me.
I found this Problem among messages from this page on Dec.27.
The Problem says:
Declare an array a[10], insert the first element of the array into the
position specified by a following integer and print the contents.
output Example:
1 2 3 4 5 6 7 8 9 10
4
2 3 4 1 5 6 7 8 9 10
I tried .the result showed the error in output and it print the
different output and not the same as said.
then what would be the best way to do that?what is the most proper
alternative way to pay for this problem?
Thanks for all.
My Proposed solution is as follows:
#include <stdio.h>
int main ()
{
int a[10], x;
int i;
for(i=0; i<10; i++){
scanf(" %d", &a);
}
putchar('\n');
for(i=0; i<10; i++){
printf("%d ",a);
}
putchar('\n');
x = a[0];a[0]= a[1]; a[1]=a[2];
a[2]=a[3];a[3]=x;
for(i=0; i<10; i++){
printf("%d ",a);
}
putchar('\n');
return 0;
}