Companies
- Accenture
- Adobe
- Alcatel-Lucent
- Alten Calsoft Lab
- Amazon
- Amdocs
- Aricent
- Arris
- Broadcom Ltd
- Brocade
- CA Technologies
- Capgemini
- Cavium Networks
- CenturyLink
- Ciena
- Cisco
- Citrix
- Cognizant
- Comcast
- CSC (DXC Technology)
- Dell EMC
- Deloitte
- EFI
- Ericsson
- Extreme Network
- Genpact
- Gigamon
- Global Edge
- GlobalLogic
- Goldman Sachs
- Happiest Minds
- HCL Technologies
- Hewlett Packard Enterprise
- IDS Infotech
- Incedo
- Infinite C S
- IpInfusion
- J.P. Morgan
- Juniper Network
- L&T Technology Services
- MindTree
- MosChip Semiconductor
- NEC Technologies
- NIIT Technologies
- OLA
- One Access
- PayPal
- Paytm
- Qualcomm
- Radisys
- Redeem Software
- Reliance Jio
- Rolta India Limited
- Samsung
- Sasken
- Siemens
- Synopsys
- Tavant Technologies
- TCS
- Tech Mahindra
- Viasat
- Wipro
- XiLinx
Interview Questions and Answers :: C
char *p = "ciena"
char ar[] = "ciena"
strlen(p);
strlen (ar);
strlen (&ar);
5 5 5
No Tags on this question yet!
#include<stdio.h>
void strlength(char c[])
{
char *p=c;
int count=0;
while(*p!=NULL)
{
*p++;
count++;
}
printf("%d",count);
}
int main()
{
char c[]="prachi katarua";
strlength(c);
return 0;
}
No Tags on this question yet!
int x = 100;
printf("%d",!x);
0
No Tags on this question yet!
struct x
{
int p;
struct x *y;
char z;
char *b;
};
16
No Tags on this question yet!
Sizeof (NULL)
Strlen(NULL);
sizeof(" ")
4, 0, 1
No Tags on this question yet!
1. static int x;
main()
{
printf x
}
2.
fun()
{
static int x;
}
No Discussion on this question yet!
No Tags on this question yet!
P++;
is there any abnormality in the above line.
no
No Tags on this question yet!
Given String :: Malayalam
No Discussion on this question yet!
No Tags on this question yet!
static x;
int x
void main()
{
//Error if any
}
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
char *p = "Hello"
char *q;
char a[10] = {0};
char b;
printf("% %d %d %d ", sizeof(p),sizeof(q),sizeof(a),sizeof(b));
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
1. struct
{
int a;
int b;
char c;
}
2. struct
{
int a;
int b;
char c;
char *d;
}
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
int a=2;
if (a=0)
printf("a is non zero");
elseif(a>0)
printf("a is +ve");
else
printf("a is zero");
it will not give compilation error, the if condition is proper,
it will be executed as like value "0" will be assigned to a and then it will check the if condition.
basically when we put any condition in if condition it check 0/1 like if (p==5) if p value is 5 then for this condition it will be something like if(1) in other scenario like if p is not equal to 5 then statement will be like if(0).
Such thing is happening in the given partial code, the last statement will be like if (0), which is false and control will go to else part. so that answer will be a is zero. However if you put a=5 then it will print a i non zero.
No Tags on this question yet!
int n;
int a=0;
scanf("%d",&a);
n=a;
while (n>2)
{
if(n%2!=0)
{
n=n/2;
if (n>=2)
{
printf("%d is prime number", a);
break;
}
}
else
{
printf("%d is not prime number", a);
break;
}
}
No Tags on this question yet!
int a[]= {2,3,4,7,9,3,8,9,6,8,7,9};
int i=0;
int j=0;
int flag=0;
int n=12;
static int incr;
for (i=0;i
for(j=0;j
if (a[i]==a[j])
{
incr++;
if (incr>=2)
flag=1;
}
}
if (flag)
printf("\n %d is repeated %d times in this array", a[i],incr);
flag=0;
incr=0;
}
No Tags on this question yet!
int a[]= {2,3,4,7,9,3,8,9,6,8,7,9};
int i=0;
int j=0;
int n=12;
int sum=12;
for (i=0;i
for(j=++i;j
if ((a[i]+a[j]) == sum)
{
printf("\n %d + %d positions of sum %d", a[i], a[j], sum);
continue;
}
}
}
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
struct xx {
char a;
int b;
};
printf("%d", sizeof(struct xx));
8 in case of union it will be 4Â
No Tags on this question yet!
Input: 10 01 11 00 Output: 01 10 11 00
#include
unsigned int swapBitsInPair(unsigned int x)
{
/*
extracts the high bit position and shifts it to the low bit position.
similarly extracts the low bit from each pair and shifts it to the high bit position.
The two parts are then combined using bitwise OR
*/
return ((x & 0b10101010) >> 1) | ((x & 0b01010101) << 1);
}
int main()
{
unsigned int x = 156;
printf("%d", swapBitsInPair(x));
return 0;
}
No Tags on this question yet!
No Discussion on this question yet!
No Tags on this question yet!
The memcpy function is used to copy a block of data from a source address to a destination address. The prototype for memcpy is
void * memcpy(void * destination, const void * source, size_t num);
#include
#include
void myMemCpy(void *dest, void *src, size_t n)
{
// Typecast src and dest addresses to (char *)
char *csrc = (char *)src;
char *cdest = (char *)dest;
// Copy contents of src[] to dest[]
for (int i=0; i
}
int main()
{
char csrc[] = "broadcom interview";
char cdest[100];
myMemCpy(cdest, csrc, strlen(csrc)+1);
printf("Copied string is %s", cdest);
return 0;
}
No Tags on this question yet!