Engineer Interview Questions | Glassdoor.co.in

# Engineer Interview Questions

91,288

Engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

17 Jun 2010
 How many rotations does earth make on its axis while going around the sun for one year.10 AnswersDepends on the Leap Year or non Leap Year 365 for Non Leap Year 366 for Leap YearThe question is flawed. It should either ask how many days earth takes in one revolution around sun, or how many days are in a year. The leap year is something imaginary humans have concocted to make the calendars look good. You can't say once is 4 years earth takes an extra day to go around the sun.It's to get you thinking about casting... the calender is a double casted to an int!Show more responses365.25 / yr I wouldn't say 365/ 366 leap year. Jain has a point.^It's either 364.25 or 366.25 depending on whether the earth spins in the same direction as it goes around the sun or not (I don't remember which it is and can't deduce it from the information that's available to me without looking it up). Imagine if the Earth did not spin at all on its axis so it would seem as if a year was equivalent to one day. It will take the Earth rotating either 264.24 or 366.25 times depending on the direction to seem like the 365.25 days that it does take.Every year it takes 365.25 rotations but while making calendar we ignore that 0.25 for 3 years and add an extra day in 4th year.365.25 is WRONG!!! Actually Anonymous is right! Just think about this (lay it out on your desk):
• How many days would there be if the earth would not revolve around its axis?
• How many days would there be if it turned once around it's axis?
• Now do again one, change the direction the earth revolves it's axis, but keep going the same direction around the sun ...
The concrete right answer is 366.25 Here you find details on the exact number (with other proof): :)This question makes no sense.It's other way around, only when earth complete one round, we call it a year. To make human calculations easy, we introduced leap yrs. One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

### Software Engineer at WebKul was asked...

19 Feb 2016
 code for this pattern: Here n =6 (no. of astericks in the first line of pattern).This can be of any range for n = 1 to 100 (inclusive) ****** **** ** * ** **** ******9 Answers#include int main() { int q,p,i,j,k,n; scanf("%d",&n); for(i=0;i0) { printf(" "); q--; j++; } else printf("*"); } printf("\n"); p--; } return 0; }#include int main() { int q,p,i,j,k,n; scanf("%d",&n); for(i=0;i0) { printf(" "); q--; j++; } else printf("*"); } printf("\n"); p--; } return 0; }#include int main(){int q,p,i,j,k,n;scanf("%d",&n);for(i=0;i0) { printf(" "); q--; j++; } else printf("*"); } printf("\n"); p--; } return 0; }Show more responses// Full version of code #include int main() { int n=6,i,j,s,t,temp,l; if(n%2==0){ l=2; }else{ l=3; } temp = (n/2)+1; t=n; for(i=1;i1;i--){ for(s=2;sint main() { int n,s; printf("enter a number\n"); scanf("%d",&n); s=n; for(int i=1;i<=n;i++) { for(int j=1;j<=s;j++) { printf(" "); } s++; for(int k=1;k<=2*(n-i)-1;k++) { printf("*"); } printf("\n"); } }code of this pattern #include #include int main() { int n=3,i,j,k; for(i=n;i>=1;i--) { for(j=1;j<=n-i;j++) printf(" "); for(k=1;k<=2*i-1;k++) printf("*"); printf("\n"); } for(i=2;i<=n;i++) { for(j=1;j<=n-i;j++) printf(" "); for(k=1;k<=2*i-1;k++) printf("*"); printf("\n"); } return 0; }int main() { int i,j,n,s,m,o; scanf("%d",&n); for(i=(n/2)+1;i>=2;i--) { for(s=1;s<=((n/2)+1)-i;s++) { printf(" "); } for(j=1;j<=(2*i)-2;j++) { printf("*"); } printf("\n"); } for(i=1;i<=(n/2)+1;i++) { if(i!=1) { for(s=1;s<=((n/2)+1)-i;s++) { printf(" "); } for(j=1;j<=(2*i)-2;j++) { printf("*"); } } else { for(m=1;m<=(n-2)/2;m++) { printf(" "); } for(o=1;o<=1;o++) { printf("*"); } } printf("\n"); } return 0; }import java.io.*; class GFG { static void pattern(int n) { int i, j; // This is upper half of pattern for (i = 1; i (n - j + 1)) System.out.print(" "); else System.out.print("*"); } System.out.println(""); } // This is lower half of pattern for (i = 1; i <= n; i++) { for (j = 1; j <= (2 * n); j++) { // Right Part of pattern if (i < j) System.out.print(" "); else System.out.print("*"); } System.out.println(""); } } // main function public static void main(String[] args) { pattern(7); } } // This code is contributed by vt_mdef fun(n): print("*"*n,end="") print("") px=int(n/2) for x in range(2,n,2): for y in range(0,n-x): print("*",end="") print("") print("*",end="") print("") for x in range(2,n+1,2): for y in range(0,x): print("*",end="") print("") fun(6)

