Shobhit
BAN USER- 0of 0 votes
AnswersGiven an unsorted array.
- Shobhit in United States
With each number, we can associated a sum which is equal to the sum of all the numbers, less than the current number.
We've to find the total sum of all those numbers.
e.g. unsorted array :1, 5, 3, 6, 4.
for a[0]=1, sum[0]=0
for a[1]=5, sum[1]=1
for a[2]=3, sum[2]=1
for a[3]=6, sum[3]=1+5+3
for a[4]=4, sum[4]=1+3
total sum =sum[0]+sum[1]+sum[2]+sum[3]+sum[4] = 15| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven the array of digits, you have to calculate the least positive integer value of the expression that could NOT have been received by you.
- Shobhit in United States
The binary operators possible are *, +, -, / and brackets possible are ( and ). Note that / is an integer division i.e. 9/5 = 1.
For ex- 6 6 4 4 the answer is 18
1 = 6 /6 + 4-4
2 = 6/6 + 4/4
3 = 6 +( 6/4) -4
4 = (6+6+4) / 4
……..
18 cannot be formed| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
Answerssearch an element in sorted 3D Array .(Sorted in all the 3 directions) .
- Shobhit in United States
best time complexity (less than O(n^2))| Report Duplicate | Flag | PURGE
Amazon C - 0of 0 votes
Answersgiven a string . find the first unique character .
- Shobhit in United States
time complexity : O(logn) , space O(1)| Report Duplicate | Flag | PURGE
Amazon C - -1of 1 vote
AnswersWhat is the main use of interface ? Provide a real time example that shows it
- Shobhit in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersWhat is the importance of overriding in java ? Give any real life example . How is it increasing the code reusability and robustness .? Cant we create new function instead of override ? What difference will it make ?
- Shobhit in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
#include<stdio.h>
int main()
{ double i=0;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
if(i==0.7)
printf("Equal : i=0.7\n");
i+=0.1;
if(i==0.8) printf("Equal : i=0.8\n");
else printf("Not Equal : i=0.8\n");
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerschar *p="havfun" , *q ="havfun" ;
- Shobhit in United States
are these two pointers equal ? If yes , then explain .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersCompare the behavior of both the programs :
- Shobhit in United States
(1) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=1;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}
(2) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=i;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIs there no null character after "abcd" string in the following declaration .
- Shobhit in United States
char *p="abcd";| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
int main()
{
struct{int a:1;
int b;
}obj;
obj.b=6;
obj.a=1;
printf("%d %d",obj.b,obj.a);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIn the following declaration ptr is
- Shobhit in United States
far * near * huge * ptr;
1. far
2. huge
3. near
4. all of the above| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit in United States
#include<conio.h>
int main()
{
int i;
i=5;
i=++i/i++;
printf("%d",i);
getch();
}
Explain the output .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit in United States
int main()
{
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut: // There should be an error .
printf("NONE\n");
}
return 0;
}
Check the output .. and explain why is it not showing an error ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswrite a C program which generates random numbers between 1-100 (inclusive) on mouse movements.
- Shobhit in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
#include<stdio.h>
#define power(a) #a
int main()
{
printf("%d",*power(432));
getch();
return 0;
}| Report Duplicate | Flag | PURGE
C
There's an unusual behavior with the printing of *p .Following will be the output of *p :
Enter the pointer -------> Output in printf (*p)
1 -----------1
3 ----------- 3
5 ----------- 5
9 ----------- 9
10 ----------- 16
11 ----------- 17
14 ----------- 20
20 ----------- 32
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i=0,a[]={1,5,7,9,12};
int j=0,b[]={3,8,14,15,19,20};
int k=0,c[]={5,12,17,23,25,26,30};
int ie=(int)sizeof(a)/sizeof(a[0]);
int je=(int)sizeof(b)/sizeof(b[0]);
int ke=(int)sizeof(c)/sizeof(c[0]);
int t=1;
while(1)
{
if(a[i]+b[j]==c[k])
{
printf("a[%d]=%d , b[%d]=%d , c[%d]=%d \n",i+1,a[i],j+1,b[j],k+1,c[k]);
j++;
k++;
}
else if(a[i]+b[j]>c[k])
{
if(a[i]>b[j])
while(1)
{ i--;
if(a[i]+b[j]<c[k])
{ k++;break; }
else if(a[i]+b[j]==c[k]) break;
}
else {
while(1)
{ j--;
if(a[i]+b[j]<c[k])
{ k++;break; }
else if(a[i]+b[j]==c[k]) break;
}
}
}
else {
if(a[i]>=b[j])
j++;
else i++;
}
if(i>=ie||j>=je||k>=ke)
break;
}
return 0;
}
Repwilliamland1990, Associate at Advent
Gifted in donating shaving cream worldwide. Crossed the country getting my feet wet with the elderly in Salisbury, MD. Have ...
RepLizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
RepNaomiMoore, abc at A9
I have wide experience with commercial negotiations and international transactions.Advising on the incorporation and related shareholder agreements for a ...
RepRomiTerry, Member Technical Staff at Cleartrip.com
Romi , a Dynamic Property Manager highly regarded for increasing and maintaining a high level of occupancy adhering to all regulations ...
My mistake ..its working fine on Ubuntu ..
- Shobhit July 01, 2012