ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories >> Software >> Programming-Languages >> C
 
 


 

Back to Questions Page
 
Question
how we can make 3d venturing graphics on outer interface
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Microsoft
I also faced this Question!!   © ALL Interview .com
Answer
what is 3rd venturing graphics...
 
0
Ravi
 
 
Question
How to add two numbers without using arithmetic operators?
Rank Answer Posted By  
 Question Submitted By :: Gopi
This Interview Question Asked @   Sapient , Pan Parag, Tcs, E-Track System, In Exam
I also faced this Question!!   © ALL Interview .com
Answer
#include <stdio.h>
      int add(int a, int b)
      {
	    if (!a)
		return b;
	    else
		return add((a & b) << 1, a ^ b);
      }

      int main()
      {
	    unsigned int a,b;
	    printf("Enter the two numbers: \n");

	    scanf("%d",&a);
	    scanf("%d",&b);
	    printf("Sum is: %d",add(a,b));
      }
 
0
Selloorhari
 
 
Answer
Please explain me the code
 
0
Kiran
 
 
 
Answer
Hi,
This is the code for a FULL ADDER circuit.
 
0
Selloorhari
 
 
Answer
why cant we just or the two numbers
 
0
Nitish
 
 
Answer
Hi Nitish,

If we will do the LOGICAL OR function then we will get
either 1 or 0. 
If we will do the BITWISE OR then we will get the largest of
the two.. 

For
 ex:
Let us take, First number as 2 and Second number as 3..
Then as per the first case we will get 1 as the output. 
10(2) || 11(3) -> 1(1)
As per the second case the output will be 3..
10(2) | 11(3) -> 11(3).
Ok
 
0
Selloorhari
 
 
Answer
int sum(int num1,int num2)
{	
     for(int i=0;i<num2;i++)	
        num1++;	
     return num1;
}
 
4
Pugalarasu
 
 
Answer
even this gives the same ans as the above program gives...
just every one plz check it and tell me
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c;
printf("enter the nos");
scanf("%d %d",&b,&c);
a= (b^c);
printf("%d",a);
return 0;
}
 
0
Prashant
 
 
Answer
#include<stdio.h>
int a,b,c;
{
printf("enter the two values");
scanf("%d","%d",&a,&b);
c=a||b;
}
 
1
Kavi
 
 
Answer
prashant answer is wrong suppose add two similar numbers 
prashant answers will fail because addtion of two similar 
bits  according to the bitwise xor fails.
 
0
Pradeep
 
 
Answer
#include<stdio.h>
main()
{
int a=5,b=4,c;
c=a||b;
printf("sum="+c);
}
 
0
Ranjith
 
 
Answer
# include <stdio.h>
main()
{
int a=8,b=2;
a|=b;
printf("sum="+a);
}
 
0
Suhas
 
 
Question
write a program to swap bits in a character and return the value
prototype of function
char fun (char a, charb flag c)
where fun returns a char, char a is a the value char b is
the bit to be changed and flag c is the bit value
for eg: x=fun(45,7,0)
since 45 is 0010 0101
and ow x should contain the value 65  (0110 0101)
Rank Answer Posted By  
 Question Submitted By :: Yasir Sidique
This Interview Question Asked @   Bosch
I also faced this Question!!   © ALL Interview .com
Answer
#include <stdio.h>

char fun ( char a, char b, int flag )
{
	if ( flag ) return ( a |= ( flag << ( (int) b - 
1 ) ) );
	return ( a &= ~( 1 << ( (int) b - 1 ) ) );
}

int main ( int argc, char* argv [] )
{

	char a = 45;

	printf ( "\n Before change :%d", (int) a );
	printf ( "\n After change :%d", (int) fun ( a, 
(char) 7, 1 ) );

	return ( 0 );
}
 
0
Abdur Rab
 
 
Question
18)struct base {int a,b;
base();
int virtual function1();
}
struct derv1:base{
int b,c,d;
derv1()
int virtual function1();
}
struct derv2 : base
{int a,e;
}
base::base()
{
a=2;b=3;
}
derv1::derv1(){
b=5;
c=10;d=11;}
base::function1()
{return(100);
}
derv1::function1()
{
return(200);
}
main()
base ba;
derv1 d1,d2;
printf("%d %d",d1.a,d1.b)
o/p is
a)a=2;b=3;
b)a=3; b=2;
c)a=5; b=10;
d)none
19) for the above program answer the following q's
main()
base da;
derv1 d1;
derv2 d2;
printf("%d %d %d",da.function1(),d1.function1(),d2.function1
());
o/p is
a)100,200,200;
b)200,100,200;
c)200,200,100;
d)none
20)struct {
int x;
int y;
}abc;
you can not access x by the following
1)abc-->x;
2)abc[0]-->x;
abc.x;
(abc)-->x;
a)1,2,3
b)2&3
c)1&2
d)1,3,4
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
18) d 
o/p is 
2 5
19)
d
o/p is
100 200 100
20) none
Answer is 1,2 & 4.
 
