Code Snippets Interview Questions
Questions Answers Views Company eMail

Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,

21 45453

Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.

Mentor Graphics, Microsoft,

2 21322

Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

Fusion Systems GmbH,

6 19057

Give a one-line C expression to test whether a number is a power of 2.

Microsoft,

10 23597

Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

Wipro,

2 9906

Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

Microsoft,

7 28071

program to Reverse a linked list

Aricent, Microsoft, Ness Technologies,

12 56741

write a program to Insert in a sorted list

Microsoft,

4 13384

Program to Delete an element from a doubly linked list.

College School Exams Tests, Infosys,

4 32053

Write a function to find the depth of a binary tree.

Adobe, Amazon, EFI, Imagination Technologies,

13 85815

Write a routine that prints out a 2-D array in spiral order

Microsoft,

3 16442

Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

Intel, Microsoft, TCS,

13 34949

Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

Disney, Google, ZS Associates,

3 13182

Print an integer using only putchar. Try doing it without using extra storage.

2 19560

How to swap two variables, without using third variable ?

AB, ADP, BirlaSoft, Cisco, Cygnet Infotech, HCL, Hewitt, Honeywell, HP, IBM, Infosys, Manhattan, Microsoft, Mobius, Percept, Satyam, SofTMware, TCS, Wipro, Yamaha,

104 222091


Un-Answered Questions { Code Snippets }

Hi All, Do anyone have a solution/script for Uploading the Excel file in Local drive to QC Resources folder..?? TIA Dwaraka.

1162


create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00

6273


How can call any javascript function without saying onclick, onchange, onblur etc events in php?

4141


