Epic Systems Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
5
of 5 vote

function to draw a triangle given the height and width (not just height like most of the above solutions).

private static void drawTri(int height, int width) {
for(int i=1; i<=height; i++){
for(int j=0; j<(i*(width/height)); j++){
System.out.print("*");
}
System.out.print("\n");
}

}

- agnithin August 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

your answer is brilliant except that you need to take care of the integer division (i.e. multiply width by 1.0 before division)
replace this

for(int j=0; j<(i*(width/height)); j++)

with this

for(int j=0; j<(i*(width * 1.0/height)); j++)

and everything would work fine

- Moustafa Ashmawy July 05, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

void printStar(int numLine)
{
   String line = "";
   for (int i=0; i<numLine; i++)
   {
       line.concat("*");
       System.out.println(line);
       System.out.println("\n");
   }
}

- Anonymous March 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

should be line = line.concat("*");

- xiguang May 05, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

right baby!
and then solution is perfect, simple and clear and runs in O(n)

- googler August 19, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void printStar(int numLine)
{
   String line = "";
   for (int i=0; i<numLine; i++)
   {
       line.concat("*");
       System.out.println(line);
       System.out.println("\n");
   }
}

- Anonymous March 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote
{{{ for (int i = 0; i < height; ++i ) { for ( int j = 0; j <= i; ++j ) { cout << '*'; } cout << "\n"; } - Anonymous March 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for (int i = 0; i < height; ++i ) {
  for ( int j = 0; j <= i; ++j ) {
    cout << '*';
  }
  cout << "\n";
}

- Anonymous March 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void printStar(int n){
for (int i = 0; i < n; i++){
for (int j = 0; j <= i; j++)
System.out.print("*");
System.out.println();
}
}

- Anonymous May 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static void printTriangle(int n)
{
for (int i = 0; i < n; i++)
{
string _s = null;
for (int j = 0; j <= i; j++)
{
_s += "*";
}
Console.WriteLine(_s);
}
}

static void printTriangle1(int n)
{
string _s = null;
for (int i = 0; i < n; i++)
{
_s += "*";
Console.WriteLine(_s);
}
}


//Two functions for printing triangle

- Anonymous June 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

//previous one is not optimized this is perfect 2 solutions

static void printTriangle(int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}

static void printTriangle1(int n)
{
string _s = null;
for (int i = 0; i < n; i++)
{
_s += "*";
Console.WriteLine(_s);
}
}

- Anonymous June 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

// To print a triangle of stars of a given height
//======================================================
#include <iostream>
using namespace std;

void printTriangle(int height) {
    for (int i = 0; i < height; ++i ) {
      for ( int j = 0; j <= i; ++j ) {
        cout << '*';
      }
      cout << "\n";
    }
}

int main() {
    int height;
    cout<<"Enter the height of the triangle: ";
    cin>>height;
    printTriangle(height);
    return 0;
}
//===================================================

- Rock September 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How can I forget this qn? K&R exercise problem! I guess one of my earliest C programs :)

- ISU October 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
public static int len = 0;
static void Main(string[] args)
{


printstart(3);
Console.ReadLine();

}

static void printstart(int numline)
{
string line = "";
for (int i = 1; i <= numline; i++)
{
line = line.PadLeft(i,'*');
Console.WriteLine(line);
}
}

}
}

- C# December 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char p[MAX];

for(j=0;j<line;j++)
{
p[j]='*';
p[j+1]='\0';
cout<<p<<endl;
}

- helen January 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <stdlib.h>
int main (){

int ht = 5;
int n,i ;
for(n = 0; n<=ht; n++){
for (i = 0; i<n ;i++){
printf("*");
}
if (n!= 0)
printf(" \n");
}

return 0;
}

- adhikarimanoj1 June 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey48889" class="run-this">public void printTriangle (int height, int width) {

String line = "";

for(int i = width; i > 0; i--) {
int j = i;
if (height > 0) {
while (j > 0) {
line = line.concat("*");
j --;
}// end while

System.out.println(line);
line = "";
height--;
} // end if
else
break;
} // end for
}

</pre><pre title="CodeMonkey48889" input="yes">
</pre>

- Anonymous July 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey66197" class="run-this">public void printTriangle (int height, int width) {

String line = "";

for(int i = width; i > 0; i--) {
int j = i;
if (height > 0) {
while (j > 0) {
line = line.concat("*");
j --;
}// end while

System.out.println(line);
line = "";
height--;
} // end if
else
break;
} // end for
}

</pre><pre title="CodeMonkey66197" input="yes">
</pre>

- Anonymous July 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
main()
{ int i,j,n;
printf("Enter the no of stars as height\n");
scanf("%d",&n);
for(i=0; i<n; i++)
{ for(j=0; j<i; j++)
printf("*");
printf("\n");
}
}

- @123 August 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class star {

	public static void main(String args[]) {
		int numLine = 5;
		String line = "";
		for (int i = 0; i < numLine; i++) {
			line = line.concat("*");
			System.out.println(line);
		}
	}
}

- sanjeev kaneria March 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is a working code in C++:

#include <cstdio>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int i, j;
    float x, y;
    cin>>x;
    cin>>y;
    for(i=1; i<=x; i++)
    { 
        for(j=0; j<(i*(float)(y/x)); j++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}

- Meraj Ahmed November 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def trianglePrint(n):
for x in xrange(1,n+1):
print "*" * x
trianglePrint(3)

- aditya bist January 01, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static void printStar(int num)
{
StringBuilder line = new StringBuilder();
for (int i=0; i<num; i++)
{
line.append("*");
System.out.print(line);
System.out.print("\n");
}
}

- MeSoRight November 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The function takes input as the height. Keeps appending one star on the right as code moves from top (0) to bottom (num-1).

- MeSoRight November 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package starpyramid;

/**
 *
 * @author swetalina
 */
public class StarPyramid {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        StarPyramid(8);
    }
    
          public static void  StarPyramid(int i)
            {
              
                for(int k=1;k<=i;k++){
                    for(int j=1;j<=k;j++)
                    {
                        System.out.print("*");
                    }
                    System.out.println("\n");
                }
                
            }

    
}

- Anonymous November 08, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class stars {

	public static void main(String[] args) {
		
		String str = "*";
		
		for(int i = 1;i <= 5;i++){
			for(int j = 1; j<=i;j++){
				System.out.print(str);
			}
			System.out.println();
		}
	}

}

- Tejaswi January 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is for 5 stars..was doing some testing and forgot to change it back to 3

- Tejaswi January 22, 2015 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More