>pls give me the code plss
No, no, and no. We don't do homework, and the more you ask, the more we will consider banning you. If you want to post an honest attempt to solve the problem, we'll be glad to help you with it, but we won't do it for you.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
How about for each number, you save it if it's bigger than the last one?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
okay umbrella here is your code.this will find the largest number in a given set of numbers.first of all you store the given numbers in an array and then initialise a for loop:-
main()
{
int i,j,max,a[100];
printf("\enter the number of elements");
scanf("%d",&i);
for(j=1;j<=i;j++)
{
printf("enter the %d element",j);/*comparing and finding the largest number*/
scanf("%d",&a[j]);
}
max=a[1];
for(j=1;j<=i;j++)
{
if(a[j]>max)
max=a[j];
}
printf("\nthe largest number among the given set of numbers is %d",max);
}
indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
mr.stoned_coder for your information.the code is executing perfectily.and i have started the counting from 1 so that the program looks more readable and user friendly.
indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
The code only works for indian because he is not willing to sit and actually enter all 100 items that he is initializing his array for. So it "APPEARS" to be working correctly for him. I know i'm repeating what stoner just said, but i figured i'd explaina little more so that when his code flops he will understand why.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
[Moderator edit]Removed silly namecalling[/edit]
i have declared a[100].that doesnt mean it is compulsary for the user to enter 100 elements.it is for him to enter a number less than 100 so as to fit the numbers into the array.
[Moderator edit]Removed flaming comments[/edit]
indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
>this is the solution to your stupid example
The solution is to fix your stupid broken code, genius. If you want to go around calling people idiots then you had better be damn sure that you're correct. In this case, you're wrong, and ignorant, and stubborn, and I'm giving you an official warning about your attitude. So watch your step when incorrectly correcting someone with a pissy attitude.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
he would be comfortable with 10 or atmost 20 elements.
This is the attitude of someone who wants to write code that will break. You are being advised -- in a very simple way -- how to help make your code unbreakable. Why the hostility?
Eventually, "you'll never need more thatwhatever units" does come back to bite you.
<>
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314