Member • Mar 6, 2010
9 th c++ Problem
write a program to find index of smallest no in an array?
The one whose program will take minimum execution time and with smallest exe file size will be appreciated
😀
Member • Mar 6, 2010
Member • Mar 6, 2010
#include "stdafx.h" int main () { int arr[] = {5, 9, 2, 4, 5, 3, 9, 6, 7, 4}; int smallest = arr[0]; int index, i; for (i = 0; i < 10; i++) { if (arr[i] <= smallest) { smallest = arr[i]; index = i; } } printf ("The smallest element in the array is %d and its index is %d\n", smallest, index); return 0; }I think size of executable may vary with the compiler used.
Member • Mar 6, 2010
Member • Mar 6, 2010
How to check the run time?goyal420correct .let us wait for more answers ..by the way have you checked run time of this program?
Member • Mar 6, 2010
Member • Mar 6, 2010
Member • Mar 6, 2010
Member • Mar 7, 2010