| Back to Questions Page |
| |
| Question |
write a c program to find biggest of 3 number without
relational operator? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Wipro |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | void main()
{
int a = 5;
int b = 7;
int c = 2;
int res;
res = (int)(a/b)?a:b;
res = (int)(res/c)?res:c;
printf("big num = %d",res);
}  |
| Manjeeth |
| |
| |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
int a,b,c;
clrscr();
printf("enter any three no.s");
scanf("%d%d%d",&a,&b&c);
if(a>b&&a>c);
{
printf("a is biggest");
}
else if(b>a&&b>c)
{
printf("b is biggest");
}
else
printf("c is biggest");
getch();
}  |
| Priyanka |
| |
| |
| Question |
void main(int argc,char *argv[],char *env[])
{
int i;
for(i=1;i<argc;i++)
printf("%s",env[i]);
} |
Rank |
Answer Posted By |
|
Question Submitted By :: Msrambabu |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | i need answer and explation to env function  |
| Msrambabu |
| |
| |
|
|
| |
| Answer | It’s interesting.
This program reads environmental variables. It is as same as
"env" command in unix.
But program is not proper. i.e. if you pass n arguments to
program, then it reads n environmental variables only.
Try this program
void main(int argc,char *argv[],char *env[])
{
int i;
if (2 <=argc){
for(i=0;i<atoi(argv[1]);i++)
printf("\n%s",env[i]);
}else printf("\nPlease enter no. of env variables you want
e.g. 'a.out 5'\n");
}  |
| Gaurav |
| |
| |
| Question |
how to display 2-D array elements in spiral |
Rank |
Answer Posted By |
|
Question Submitted By :: Sridhar |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #define subscript 5
void spiral()
{
int a[subscript][subscript],i,j,k,l,m,p,q;
p=q=subscript ;
for(i=0;i<p;i++,p--)
{
for(j=i;j<n-1;j++)
printf("%d",a[i][j]);
for(k=i;k<j;k++)
printf("%d",a[k][j]);
for(l=k;l>i;l--)
printf("%d",a[l][k]);
for(m=k;m>i;m--)
printf("%d",a[i][m]);
}
if(q%2!=0)
printf("%d",a[j][j]);
}  |
| Raj |
| |
| |
| Question |
What is meaning of "Void main" in C Language. |
Rank |
Answer Posted By |
|
Question Submitted By :: Kundan |
| This Interview Question Asked @ TCS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | The main function returns a void value .  |
| Madhusmita Mishra |
| |
| |
| Answer | The main function does not return any information to the
operating system.  |
| Sonali Panda [Student] |
| |
| |
| Answer | The meaning of void is nothing thats why when the function
cant return any value than at that time we declair it as a void
void main means main does not return any value  |
| Piyush Mani Tiwari [Student] |
| |
| |
| Answer | void mean no return type. and main does not return any value so we use void main .  |
| Rohit [Student] |
| |
| |
| Answer | void main means does not return valu at exicution time
mens return (0)  |
| Ashturkar Sameer [Student] |
| |
| |
| Answer | void means simply it's return zero(0)  |
| Sameer Ashturkar [Student] |
| |
| |
| Answer | by default main return int to its environment but when we
declare void main it means it will not return any value  |
| Raj [Student] |
| |
| |
| Answer | void main() is a main function in c language.void means
nothing return any value.this function is used to execute our
program.without main(), program can compile but not run.  |
| Mohit Giri [Student] |
| |
| |
| Question |
c programming of binary addition of two binary numbers
|
Rank |
Answer Posted By |
|
Question Submitted By :: Soham |
|
I also faced this Question!! |
© ALL Interview .com |
| 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<stdio.h>
#include<conio.h>
#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  |
| Vignesh1988i |
| |
| |
| 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 |
| |
| |
| Answer | #include<stdio.h>
#include<conio.h>
void main()
{
char c,d;
int a;
clrscr();
printf("enter character");
scanf("%c",&c);
a=c;
d=a;
printf("the ascii code is:%d",a);
printf("the character is:%c",d);
getch();
}  |
| Harish Solanki |
| |
| |
| 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 |
| |
| |
| Answer | actually, in C, every keyword has some specific value some
specific meaning and those meanings of keywords are already
been stored in header files like
<stdio.h>,<conio.h>,<math.h> etc.... so to make computer
understood the meaning of printf, scanf like keywords, we
have to use header files in begining of the prog... and #
is a preprocessor.... this tells computer that now u be
ready to write a prog...
this is wat i think.... though i dnt hav technical
knowledge still i tried to xplain.....  |
| Priyanka [Student] |
| |
| |
| Answer | it is library file access,which contains information that
must be included in the program when it is compiled.  |
| Pandya Umesh C [Student] |
| |
| |
| 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 |
| |
| |
| Answer | I am totally satisfied with your above explanation except
last one.
i.e. Char *p="literal";
So, i want to mention yes this will work.
Explanation: *p++.
Here we have post increment.
Postfix increment/decrement have high precedence, but the
actual increment or decrement of the operand is delayed (to
be accomplished sometime before the statement completes
execution).
value of printf("\nstr=%c\n",*p++) will be 'l', but before
complete execution of this statement p will point to string
"iteral" as p got incremented.  |
| Gaurav |
| |
| |
| 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 |
| |
| |
| Answer | main()
{
int i;
printf("Enter Number :");
scanf("%d",&i);
if(i&(i-1))
printf("Not atwo power");
else
printf("Two 's Power");
}  |
| Veerendra Jonnalagadda |
| |
| |
| Answer | main()
{
int i;
printf("Enter Number :");
scanf("%d",&i);
if(i&(i-1))
printf("Not atwo power");
else
printf("Two 's Power");
}  |
| Veerendra Jonnalagadda |
| |
| |
|
| |
|
Back to Questions Page |