Page 1 of 1

Help Needed in C.

Posted: Sun Jan 06, 2013 5:25 am
by uvasarker
Which one is better? And why?
Please, help............

Code 1:::

Code: Select all

#include <cstdio>

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0 ; i<n ; i++ ){
        printf("Help Needed.\n");
    }
    return 0;
}

Code 2:::

Code: Select all

#include <cstdio>
#define IN ( {int _T; scanf("%d",&_T); _T;} )
#define loop(ini, lim, inc) for(int i=ini ; i<lim ; i+=inc)

int main()
{
    int n=IN;
    loop(0,n,1){
        printf("Help Needed.\n");
    }
    return 0;
}


Re: Help Needed in C.

Posted: Mon Jan 07, 2013 3:04 am
by brianfry713
I think code 1 is easier to read.

Re: Help Needed in C.

Posted: Mon Jan 07, 2013 3:41 pm
by uvasarker
Hmm,
Guru
Any difference with execution time?

Re: Help Needed in C.

Posted: Mon Jan 07, 2013 10:18 pm
by brianfry713
Not much difference in runtime.