Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@gauravbhorkar-Pf9kZD • Mar 6, 2010
Compiler used - Visual C++ Express 2008.
Here is the code.
#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.
Size of this exe when compiled using VC++ 2008 is 30 Kb. -
@manish-r2Hoep • Mar 6, 2010
correct .let us wait for more answers ..by the way have you checked run time of this program? -
@gauravbhorkar-Pf9kZD • 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? -
@manish-r2Hoep • Mar 6, 2010
I don't know about visual c++ but you can check it in turbo c++
click on option 'compile' in menu bar...then click 'information'
For more info have a look of this thread
#-Link-Snipped-# -
@gauravbhorkar-Pf9kZD • Mar 6, 2010
Well, I couldn't find that in VC++. Even googling didn't help much. -
@manish-r2Hoep • Mar 6, 2010
It's okk..good job 😀 -
@thechamp-p64ZA1 • Mar 7, 2010
#include<iostream>
using namespace::std;
int main()
{
int a[10]={5, 9, 2, 4, 5, 3, 9, 6, 7, 4},i,n,index;
n=a[0],index=0;
for(i=1;i<10;i++)
if(a<n) n=a, index=i;
cout<<index;
return 0;
}
This code has executible file of size 464 kb in dev-cpp and 24 kb in turbo c, also the code has 0.1 millisecond execution time in Turbo, dont know how to find time in dev-cpp