Software engineer ii Interview Questions in India | Glassdoor.co.in

# Software engineer ii Interview Questions in India

99,078

software engineer ii interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

23 Apr 2010

17 Apr 2018
hai

16 Feb 2016

4 Oct 2017

24 Dec 2015

20 Aug 2017

### PHP Developer at WebKul was asked...

11 Sep 2016
 Q1. Draw star pattern like. n=1. * n=2. ** * n=3. *** ** * n=4 **** *** ** * n=5. ***** **** *** ** *16 Answers#include int main() { int n=10,i,j,s,sum=1,l,k; for(k=1;k=1;i--){ l=sum-i; for(s=1;s<=l;s++){ printf(" "); } for(j=1;j<=i;j++){ printf("*"); } l=l+1; sum=l; printf("\n"); } return 0; }#include int main() { int n,i,j,k,l=1; for(n=1;n=1;i--) { if(n==3) {for(k=i-1;k>=1;k--) printf(" "); } if(n==4) { if(i>2) {for (k=i-1;k>=l;k--) printf(" "); } l++; } if(n==5) { if(i>2) { for(k=i+2;k>=l-2;k--) { printf(" "); } l++; } } for(j=i; j>=1;j--) { printf("*"); } printf("\n"); } printf("\n"); } }import java.util.Scanner; class New { public static void main(String ... args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); int p=n-2; for(int i=1;i<=n;i++) { for(int j=1;j<=(p*(p+1))/2;j++) System.out.print(" "); p--; for(int k=1;k<=n-i+1;k++) System.out.print("*"); System.out.println(""); } } }Show more responsesspace is 1+2+3+...(n-2) Code is as follow: public class Pattern { public static void main(String ...args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=n;i>=1;i--) { for(int j=1;j<=(i-1)*(i-2)/2;j++) System.out.print(" "); for(int j=1;j<=i;j++) System.out.print("*"); System.out.println(); } } }public class Pattern11 { public static void main(String[] args) { int number = 6, count = number; for (int i = 1; i <= number; i++) { for (int j = 1; j <= (number - i) + count; j++) { if (j <= number - i) { System.out.print(" "); } else { System.out.print("*"); } } count = count - 1; System.out.println(); } } }int main() { int i,j,s,n; scanf("%d",&n); for(i=1;i<=n;i++) { for(s=1;s<=n-i;s++) { printf(" "); } for(j=1;j<=(n+1)-i;j++) { printf("*"); } printf("\n"); } }x=int(input()) for i in range(x,0,-1): for k in range(i-1,0,-1): print(" ",end="") for j in range(i,0,-1): print("*",end="") print()#include int main() { // Input n from user and make h,s,n all equal // Input 5 is taken randomly it can be any thing int h = 5; int n = 5; int s ; s=n; for(int u = 0; u 0 ; s-- ) { printf(" "); } for(int s = h ; h>0 ; s-- ) { printf("*"); h--; } printf("\n"); h = n - 1; }import java.util.*; import java.io.*; class Starpattern5 { public static void pattern(int n) { int i,j; for (i=n;i>=1;i--) { for (j=1;j<=((2*i)-1);j++ ) { if (jimport java.util.*; import java.io.*; class Starpattern5 { public static void pattern(int n) { int i,j; for (i=n;i>=1;i--) { for (j=1;j<=((2*i)-1);j++ ) { if (j2){ for(\$j=3;\$j= 2){ echo " "; } \$count--; for(\$k=\$val;\$k>=\$i;\$k--){ echo "*"; } echo "
"; } } ?>Import java.util.Scanner; Class web { Static void web(int n) { for(int i=n;i>=1;i--) { for(int j=0;j<=n;j++) System.out.print("*"); } System.out.println("\t"); } } Public static void main(String args[]) { Scanner sc =new Scanner(System.in); Int n=sc.nextInt(); Web(n); } }#in python n= int(input('enter the max no.')) for i in range(n): print('*'*(n-i), end=' ')Show more responsesn=int(input("")) for i in range(n+1): print(" "*(n-i-1 )+"*"*(n-i))=(\$n+1-\$i) && \$j One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

19 Mar 2009
 Come out with an algorithm for getting the column number provided the column name in a excel sheet and vice versa. Excel has a naming convention of A,B..Z,AA,AB,AC..ZZ,AAA... This had to be converted to the column numbers. A will be 1 and AA will 27.. Also the algorithm to find the name provided column number.13 AnswersIts conversion from decimal to base 26 with some exception like there is nothing maps to zero. There might be a better way to do it.void printColumn(uint32_t col) { col --; int div = 26; int add = 26; while( col / div ) { div *= 26; } div /= 26; while( div != 1) { printf("%c", (col / div) + 'a' - 1); col = col % div; div /= 26; } printf("%c\n", col + 'a'); }Opps above does not work after ZZ. The correct one is void printColumn(uint32_t col) { int a = 26; int denominator = 1; while(a 0; i /= 26) low += i; // if value is lower than lower bound, decrease quotient by one if( denominator != 1 && col < (quotient * denominator + low) ) { quotient --; } printf("%c", quotient - 1 + 'A'); col = col - denominator * quotient; denominator /= 26; } }Show more responsesLet the size of the string asked is 3 e.g GHD . The formula to this : [ 26+26^2+...+ 26^(size-1) + (LetterIndex-1)*{26^(size-1)+....+(LetterIndex-1)*26}+Index ]In the code the above formula will use recursion to find the column number.The answer can be as simple as finding the first combination of number * i such that it is less then xcelcolvalue; ie repeat this till xcelColValue >= 26 ( 0 = 26){ int i = 1, num = 1; while((num * (i + 1)) 26){ i = 1; num++;} else i++; xcelNum -= num*i; sb.append((char) i); } if (xcelNum > 0) sb.append((char) xcelNum); return sb.toString(); }Also the above code is rough idea and not tested but gives enough idea on simplifying the solution. The code does not use lot of / and % calcuations but could elegantly find the solution. Note the Gaurd if(i > 26){ i = 1; num++;} else i++; which is important in finding the combination of num and i which multiples at least to xcelNum.I think the above is incorrect and it should be : public static String xcelString(int xcelNum) { StringBuffer sb = new StringBuffer(); while(xcelNum >= 26){ int i = 1; for(;(26 * (i + 1)) 0) sb.append((char) xcelNum); return sb.toString(); }Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }public static String numToExcel(int n) { if(n 0) { int remainder = n%26; char newChar = (char) ('Z' - (26 -remainder)%26); result = newChar + result; n = (n-1)/26; } return result; }