How to calculate memory required by a c Program ?

Is there any way we will find the time and memory required by a c program ?

on a unix like system, if your executable file was called fred you could do

time fred

or

timex fred 

`(on some systems)

memory - afaik codechef used spoj and spoj uses a method that includes the size of the c libraries linked, so even a do nothing program submitted in c reports 2.2Mb

any memory used by your code will be added to the 2.2Mb
an integer takes 4 bytes on codechef c and most other c systems so e.g

int myarray[1000000];

would be approx 6.2Mb total

the memory needed for code you wrote is usually negligible for codechef and competitive programming type problems.

//