0
Naresh S
 
 
Question
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?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
After calling the function swap(), the values of x,y will be
the same.

i.e. x = 2, y = 3.

The scope of the variables x,y,temp in the swap() function
lies inside the function swap() itself. So there will not be
any change in the values of x,y in the main() function..
 
0
Selloorhari
 
 
Answer
the values will be x =2 and y = 3.

the variables x and y declared in main() are local to main.

whereas 

the variables x and y declared in swap() are local to swap..

 the change in the value of the variables in either 
function will have zero effect on the other function.

Hence the value remains teh same.
 
0
Shruti
 
 
Question
2)#include<iostream.h>
main()
{
printf("Hello World");
}
the program prints Hello World without changing main() the 
o/p should
be
intialisation
Hello World
Desruct
the changes should be
a)iostream operator<<(iostream os, char*s)
os<<'intialisation'<<(Hello World)<<Destruct
b) c) d)none of the above
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Siemens
I also faced this Question!!   © ALL Interview .com
Answer
d
 
0
Anitha
 
 
Answer
c
 
0
Renuka
 
 
Answer
a
 
0
Sheeba
 
 
Answer
b
 
0
Beedha
 
 
Question
1)which of following operator can't be overloaded.
a)== b)++ c)?! d)<=
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Siemens
I also faced this Question!!   © ALL Interview .com
Answer
ans is C
 
4
Rohit
 
 
Answer
d
 
0
Vani
 
 
Answer
a
 
8
Manu
 
 
Answer
Answer is (d).
 
0
Vivek
 
 
Answer
c
 
5
Kamaljit Singh
 
 
Answer
Ans is (c)
 
5
Suganya
 
 
Answer
c
 
0
Ruchi
 
 
Answer
D
 
0
Rajesh
 
 
Answer
ans is c....write
 
0
Jignesh
 
 
Answer
a
 
0
Umamaheswari
 
 
Question
What will be printed as the result of the operation below:

#include<..>

int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);
x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);
}
Rank Answer Posted By  
 Question Submitted By :: Selloorhari
I also faced this Question!!   © ALL Interview .com
Answer
The Output will be:

First output  : 12
Second output : 13
Third output  : 14

for changevalue() function:
      Even though the value of x(11) is sent to
changevalue() and it returns x(12), no variable is assigned
to capture that 12. So, in main() function, x remains as 11(
not as 12 ) . then it gets incremented and prints the value
12...

And, the Same story for other functions also.....
 
0
Selloorhari
 
 
Answer
The Output will be:

First output  : 12
Second output : 13
Third output  : 13
 
0
Civa
 
 
Question
What is meant by global static? why we have to use static 
variable instead of Global variable
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   L&T
I also faced this Question!!   © ALL Interview .com
Answer
Static is protected one and you cannot acess the variable 
in other files/functions.It is declared in the top of the 
file/function.The value retains tho,t the program.
 
0
Guest
 
 
Answer
Static remains throughout the program, however its scope is 
limited to that file alone. If a program consists of 
multiple files, you want a variable to be seen by the 
entire file and do not want that variable to be seen by the 
other files, then mark is as static

static int a; 

as a global variable
 
0
Abdur Rab
 
 
Question
write a code for large nos multilication (upto 200 digits)
Rank Answer Posted By  
 Question Submitted By :: Atul Kabra
This Interview Question Asked @   Persistent
I also faced this Question!!   © ALL Interview .com
Answer
#include<stdio.h>
#include <conio.h>
#include<string.h>
#include<alloc.h>
char * mul(char *, char);
char * add(char *, char *);
void main()
{

	char *no1=(char * )malloc(100);
	char *no2=(char *)malloc(100);
	char *q="0";
	char *p;
	int i=0,j=0,t=0,l=0;
	clrscr();
	printf("\n Enter the large no ");
	gets(no1);
	printf("\n Enter the second no ");
	gets(no2);

	while(l<strlen(no2))
	{
		p=mul(no1,no2[l]);
		for(j=1;j<=strlen(no2)-l-1;j++)
		strcat(p,"0");
		q=add(q,p);
		l++;
	}
	printf("\n Multiplication is %s",q);
	free(no1);
	free(no2);
}


