How about this solution?
From: John (ghaogha_at_fsmail.net)
Date: 12/28/04
- Previous message: PainKiller: "Logic Design question"
- Next in thread: Thad Smith: "Re: How about this solution?"
- Reply: Thad Smith: "Re: How about this solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Dec 2004 10:23:07 -0800
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[i]);
}
putchar('\n');
for(i=0; i<10; i++){
printf("%d ",a[i]);
}
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[i]);
}
putchar('\n');
return 0;
}
--- John
- Previous message: PainKiller: "Logic Design question"
- Next in thread: Thad Smith: "Re: How about this solution?"
- Reply: Thad Smith: "Re: How about this solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|