Wednesday 26 August 2009

typedef of function in c

In c we can typedef the function declaration. It is useful when function declaration is too complex and we have to give any simple name or if we have to create more numbers of function of the same type. typedef void govinda(int);void main(){    govinda one,two;    one(1);    two(2);    getch();}void one(int x){    printf("FROM ONE %d",x);}void two(int y){    printf("\nFROM TWO %d",y);}FROM ONE

Monday 24 August 2009

How to calculate size of a function in c?


Size of any function is calculated as:



Size of function = Size of all local variable which has declared in function + Size of those global variables which has used in function+ Size of all its parameter+ Size of returned value if it is an address. Example:




What is size of calculate function?


int x=2;

int* calculate

void main(){

    int *p,a=0,b=5;

    p=calculate(a,b);

    printf(

Saturday 15 August 2009

c strlen



strlen is function of c which has been defined inside the library string.h. Prototype of strlen function is: size_t strlen(const char * str); Explanation of prototype: Return type: Return type of strlen function is number of character in the str excluding null character. Example:(1)What will be output if you will execute following c code? #include "string.h"void main(){ size_t t; t=

main.c



Every c program starts with a main function and end with null statement. Properties of main function: 1. Any c program can have only one main function. 2. main function is called by operating system. 3. main is not keyword of c. So any variable name can be main. 4. Programmer can also call the main function. 5. Default return type of main function is int and default parameter is void.

Sunday 2 August 2009

Storage class interview questions in c


Storage
class interview questions in c programming

1. What is problem in following code?

void main(){

    int a=5;

static int i=a+5;

printf(“%d”,i);

}

2. Tell any five properties of auto variables?

3.

What is problem in following code?

void main(){

    register a,b,sum;

scanf(“%d%d”,&a,&b);

sum=a+b;

printf(“%d”,sum);

}

4. Can we declare same variables in two times globally?

5.

Data type interview questions

1. What is use of void data type?
2. What is size of int data type in c?
3. What will happen if we will assign a value to float variable which is beyond the range of float data type?
4. Write down three derived data types in c.
5. Can we use signed keyword with double? Why?  
6. Why range of signed char is -128 to 127 not -127 to 128?
7. What is cyclic nature of int data type?
8. What will be