Confucius says, "Search the FAQ. There be many articles suited for many different circumstances."
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
![]()
This is a discussion on Class assignment within the C Programming forums, part of the General Programming Boards category; Originally Posted by tmnismo91 Any words of wisdom? Confucius says, "Search the FAQ. There be many articles suited for many ...
Confucius says, "Search the FAQ. There be many articles suited for many different circumstances."
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
![]()
Ok so I generated my random integers. Now I need to print the highest random integer.Code:while(i < 10) { array[i] = rand() % 100; printf("%d\n", array[i]); i++; }
1. set max_value to array[0]
2. loop for all other member of the array
3. if current value is bigger then max_value - replace max_value
4. after the for - print the found max_value
If I have eight hours for cutting wood, I spend six sharpening my axe.
^^ One of the best programming techniques right there.
Put your problem into english words, in a step-by-step format, what needs to be done to solve the problem. Write down the problem first. The words are called pseudo-code and the whole thing is called an algorithm. They outta teach this stuff before even touching C, IMO.
I suggest you draw out a diagram of an array and "deck-check" your algorithm before even beginning to code it. Make sure your method works to get the right answer. With a simple of a problem as yours is, you should be able to code a logic-bug free C program straight away.