Code Snippets Interview Questions
Questions Answers Views Company eMail

int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

1 2211

main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }


29 21055

main() { int i=5; printf("%d",++i++); }

1 1727

main() { char *p = “ayqm”; char c; c = ++*p++; printf(“%c”,c); }

1 2422

int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

1 2836

main() { int i=5; printf(“%d”,i=++i ==6); }

1 1704

main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 4545

void ( * abc( int, void ( *def) () ) ) ();

1 2272

main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }

1 2526

main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

1 2047

main() { int i = 3; for (;i++=0;) printf(“%d”,i); }


1 5483

void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 1920

void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 5344

main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

CSC, Adobe,

2 10307

1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 2254

Un-Answered Questions { Code Snippets }

A program that will create a movie seat reservation. The program will display the summary seats and its status. The user will be ask what seat no. to be reserved, then it will go back again to the summary to display the updated seat status. If the seat no. is already reserved then it will prompt an error message. And also if the input seat no is out of range then it will also prompt an error message. The program is continuously running. Termination of the program will depends on how the programmer will apply. Sample output: Movie Seats Reservation Summary of Seats: Seat 1: Available Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 6 The Seat no. is out of range! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 The Seat no. is already reserved! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 0 GoodBye... Thank You!!!


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??


Find out the list of roles which gives access to all t-codes in SAP? Thanks in advance.


Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.


i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.


How to swap two ASCII numbers?


How to Print GridView Data on Button Click using Javascript?


code to set the main window's size


U hv to enter a range from a and b and search hw many no. of times a pattern n. occurs between the range a and b. Eg :i/p:enter range :0 100 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 0 to 100:1 Eg :i/p:enter range :100 1000 Enter pattern: 13 o/p: the no. times 13 occurred betwwn 100 to 1000: (in this 13,113,131,132,133…139,213,313,…913 all these will be counted)


code to Hide and Show form controls


write a program in java to find the moving average of all prime numbers between 2 and 100.


plzzzzzzzzz xplain this code import java.awt.*; import java.awt.event.*; import java.awt.MenuItem.*; import java.sql.*; import java.util.Date; import sun.jdbc.odbc.*; import*; public class RefillBooking 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 txtBookingNo,txtConsNo,txtBookingDt,txtConsName,txtAddr1,txt PhNo,txtBookDtold,txtPrintDt,txtCMemoNo,txtOldDlryDt,adr2,ad r3,tot,stnry,rmrk; Date date=new Date(); String ConsName; String Addr1; public static void main(String sr[]) { new RefillBooking().setVisible(true); } public RefillBooking() { super("Refill Booking"); 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.lightGray); setLayout(null); l1=new Label("Booking 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 (mm/dd/yyyy)"); l3.setBounds(520,60,190,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); txtBookingNo=new TextField(); txtBookingNo.setBounds(375,60,80,30); txtBookingNo.setBackground(Color.white); add(txtBookingNo); txtConsNo=new TextField(); txtConsNo.setBounds(130,60,80,30); txtConsNo.setBackground(Color.white); add(txtConsNo); txtBookingDt=new TextField(); txtBookingDt.setBounds(750,60,80,30); txtBookingDt.setBackground(Color.white); add(txtBookingDt); 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); txtCMemoNo=new TextField(); txtCMemoNo.setBounds(700,440,60,30); txtCMemoNo.setBackground(Color.white); add(txtCMemoNo); 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(; exit.setBounds(760,700,40,40); exit.addActionListener(this); add(exit); save=new Button("SAVE"); save.setBackground(; save.setBounds(715,700,40,40); save.addActionListener(this); add(save); next=new Button("NEXT"); next.setBackground(; next.setBounds(90,700,40,40); next.addActionListener(this); add(next); top=new Button("TOP"); top.setBackground(; top.setBounds(0,700,40,40); top.addActionListener(this); add(top); prev=new Button("PREV"); prev.setBackground(; prev.setBounds(45,700,40,40); prev.addActionListener(this); add(prev); botm=new Button("BOTM"); botm.setBackground (; botm.setBounds (135,700,40,40); botm.addActionListener (this); add(botm); ad=new Button("ADD"); ad.setBackground (; ad.setBounds (300,700,40,40); ad.addActionListener (this); add(ad); show=new Button("SHOW"); show.setBackground (; 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) { int bkflag=1; try { Connection con=DriverManager.getConnection("jdbc:odbc:Agency"); PreparedStatement pst=con.prepareStatement("INSERT INTO RefillBooking VALUES (?,?,?,?)"); pst.setInt (1,Integer.parseInt(txtBookingNo.getText())); pst.setInt (2,Integer.parseInt(txtConsNo.getText())); pst.setString (3,txtBookingDt.getText()); pst.setInt(4,bkflag); /* pst.setString (4,txtConsName.getText()); pst.setString (6,txtAddr1.getText()); pst.setString(7,adr2.getText ()); pst.setString(8,adr3.getText ()); pst.setInt(9,Integer.parseInt (txtCylQty.getText())); pst.setInt (10,Integer.parseInt(txtCylDep.getText())); pst.setInt (11,Integer.parseInt(txtRegQty.getText())); pst.setInt (12,Integer.parseInt(txtRegDep.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);} } if(e.getSource()==show) { System.out.println("entered if body"); try { //to bring consumer's details Connection con2=DriverManager.getConnection("jdbc:odbc:Agency"); int consumer=Integer.parseInt (txtConsNo.getText()); PreparedStatement ps2=con2.prepareStatement("SELECT * FROM NewCon WHERE Cons_No=?"); ps2.setInt(1,consumer); ResultSet rs2= ps2.executeQuery(); while( { System.out.print ("entered while"+rs2.getString(2)); txtConsName.setText (rs2.getString("Cons_Name")); txtAddr1.setText (rs2.getString("Adress1")); txtPhNo.setText (""+rs2.getInt("Ph_No")); adr2.setText (rs2.getString("Adress2")); adr3.setText (rs2.getString("Adress3")); rmrk.setText(""); } //Statement stmt3=con2.createStatement(); //ResultSet rs3=stmt3.executeQuery("SELECT CMemoNo,CMemo_Date,DeliveryDate FROM CashMemo where Cons_No="+consumer); con2.close(); } catch(Exception e2) {System.out.println(e2);} } if(e.getSource()==ad) { int newbkno=0; System.out.println("entered if body"); try { //to clear textboxes txtConsName.setText(""); txtAddr1.setText(""); txtBookingNo.setText(""); txtPhNo.setText(""); adr2.setText(""); adr3.setText(""); rmrk.setText(""); txtConsNo.setText(""); txtBookingDt.setText("" + date); txtBookDtold.setText(""); txtPrintDt.setText(""); txtCMemoNo.setText(""); txtOldDlryDt.setText(""); //to generate bookin no System.out.println("entered the try:"); Connection con1=DriverManager.getConnection("jdbc:odbc:Agency"); Statement stmt1=con1.createStatement(); ResultSet rs1=stmt1.executeQuery ("SELECT BookingNo FROM RefillBooking "); while( { txtBookingNo.setText (""+rs1.getInt(1)); } newbkno=Integer.parseInt (txtBookingNo.getText()); System.out.println(newbkno); newbkno=newbkno+1; txtBookingNo.setText(""+newbkno); } catch(Exception e4){System.out.println(e4);} } } }


write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150


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.


Write a function that takes an unsorted integer array, and returns a three element subset whose sum is zero.