What is a static function?
How to print a statement without using printf() in c?
using getchar()
main()
{
int i;
char c;
for(i=0;i!=’
‘;i++)
{
c=getchar();
putchar(c,n);
}
getch();
}
Why should I prototype a function?
A function prototype tells the compiler what kind of arguments a function is looking to receive and what
kind of return value a function is going to give back. This approach helps the compiler ensure that calls to a function are made correctly and that no erroneous type conversions are taking place.
What is the purpose of main( ) function?
main() is the user defined function.
main() is the first function in the program which gets called when the program executes.The startup code contains runmain() function which calls main() function.we can’t chage the name of the main() function.
How would you use the functions randomize()and random()?
Random() returns a random number between 0 and (num-1).random(num) is a macro defined in stdlib.h
Randomize() initializes the random number generator with a random value.Because randomize is implemented as a macro that calls the time function protyped in time.h,you should include time.h when you use this routine.
What is the difference between printf() and sprintf()?
Both are similar but a normal diffrence is that printf() print the actual means which we want to print and sprint() is for only string operation
How would you use the functions sin(),pow(),sqrt()?
Before using these functions <math.h>
should be included in the program
sin(d) will returns the sine of d,
pow(a,b) will returns a the value a to the power b(a^b)
eg:pow(2,3) will returns 8;
sqrt(a) returns the square root of a
eg: sqrt(4) returns 2;
How to write a program in c to print its own code?
#include<stdio.h>
int main(int argc,char *argv[])
{
int c;
FILE *fp=fopen(argv[1],”r”);
while((c=getc(fp)) != EOF)
putchar(c);
getch();
fclose(fp);
return 0;
}
How to write a program such that it will delete itself after exectution?
A large program is subdivided into a number of smaller programs or subprograms. Each subprogram specifies one or more actions to be performed for a large program.such subprograms are functions.
The function supports only static and extern storage classes.By default, function assumes extern storage class.functions have global scope. Only register or auto storage class is allowed in the function parameters. Built-in functions that predefined and supplied along with the compiler are known as built-in functions.They are also known as library functions.
Is it better to use a macro or a function?
It generally depends on your requirement. Because macro are inserted into the code where they called and the cursor always go sequentially. It means, when a compiler compile the program, it insert the macro code to particular place. And it increases the speed of execution.But in case of function, whenever it is called the pointer goes to particular address where function is stored and do calculation and return result if required.
In this case, if a function is called so many time, it consume time in to and from.