### Senior Software Engineer at Amazon was asked...

13 Oct 2012
 You are given a fixed number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps. Now given an amount for sending a parcel, you should design an algorithm to come out with the minimum number of stamps that should be used for attaining that amount. For example, if the parcel costed 30 rupees, it could be attained using one 20 rupee stamp and one 10 rupee stamp OR using three 10 rupee stamps OR using one 20 rupee stamp and two 5 rupee stamps OR using one 10 rupee stamp and four 5 rupee stamps OR using two 10 rupee stamps and two 5 rupee stamps. However, the minimum number of stamps is the case of one 20 rupee stamp and one 10 rupee stamp where only two stamps are used. The case where no solution is possible should also be handled, for example, a parcel amount of exactly 33 rupees cannot be attained.9 AnswersThe solution is attained using dynamic programming. The basic idea is that the minimum number of stamps used for attaining an amount x, is 1+minimum of (minimum number of stamps for attaining x-5, minimum number of stamps for attaining x-10, minimum number of stamps for attaining x-20,minimum number of stamps for attaining x-50). You can try to solve this first by assuming that an unlimited number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps are available. And then you can take into account that only a fixed number of these stamps are available.And what is the time involved to get this done? I really liked the question.Simple to read but involves good amount of logic. I ve written down the algorithm but i believe i took more time than i initially thought i would take.I understand what the interviewer is trying to test and I know how to solve it, but what about more realistic scenario where parcel postage cost would be beyond given values like 3 units of currency or 37 units of currency.Show more responsesIn this specific case, dynamic programming is overkill. There's a better optimal substructure here: The stamp with greatest value less than parcel cost minus stamp values already committed minimize the total of stamps.1. find the stamp <= cost from highest stamp cost 2. num of found_stamp = found_stamp/cost, rem_stamp = found_stamp % cost 3. Do 1, then 2 until rem_stamp ==0 (done) or rem_stamp < least stamp available (not possible case)In the previous ans, after step 3 if rem_stamp !=0, go back to step 1, find next_stamp < cost (but smaller than value of found_stamp in previous iteration)i=0; boolean solPossible = false; do { if(cost % notes[i] == 0) solPossible = true; else i++; } while(!solPossible && (ivoid sendParsal(int cost) { int[] avlstm={50,20,10,5}; int i=0; while(cost>=5) { while(cost>=avlstm[i]) { System.out.println(avlstm[i]); cost=cost-avlstm[i]; } i++; } if(cost!=0) { System.out.println("Solution not possible."); } }void Foo(int cost) { if (cost % 5 != 0) Console.WriteLine("Not possible"); else if (cost stampCosts = new List() { 50, 20, 10, 5 }; int count = 0; while (cost > 0) foreach (int stampCost in stamptCosts) if (cost >= stampCpst) { cost -= stampCost; Console.WriteLine("Stamp: " + stampCost); count++; break; } } Console.WriteLine("Count: " + count); }

### Software Engineer at Sirkus Systems IT Services was asked...

3 Nov 2017