plzzzzzzzzz xplain this code import java.awt.*; import java.awt.event.*; import java.awt.MenuItem.*; import java.sql.*; import sun.jdbc.odbc.*; import java.io.*; public class ShopDelivery extends Frame implements ActionListener { Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13; Button exit,save,next,top,prev,botm,ad,show; TextField txtCMemoNo,txtConsNo,txtCMemoDt,txtConsName,txtAddr1,txtPhNo ,txtBookDtold,txtPrintDt,txtOldCMemNo,txtOldDlryDt,adr2,adr3 ,tot,stnry,rmrk; String ConsName; String Addr1; public static void main(String sr[]) { new ShopDelivery().setVisible(true); } public ShopDelivery() { super("Shop Delivery"); Statement stmt; ResultSet rs; //PreparedStatement pst; Connection con; try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Agency"); if (con!=null); System.out.println ("connected"); stmt =con.createStatement (); } catch(Exception e1) { System.out.println (e1); } setSize(1280,800); setBackground(Color.CYAN); setLayout(null); l1=new Label("Cashmemo No"); l1.setBounds(260,60,90,30); l1.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l1.setAlignment(Label.CENTER); add(l1); l2=new Label("CONSMR NO"); l2.setBounds(30,60,90,30); l2.setFont(new Font("TimesRoman",Font.PLAIN,15)); l2.setAlignment(Label.CENTER); add(l2); l3=new Label("Book DATE"); l3.setBounds(520,60,90,30); l3.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l3.setAlignment(Label.CENTER); add(l3); l4=new Label("NAME"); l4.setBounds(30,150,45,30); l4.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l4.setAlignment(Label.CENTER); add(l4); l5=new Label("ADRS"); l5.setBounds(30,220,45,30); l5.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l5.setAlignment(Label.CENTER); add(l5); l6=new Label("PH NO"); l6.setBounds(500,150,45,30); l6.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l6.setAlignment(Label.CENTER); add(l6); l7=new Label("OldBkDt"); l7.setBounds(30,390,55,30); l7.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l7.setAlignment(Label.CENTER); add(l7); l8=new Label("Print Date"); l8.setBounds(320,390,65,30); l8.setFont(new Font("TimesRoman",Font.PLAIN,15)); l8.setAlignment(Label.CENTER); add(l8); l9=new Label("CMemo No"); l9.setBounds(700,390,65,30); l9.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l9.setAlignment(Label.CENTER); add(l9); l10=new Label("Del Date"); l10.setBounds(550,390,55,30); l10.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l10.setAlignment(Label.CENTER); add(l10); l13=new Label("REMARKS"); l13.setBounds (30,630,85,30); l13.setFont(new Font ("TimesRoman",Font.PLAIN,15)); l13.setAlignment (Label.CENTER); add(l13); txtCMemoNo=new TextField(); txtCMemoNo.setBounds(375,60,80,30); txtCMemoNo.setBackground(Color.white); add(txtCMemoNo); txtConsNo=new TextField(); txtConsNo.setBounds(130,60,80,30); txtConsNo.setBackground(Color.white); add(txtConsNo); txtCMemoDt=new TextField(); txtCMemoDt.setBounds(635,60,80,30); txtCMemoDt.setBackground(Color.white); add(txtCMemoDt); txtConsName=new TextField(); txtConsName.setBounds(100,150,200,30); txtConsName.setBackground(Color.white); add(txtConsName); txtAddr1=new TextField(); txtAddr1.setBounds(100,220,350,30); txtAddr1.setBackground(Color.white); add(txtAddr1); adr2=new TextField(); adr2.setBounds(100,250,350,30); adr2.setBackground(Color.white); add(adr2); adr3=new TextField(); adr3.setBounds(100,280,350,30); adr3.setBackground(Color.white); add(adr3); txtPhNo=new TextField(); txtPhNo.setBounds(570,150,150,30); txtPhNo.setBackground(Color.white); add(txtPhNo); txtBookDtold=new TextField(); txtBookDtold.setBounds(30,440,60,30); txtBookDtold.setBackground(Color.white); add(txtBookDtold); txtPrintDt=new TextField(); txtPrintDt.setBounds(320,440,60,30); txtPrintDt.setBackground(Color.white); add(txtPrintDt); txtOldCMemNo=new TextField(); txtOldCMemNo.setBounds(700,440,60,30); txtOldCMemNo.setBackground(Color.white); add(txtOldCMemNo); txtOldDlryDt=new TextField(); txtOldDlryDt.setBounds(550,440,60,30); txtOldDlryDt.setBackground(Color.white); add(txtOldDlryDt); rmrk=new TextField(); rmrk.setBounds(140,630,600,30); rmrk.setBackground(Color.white); add(rmrk); exit=new Button("EXIT"); exit.setBackground(Color.orange); exit.setBounds(760,700,40,40); exit.addActionListener(this); add(exit); save=new Button("SAVE"); save.setBackground(Color.orange); save.setBounds(715,700,40,40); save.addActionListener(this); add(save); next=new Button("NEXT"); next.setBackground(Color.orange); next.setBounds(90,700,40,40); next.addActionListener(this); add(next); top=new Button("TOP"); top.setBackground(Color.orange); top.setBounds(0,700,40,40); top.addActionListener(this); add(top); prev=new Button("PREV"); prev.setBackground(Color.orange); prev.setBounds(45,700,40,40); prev.addActionListener(this); add(prev); botm=new Button("BOTM"); botm.setBackground (Color.orange); botm.setBounds (135,700,40,40); botm.addActionListener (this); add(botm); ad=new Button("ADD"); ad.setBackground (Color.orange); ad.setBounds (300,700,40,40); ad.addActionListener (this); add(ad); show=new Button("SHOW"); show.setBackground (Color.orange); show.setBounds (345,700,40,40); show.addActionListener (this); add(show); } public void actionPerformed(ActionEvent e) { if(e.getSource()==exit) { this.dispose(); System.exit(0); } /*if(e.getSource()==save) { try { Connection con=DriverManager.getConnection("jdbc:odbc:Agency"); PreparedStatement pst=con.prepareStatement("INSERT INTO NewCon values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); pst.setInt (1,Integer.parseInt(txtConsNo.getText())); pst.setInt (2,Integer.parseInt(txtCMemoNo.getText())); pst.setString (3,txtCMemoDt.getText()); pst.setString (4,txtConsName.getText()); pst.setInt(5,Integer.parseInt (txtPhNo.getText())); pst.setString(6,txtAddr1.getText()); pst.setString(7,adr2.getText()); pst.setString(8,adr3.getText()); pst.setInt(9,Integer.parseInt (txtBookDtold.getText())); pst.setInt(10,Integer.parseInt (txtPrintDt.getText())); pst.setInt(11,Integer.parseInt (txtOldDlryDt.getText())); pst.setInt(12,Integer.parseInt (txtCMemoNo.getText())); pst.setInt(13,Integer.parseInt (tot.getText())); pst.setInt(14,Integer.parseInt (stnry.getText())); pst.setString(15,rmrk.getText()); pst.executeUpdate (); con.close(); } catch(Exception e2) {System.out.println(e2);} //cs(txtConsName.getText (),txtAddr1.getText()); }*/ if(e.getSource()==ad) { try { txtCMemoNo.setText(""); txtCMemoDt.setText(""); txtConsName.setText(""); txtAddr1.setText(""); txtPhNo.setText(""); txtBookDtold.setText(""); txtPrintDt.setText(""); //txtCMemoNo.setText(""); txtOldDlryDt.setText(""); adr2.setText(""); adr3.setText(""); tot.setText(""); //stnry.setText(""); //rmrk.setText(""); Connection con1=DriverManager.getConnection("jdbc:odbc:Agency"); Statement stmt1=con1.createStatement(); ResultSet rs1=stmt1.executeQuery("SELECT Max(Cons_No) FROM NewCon"); int nextcono = rs1.getInt ("Cons_No"); System.out.println (nextcono); nextcono=nextcono+1; txtConsNo.setText ("nextcono"); con1.close(); } catch(Exception e4){} } } }

1914


Could u please tell me any UNIX scripts that 'll lead to find the network latency of the servers.?or else any unix command to find the network latency of a server?Thnx in advance...

1675






What is CDATA?

346


How to run the Result Intemation System project in java for collage student in which result of internal exam marks send on parents mobile using SMS? what software required to run this project? please reply immediately...

2570


What is XQuery?

349


What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }

560


Develop a routine to reflect an object about an arbitrarily selected plane

2938


Common UI for Multiple web applications. Suppose there are 35 websites using same third party controls.These 3rd party controls are made together that all 35 websites can use these controls.If we put all 3rd party controls and use its dll in 35 websites,only class files will be accessable. But I want to use CSS,images also in all 35 websites. how I can design the N-tier solution for this project.

2218


i have some csv files in a directory which have sub-directories also. now how can i merge all .csv files in to one with a single header. for example: have some 4 files. 1.csv--------name,age,sal abc,25,4000 2.csv--------name,age,sal vgd,32,3500 3.csv--------name,age,sal hfg,20,5000 4.csv--------name,age,sal asd,15,2000 now my output file should be like 5.csv----------name,age,sal abc,25,4000 vgd,32,3500 hfg,20,5000 asd,15,2000 and please explain the code for me. as i am new to scripting. thank you in advance

1395


Write a program to Print the Pascal triangle

503


can any body give me answer to this question please? please give me code in cl with the folling specifications. 1.Accept 2 parameters-date and date type 2.If date type is J then convert date to *MDY format 3.If date type is M convert date to *JUL format 4. Send a program message with the value of converted date? Please give me the answer.Because im practicing in my house.Im taking trining on AS/400.

1892


What is an attribute?

349