state your compiler for clearing screen...sub routines are simple...
first off: they're not suroutines, they're functions. they're really simple to do:
Code:
#include <stdio.h>
void /*no return value*/ myfunc(void/*no input*/)
{
printf("Tada!\n");
}
int main(void)
{
myfunc();
return 0;
}
that code calls the function myfunc() to display "Tada!" on the screen.
passing a value to a function is simple, too:
Code:
#include <stdio.h>
void myfunc(int numtimes)
{
int x;
for(x=0;x<numtimes;x++)
printf("Tada!\n");
}
int main(void)
{
myfunc(5);
return 0;
}
and that should display Tada! 5 times.where I wrote int numtimes in the function declaration, it tells the compiler that it needs to be passed an integer value to wrok properly.