16 Jun 2012
 Puzzle question: A Floating ship contains 1 stone , If I drop that stone in sea,,What will happen with water level??? Is it increase or decrease n why?? 8 Answersafter long discussion... concluded that it will decrease..nothing will happeneven i feel nothing will happen to the level.plz explain the ans.Show more responsesLevel will decreaseYes It will decrease, as per Arcemedes object with same masses upward buoyant force is higher for object which has larger volume area, so when stone is on boat, it increase boat weight and so upward buoyant force is high for boat, but when It is thrown its upward buoyant force is less with compare to when it is on boat, and upward buoyant force of boat also decreases because stone is thrown, so ultimately upward buoyant force decrease than means decrease in water level, hope it will help :)I think it will decrease as when the stone is on the boat the volume of water it displaces is more than when it is thrown into the sea. as more volume of water is displaced the more water level goes up we can say that water level will be higher when the stone is on the boat.The amount of water displaced is equal to the mass of the object immersed. Since the net mass of objects in water is the same, the same amount of water needs to be displaced. Hence no change in the water level.It solely depends upon the density of stone. If density of stone is higher than boat material then it will increase the water level .. Otherwise decrease

### Assistant Software Engineer at Nucleus Software Exports was asked...

16 Apr 2016
 Q1. Print the 1st and 100th element of Fibonacci series together, 2nd and 99th element and so on. Q2. Print the following pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25. (Condition was using one for loop)8 AnswersSince both the question required 2 for loops. A1. I created a function fibo() that returns finbonacci nth element using recursion . And run a for loop from 1 to 100 and print the fibo(i) and fibo(100-i) [i running from 1 to 100]. A2. I created a recursive call to a function that acted as the outer loop and a base condition to exit. and in the else part do the printing using a single for loop.For question 2: //here i = 5 void print_sequence(int i) { int num = 1; int count = 0; for(;num= num) { count = 0; num++; cout<For question 2: //here i = 5 void print_sequence(int i) { int num = 1; int count = 0; for(;num= num) { cout=num) { count = 0; num++; cout<Show more responses#include using namespace std; int main() { int j=1; for(int i=1; i<=10; ){ cout << j*i << " "; if(j == i){ i++; j=0; cout << endl; } j++; } return 0; }#include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int i; cin >> i; int j=1; for(int k=1;kj) { cout << endl; j++; k=0; continue;} else cout << j*k << " "; } }For the fibonacci, the best way wud be to create an array of fibonacci numbers from 1-100 using dp which uses just one for loop. and then print sumultaneously the following asked numbers.#include using namespace std; main() { int i,j; for(i=1,j=1;i<=5;) { cout<import java.util.Scanner; import static java.lang.System.out; class PA{ public static void main(String...args){ int a=1,i=1,j=1; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); while(a!=0){ out.print(i+" "); if(i==(j*j)){ out.println(""); j++; i=j; } else{ i=i+j; } a++; if(i==(n*n)) {out.print(i); break;} } } }

### Hardware Engineer at e-con Systems was asked...

18 Jul 2017
 In puzzle test , a small town, there are three temples in a row and a well in front of each temple. A pilgrim came to the town with certain number of flowers. Before entering the first temple, he washed all the flowers he had with the water of well. To his surprise, flowers doubled. He offered few flowers to the God in the first temple and moved to the second temple. Here also, before entering the temple he washed the remaining flowers with the water of well. And again his flowers doubled. He offered few flowers to the God in second temple and moved to the third temple. Here also, his flowers doubled after washing them with water. He offered few flowers to the God in third temple. There were no flowers left when pilgrim came out of third temple and he offered same number of flowers to the God in all three temples. What is the minimum number of flowers the pilgrim had initially? How many flower did he offer to each God?8 AnswersTwo students appeared at an examination. One of them secured 9 marks more than the other and his marks was 56% of the sum of their marks. The marks obtained by them are:Pilgrim has 7 flowers initially and he offers 8 on each temple :P ;-)42 and 33Show more responsesThe pilgrim would enter with 7 flowers and would have worshipped each god with 8 flowers each.The pilgrim would enter the village with 7 flowers and would have worshipped each god with 8 flowers each.Solve the equation: 2x-y=2y-z=2zexplain me how to findAny no of flowers which is a multiple of 7..7x and offers 8x

25 Sep 2018