| Other C Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| Main must be written as
a.the first function in the program
b.Second function in the program
c.Last function in the program
d.any where in the program
| TCS | 10 |
| class foo {
public:
static int func(const char*& p) const;
};
This is illegal, why? | Google | 6 |
| Find Error if any in below code, Justify ur answer:
struct xx
{
int a;
struct yy
{
char c;
struct xx* p;
}
struct yy* q;
} | NDS | 2 |
| what is diff between localstatic and globalstatis variable
possible 2 use in another file...? | HCL | 2 |
| I have a function which accepts, and is supposed to
initialize,a pointer, but the pointer in the caller remains
unchanged. | | 1 |
| which of the following statements is incorrect
a.typedef struct new{
int n1;
char n2;
} DATA;
b.typedef struct {
int n3;
char *n4;
}ICE;
c.typedef union {
int n5;
float n6;
} UDT;
d.#typedef union {
int n7;
float n8;
} TUDAT;
| TCS | 5 |
| how memory store byte
| Huawei | 3 |
| proc() {
static i=10;
printf("%d",i);
}
If this proc() is called second time, what is the output?
| Hughes | 5 |
| what are the various memory handling mechanisms in C ? | HP | 2 |
| WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR
LOOPS.
A) * B) *****
*** * *
***** * *
***** | | 2 |
| what's the o/p
int main(int n, char *argv[])
{
char *s= *++argv;
puts(s);
exit(0);
}
| Motorola | 1 |
| compute the nth mumber in the fibonacci sequence? | TCS | 6 |
| What is the function of ceil(X) defined in math.h do?
A)It returns the value rounded down to the next lower
integer
B)it returns the value rounded up to the next higher integer
C)the Next Higher Value
D)the next lower value | Accenture | 3 |
| How to receive strings with spaces in scanf() | | 3 |
| pick out the odd one out of the following
a.malloc()
b.calloc()
c.free()
d.realloc()
| TCS | 1 |
| Write a program that accepts a string where multiple spaces
are given in between the words. Print the string ignoring
the multiple spaces.
Example:
Input: We.....Are....Student Note: one .=1 Space
Output: "We Are Student" | IBM | 3 |
| 6)swap(int x,y)
{
int temp;
temp=x;
x=y;
y=temp;
}
main()
{
int x=2;y=3;
swap(x,y);
}
after calling swap ,what are yhe values x&y?
| | 2 |
| Write an implementation of float stringToFloat(char *str).
The code should be simple, and not require more than the
basic operators (if, for, math operators, etc.).
Assumptions
Dont worry about overflow or underflow
Stop at the 1st invalid character and return the number
you have converted till then, if the 1st character is
invalid return 0
Dont worry about exponential (e.g. 1e10), instead you
should treat e as an invalid character
Write it like real code, e.g. do error checking
Go though the string only once
Examples
1.23 should return 1.23
1a should return 1
ashould return 0
| Qualcomm | 2 |
| What is the output for the program given below
typedef enum grade{GOOD,BAD,WORST,}BAD;
main()
{
BAD g1;
g1=1;
printf("%d",g1);
}
| ADITI | 2 |
| Here is alphabets : abcdefgh
1) how to reverse. as hgfedcba
2) after reversal, how to group them in a pair hg fe dc ba.
| | 1 |
| |
| For more C Interview Questions Click Here |