Confucius says, "Search the FAQ. There be many articles suited for many different circumstances."
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
;)
Printable View
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
^^ 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.