| Back to Questions Page |
| |
| Question |
If we give two names then this displays the connection
between the two people. It is nothing but flames game |
Rank |
Answer Posted By |
|
Question Submitted By :: Gita |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | main()
{
char name1[20],name2[20];
int a,b,i,j,c;
clrscr();
printf("Enter the first name:\t");
gets(name1);
printf("Enter the second name:\t");
gets(name2);
a=strlen(name1);
b=strlen(name2);
for(i=0;i<=a;i++)
{
for(j=0;j<=b;j++)
{
if(name1[i]==name2[j])
{
a--;
b--;
}
}
}
c=a+b;
i=c%6;
switch(i)
{
case 0:printf("Friends");
break;
case 1:printf("lovers");
break;
case 2:printf("Ansisters");
break;
case 3:printf("marriage");
break;
case 4:printf("enemies");
break;
case5:printf("sisters");
break;
}
getch();
}  |
| Gita |
| |
| |
| Question |
please give me answer with details
#include<stdio.h>
main()
{
int i=1;
i=(++i)*(++i)*(++i);
printf("%d",i);
getch();
} |
Rank |
Answer Posted By |
|
Question Submitted By :: Sv.mallesh |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Answer is :64  |
| Gita |
| |
| |
| Answer | ++i * ++i * **i
->
2 3 4
now started this way
<-
4 * 4 * 4
=64  |
| Vaseem |
| |
| |
|
|
| |
| Answer | The precedence of the operations, should be (reading from
left to right in the equation)
++i <first ++i i=2>
++i <second ++i i=3>
* <first product yields 3*3=9>
++i <third ++i i=4>
* <giving the second product 3*4=36>
Thus, the first product (*) is computed before the third ++i
is computed. Once the first product is completed, i is
incremented to i=4 and the second product can occur now.
Now, if you add some parentheses to the expression giving
++i * (++i * ++i)
then you will get 64, as the other replies suggest. Tracing
through the order of operations in this one
++i <first ++i i=2>
++i <second ++I i=3>
++i <third ++I i=4>
* <the product in the parentheses now yields 4*4=16>
* <the first * yields 4*16=64>
Here, the first product (*) cannot occur until it knows the
result of the product in the parenthesis. Thus, all three
increments must occur before the multiplications take place.  |
| Joe |
| |
| |
| Question |
WAP to convert text into its ASCII Code and also write a
function to decode the text given? |
Rank |
Answer Posted By |
|
Question Submitted By :: Rakesh Sharma |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | to convert it into ascii code just assign the entered
variable to a int(integer)variabe e.g.
int i=a
which on printing i will gie 64 as the o/p  |
| Shashank Mahabdi |
| |
| |
| Question |
What is the relation between # and include<stdio.h> |
Rank |
Answer Posted By |
|
Question Submitted By :: Kundan |
| This Interview Question Asked @ HCL |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | include<stdio.h> means we include standard input and output
functions code we does not write any thing about library
functions .h means header file if we include tis header
file then we place # before the include<stdio.h> this is c
syntax.  |
| Gita |
| |
| |
| Question |
Given a single Linked list with lakhs of nodes and length
unknown how do you optimally delete the nth element from the
list? |
Rank |
Answer Posted By |
|
Question Submitted By :: Arshu22 |
| This Interview Question Asked @ Oracle |
|
I also faced this Question!! |
© ALL Interview .com |
| 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  |
| Vignesh1988i |
| |
| |
| Question |
Why cann't whole array can be passed to function as value. |
Rank |
Answer Posted By |
|
Question Submitted By :: Dileep_aum |
|
I also faced this Question!! |
© ALL Interview .com |
| 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.....  |
| Vignesh1988i |
| |
| |
| Question |
differentiate between
const char *a;
char *const a; and
char const *a;
|
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
| This Interview Question Asked @ HCL , Tcs, Gd |
|
I also faced this Question!! |
© ALL Interview .com |
| 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  |
| Vignesh1988i |
| |
| |
| Question |
what is the difference between these initializations?
Char a[]=”string”;
Char *p=”literal”;
Does *p++ increment p, or what it points to?
|
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| 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  |
| Vignesh1988i |
| |
| |
| Question |
Given an unsigned integer, find if the number is power of 2? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
void powerOfTwo(int number)
{
if(!(number & number-1) && number)
printf("\nthe number is a power of 2\n");
else printf("\nThe number is not a power of 2\n");
}
int main()
{
powerOfTwo(32); //power of 2
powerOfTwo(22); //not a power of 2
return 0;
}  |
| Coder |
| |
| |
| Question |
write a program that print itself even if the source file is
deleted? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | int main(s){
s="int main(s){s=%c%s%c;printf(s,34,s,34);return 0;}";
printf(s,34,s,34);
return 0;
}  |
| Bitan |
| |
| |
| Question |
Give a method to count the number of ones in a 32 bit number? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
#include<conio.h>
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  |
| Vignesh1988i |
| |
| |
| Question |
write a “Hello World” program in “c” without using a semicolon? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | sir, i can not give the answer of this question.  |
| Prashant |
| |
| |
| Answer | int main()
{
if(printf("hello world"))
}
For if statement compiler does not expect semi colon.  |
| Rajeev |
| |
| |
| Answer | int main(){
if(printf("Hello World")){}
}  |
| Bitan |
| |
| |
| Question |
write a program that finds the factorial of a number using
recursion? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
{
int factorial(int);
int n;
clrscr();
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
getch();
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}  |
| Anandi |
| |
| |
| Question |
swap two integer variables without using a third temporary
variable? |
Rank |
Answer Posted By |
|
Question Submitted By :: A. Sujatha |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | the best way what i choose is that : if x=89 , y=-88
x^=y^=x^=y;
this line will swap the above numbers......
thank u  |
| Vignesh1988i |
| |
| |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("\n ENTER 2 VALUES : ");
scanf("%d%d",&a,&b);
printf("\n THE VALUES BEFORE SORTING : %d,%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\n THE VALUES AFTER SORTING : %d,%d",a,b);
getch();
}  |
| Sidhartha |
| |
| |
|
| |
|
Back to Questions Page |