vignesh


{ City } chenna
< Country > india
* Profession * student
User No # 18021
Total Questions Posted # 0
Total Answers Posted # 88

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 974
Users Marked my Answers as Wrong # 508
Answers / { vignesh }

Question { 4335 }

Give a method to count the number of ones in a 32 bit number?


Answer

#include
#include
void main()
{
unsigned i;
int j=0,count=0;;
printf("Enter the number :");
scanf("%ld",&i);
while(j<=31)
{
if(!(((i>>j)&1)^1))
count++;
j++;
}
printf("\nnumber of 1's in ur number is : %d",count);
getch();
}


thank u

Is This Answer Correct ?    0 Yes 0 No

Question { 6283 }

what is the difference between these initializations?
Char a[]=”string”;
Char *p=”literal”;
Does *p++ increment p, or what it points to?


Answer

surely there is some difference.....

here 'a' is represented as array in which string gets stored
in consecutive locations......

p is a pointer variable where string is initilized... so in
p the base address of "literal " will get stored......

*p++ increments 'p' , but pertaining to some conditions.....
++ has more precedence than * , so first it will increment
the address and correspondingly it will show the value as *
precedes..... so after the increment the p points to 'i'...



thank u

Is This Answer Correct ?    5 Yes 5 No


Question { TCS, 6475 }

differentiate between
const char *a;
char *const a; and
char const *a;


Answer

const char *a : means the string is constant and the pointer
is not...

const char *a="HELLO WORLD" , if we take this example for
the whole scope of the program the string is constant and we
can't assign any other string to that pointer 'a'....

char * const a : means the pointer is constant (address) but
string is not......

char * const a="hello world" , if we take this example ,
here the address will be always constant.... string can vary..

char const *a : means string is a constant and pointer is
not..... as we have seen from the first example...


thank u

Is This Answer Correct ?    37 Yes 2 No

Question { 3131 }

Why cann't whole array can be passed to function as value.


Answer

ya it's possible ..... we can pass whole array as an value....

let's take the code :

void function(char [] );
void main()
{
char ch[30];
function(ch);
getch();
}

void function(char ch[])
{
printf("%s",ch);
}

thank u

hope this will work.....

Is This Answer Correct ?    0 Yes 4 No

Question { Oracle, 3828 }

Given a single Linked list with lakhs of nodes and length
unknown how do you optimally delete the nth element from the
list?


Answer

first create the list of unknown length..... then get the position of the element to be deleted from the user.... the start travelling in the list.... if it encounters the position prescribed by the user ... get the addresses in the list and shift that to the previous node and free this node........


thank u

Is This Answer Correct ?    2 Yes 1 No

Question { Wipro, 37156 }

#define CUBE(x) (x*x*x)
main()
{ int a,b=3;
a=cube(b++);
printf("%d %d",a,b);
}
What should be the value of a and b? My calc a=4 but syst
a=6 how pls tell me if you know it?


Answer

surely 'a' cannot be 4 or 6.... it will be the value of b... since we are multiplying b++ thrice...... so surely 'a' cannot be 4 or 6.....

according to me b=6 , and a=60......


thank u

Is This Answer Correct ?    4 Yes 9 No

Question { 24699 }

c programming of binary addition of two binary numbers


Answer

the below program is for getting two numbers as input
(decimal format) and then the below program will convert in
binary and add WITHOUT ANY ARITHMETIC OPERATORS.....



#include
#include
#define HIGH 1
#define LOW 0
void main()
{
long c[32],i,n,a,b,k,m,A,CARRY=0;
clrscr();
n=31;
printf("enter the value of a&b:");
scanf("%ld%ld",&a,&b);
for(i=0;i<32;i++)
{
k=((a>>i)&1);
m=((b>>i)&1);
if(!(CARRY^HIGH))
{
c[n]=((CARRY^k)^m);
if(!(k^HIGH)||!(m^HIGH))
CARRY=1;
else
CARRY=0;
}
else if(!(k^HIGH) && !(m^HIGH))
{
CARRY=1;
c[n]=k^m;
}
else if(!(k^LOW)||!(m^LOW))
{
if(!(CARRY^HIGH))
{
c[n]=((CARRY^k)^m);
CARRY=0;
}
else
c[n]=k^m;
}
n--;
}
for(i=0;i<32;i++)
printf("%d",c[i]);
getch();
}


thank u

Is This Answer Correct ?    30 Yes 12 No

Question { HZL, 50231 }

A man loses 20% of his money and after spending 70% of the
remainder he is left with Rs. 270. Originally he had


Answer

taking an orbital value to be 1000.. then he loses 20% , so
800 will be remaining... then he spends 70% of the remainder
so it will come upto 560.. so remaining will be 240. so this
corresponds to 270 in this question. so by unitary method we
can find... it will come 1125 rupees


thank u

Is This Answer Correct ?    15 Yes 4 No

Question { Qualcomm, 6815 }

Whats wrong with the following function

char *string()
{
char *text[20];
strcpy(text,"Hello world");
return text;
}


Answer

as for as i know , there is only one error..... you have
declared text as array of pointers and not as character data
array..... so this text can only accept addresses.... :)

char *text[20] means you are going to store 20 addresses in
this array..... When you store addresses using arrays , the
that is called array of pointers....

if u declare : char text[20] , this will work correctly..



thank u

Is This Answer Correct ?    13 Yes 2 No

Question { Amazon, 20948 }

What is the output of following program ?

int
main()
{
int x = 5;
printf("%d %d %d\n", x, x << 2, x >> 2);
}


Answer

4 4 1 is the output....

here the operation of STACK involves.... for these kind of statements (ie) statements having multiple values to get printed it is used..... so the very first element that goes inside stack is x , then x<<2 , then x>>2... so from the TOP it will be operated....
and print as the order given in printf statement..... :)

thank u

Is This Answer Correct ?    6 Yes 16 No

Question { HCL, 6236 }

what is self refrential structure


Answer

whenever a structure is been pointed by the same structure
pointer which is the member of the same structure is called
as self referential structure....


thank u

Is This Answer Correct ?    7 Yes 0 No

Question { 20276 }

In this four digit number, the second digit is half the
third digit which is three less than the first which is six
more than the fourth. If no digit is repeated, what is the
number


Answer

7241

thank u

Is This Answer Correct ?    11 Yes 1 No

Question { 18285 }

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW
IT COME ..

#include
#include
void main()
{
int k=20;
printf("%d%d%d%d",k,k++,++k,k);
getch();
}


Answer

22 21 21 20 THIS WILL THE OUTPUT..

this is merely an STACK operation.... here we have 4
parameters.. so the four parameters will be pushed inside
the stack one by one... as

TOP : k
++k
k++
BOTTOM : k

so the expressions will be evaluated from the top.. and thus
the answer....


thank u

Is This Answer Correct ?    9 Yes 3 No

Question { Infosys, 55915 }

I have two coins for 75 paise.1 coin is not 50 paise, how?


Answer

it is said that one coin is not 50 paise so other can be 50
paise and the coin which is not 50 paise can be 25 paise...


thank u

Is This Answer Correct ?    79 Yes 7 No

Question { Bosch, 28276 }

write a c program to change only the 3rd bit of the
particular number such that other bits are not affected..
if bitnum=10(say.. it can be any no..


Answer

it's not possible to change the bit individually by the user
.. the user doen't have permission..... it should not be
allowed for security purposes... then the data can be easily
hacked....



thank u

Is This Answer Correct ?    1 Yes 26 No

Prev    1   2   3   4    [5]   6    Next