| | |
pls i need help
![]() |
•
•
Join Date: Aug 2005
Posts: 2
Reputation:
Solved Threads: 0
hi to all.. i need help about C programming i have problem with my project, its about that how to determine the max number using for loop ill give the output and pls give me the code plss
Output:
Enter Numbers: 5<--input
Enter first number:1<--input
Enter second number:2<--input
Enter third numbe:3<--input
Enter fourth number:4<--input
Enter fifth number:5<--input
Maximum number is: 5<---result
Output:
Enter Numbers: 5<--input
Enter first number:1<--input
Enter second number:2<--input
Enter third numbe:3<--input
Enter fourth number:4<--input
Enter fifth number:5<--input
Maximum number is: 5<---result
•
•
Join Date: Aug 2005
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Narue
>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.
•
•
Join Date: Jul 2005
Posts: 164
Reputation:
Solved Threads: 5
how would you do it in your head especially if you had a poor memory.
You would loop through your list, examine first number and write it down on a bit of paper.Then you would look at next number if there was one and if bigger you would scrub out whats on the slip of paper and write the new number down. Eventually you would have examined all the numbers and the number on the paper slip will be the biggest number in the collection. Now if you cant figure out how to convert that to c++ dont fear, theres always a call for refuse collectors!
You would loop through your list, examine first number and write it down on a bit of paper.Then you would look at next number if there was one and if bigger you would scrub out whats on the slip of paper and write the new number down. Eventually you would have examined all the numbers and the number on the paper slip will be the biggest number in the collection. Now if you cant figure out how to convert that to c++ dont fear, theres always a call for refuse collectors!
•
•
Join Date: May 2005
Posts: 82
Reputation:
Solved Threads: 1
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:-
C Syntax (Toggle Plain Text)
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); }
•
•
Join Date: Jul 2005
Posts: 164
Reputation:
Solved Threads: 5
Ok so you wanna look like a dick!
enter 100
j<=100, 100 is <= 100 so code executes
scanf("%d",&a[100]).... segfault
a[99] is the last element of the array.
:cheesy: :cheesy:
C Syntax (Toggle Plain Text)
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]); }
j<=100, 100 is <= 100 so code executes
scanf("%d",&a[100]).... segfault
a[99] is the last element of the array.
:cheesy: :cheesy:
![]() |
Similar Threads
- windows xp installation error!! pls help! (Troubleshooting Dead Machines)
- Help me remove Online Poker Pop up pls (Viruses, Spyware and other Nasties)
- hi friends pls help me out (C++)
- pls.help me im begging you!!! (C)
- pls... i need help!!! (C)
- Pls Hlp me with Hijackthis log file. (Viruses, Spyware and other Nasties)
- Pls help with my HJT log (Viruses, Spyware and other Nasties)
- can somebody pls. help me out with my HJT log.. (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Global Variables help
- Next Thread: Please help with program - STUCK
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush fgets file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming pyramidusingturboccodes read recursion recv repetition research scanf scheduling segmentationfault send shape socket socketprograming socketprogramming stack standard string suggestions systemcall test unix urboc user voidmain() wab win32api windows.h