char * mul(char *x, char ch)
{
	int i=0,j=0,t=0;
	char *p=(char *)malloc(300);
	char *a =(char *)malloc(300);
	strcpy(p,x);
	strrev(p);
	while(p[i]!='\0')
	{
		a[j]=(p[i]-48)*(ch-48)+t;
		t=a[j]/10;
		a[j]=(a[j]%10)+48;
		i++;
		j++;
	}
	if(t!=0)
	a[j]=t+48;
	else
	j--;
	a[j+1]='\0';
	strrev(a);
	free(p);
	return(a);
}
char * add(char *p, char *q)
{
	char *t=(char *)malloc(300);
	int i=0,j=0,x=0,a;
	strrev(p);
	strrev(q);
	while(p[i]!='\0' && q[i]!='\0')
	{
		a=(p[i]-48)+(q[i]-48)+x;
		x=a/10;
		a=a%10;
		t[i]=a+48;
		i++;
	}
	while(i<strlen(p))
	{
		a=(p[i]-48)+x;
		x=a/10;
		a=a%10;
		t[i]=a+48;
		i++;
	}
	while(i<strlen(q))
	{
		a=(q[i]-48)+x;
		x=a/10;
		a=a%10;
		t[i]=a+48;
		i++;
	}

	if(x!=0)
		t[i++]=x+48;
	t[i]='\0';
	strrev(t);
	return(t);
}



 
4
Atul Kabra
 
 
Question
difference between i++* and *++i
Rank Answer Posted By  
 Question Submitted By :: Khemnath Chauhan
This Interview Question Asked @   IBM
I also faced this Question!!   © ALL Interview .com
Answer
i++* is meaningless , do u want to ask *++i and *i++ diff ?

*++i -->  it increments the i then access the value poiting 
by i

*i++ --> it first access the value pointed by i , then 
increment the i ( increments pointer , not value)
 
0
Ravi
 
 
Answer
The postfix ++ and -- operators essentially have higher
precedence than the prefix unary operators. Therefore, *i++
is equivalent to *(i++); it increments i, and returns the
value which i pointed to before i was incremented. To
increment the value pointed to by i, use (*i)++ (or perhaps
++*i, if the evaluation order of the side effect doesn't
matter).

Ref:comp.lang.c FAQ list · Question 4.3
 
0
Gv_shreenivas
 
 
Answer
i++* wont work .... as for as i know.... it's meaningless

comin to *++i, i is a pointer holding an address so here ++ 
and * holds the same priority so we ll go for associativity 
of these operators. it's RIGHT to LEFT.

so , address in 'i' will get incremented and then if that 
address points to some value means it will print that value 
or else it will have garbage value



thank u
 
0
Vignesh1988i
 
 
Question
how to exchnage bits in a byte
b7<-->b0 b6<-->b1 b5<-->b2 b4<-->b3
please mail me the code if any one know to 
rajeshmb4u@gmail.com
Rank Answer Posted By  
 Question Submitted By :: Rajesh
This Interview Question Asked @   Honeywell , Hwaei
I also faced this Question!!   © ALL Interview .com
Answer
can be done by reversing the bits
 
0
Suresh
 
 
Answer
#include<stdio.h>
#include<conio.h>

int main()
{
	int i,number,count=0,a[100];

	printf("Enter the number\n");
	scanf("%d",&number);

	for(i=7;i>=0;i--)
	{
        if((1<<i) & number)
			a[count] = 1;
		else
			a[count] = 0;
		
		count++;
	}

	printf("Binary Value of the Given Number is:\n");
	for(i=0;i<=7;i++)
	{
		printf("%d",a[i]);
	}
	printf("\nReversed Binary Value of the Given Number is:\n");
	for(i=0;i<=7;i++)
	{
		printf("%d",a[7-i]);
	}
	printf("\n");
}
 
0
Santhi Perumal
 
 
Answer
You can swap swap bits using two ways
1 ) with for loop
2 ) using recursion

#include <stdio.h>

char swap_bits_in_byte ( unsigned char byte_2_swap )
{
	unsigned char swapped_byte = 0;
	int nloop = 0;
	for( nloop = 0; nloop < 8; ++nloop ) { 
		swapped_byte = swapped_byte << 1;
		swapped_byte |= ( byte_2_swap & 1 );
		byte_2_swap = byte_2_swap >> 1;
	}
	return ( swapped_byte );
}


unsigned char swap_bits ( unsigned char byte_2_swap, int 
n_size )
{
	unsigned char swapped_byte = 0;
	int bits = ( ( sizeof ( unsigned char ) * 8 ) - 1 );

	if ( bits == n_size ) {
		swapped_byte = ( byte_2_swap 
				& (unsigned char) ( pow ( 
2, n_size ) ) ) 
			? ( 1 << ( bits - n_size ) ) : 0;
	} else {
		swapped_byte = swap_bits ( byte_2_swap, 
n_size + 1 );
		swapped_byte |= ( byte_2_swap 
				& (unsigned char) ( pow ( 
2, n_size ) ) ) 
			? ( 1 << ( bits - n_size ) ) : 0;
	}
	return ( swapped_byte );
}

int main ( int argc, char* argv [] )
{
	unsigned char byte = 128 | 32;
	unsigned char swapped_byte = 0;

	swapped_byte = swap_bits_in_byte ( byte );
	printf ( "\n Un Swapped Byte :%d", byte );
	printf ( "\n Swapped Byte :%d", swapped_byte );

	swapped_byte = swap_bits ( byte, 0 );
	printf ( "\n Un Swapped Byte :%d", byte );
	printf ( "\n Swapped Byte :%d", swapped_byte );

}
 
0
Abdur Rab
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com