<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-722618417950535887</id><updated>2012-02-16T19:33:55.467-08:00</updated><category term='Threading'/><category term='Win32 API'/><category term='Nework Programming'/><category term='Recursive'/><category term='C'/><category term='.Net'/><category term='SDI'/><category term='ADA'/><category term='Heap Sort'/><category term='Mirror Image Tree'/><category term='VC++'/><category term='Java'/><category term='VB'/><category term='Source Code'/><category term='Doc-View Architecture'/><category term='C#'/><category term='C++'/><category term='PHP'/><category term='Algorithm'/><category term='Sockets'/><category term='MFC'/><category term='Synchronization'/><category term='STL'/><category term='Database'/><category term='MDI'/><category term='HTML'/><category term='Visual Basic'/><category term='Dll'/><category term='WinSoc'/><category term='Linked List'/><category term='Quick Sort'/><category term='C#.Net'/><category term='DHTML'/><category term='Visual C++'/><category term='OpenGL'/><category term='ADO'/><category term='Heap'/><title type='text'>Sample Source Code for programming problems</title><subtitle type='html'>Java, c, C++, win32, .net, C#, ASP, VB, ADO, and many more</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4151072616417372009</id><published>2008-12-12T21:28:00.001-08:00</published><updated>2009-03-25T18:51:57.524-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>The TextEditor class is a simple text editor.</title><content type='html'>&lt;pre style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-size:130%;"&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;public class TextEditor extends JFrame&lt;br /&gt;{&lt;br /&gt;// The following are fields for the menu system.&lt;br /&gt;// First, the menu bar&lt;br /&gt;private JMenuBar menuBar;&lt;br /&gt;&lt;br /&gt;// The menus&lt;br /&gt;private JMenu fileMenu;&lt;br /&gt;private JMenu fontMenu;&lt;br /&gt;&lt;br /&gt;// The menu items&lt;br /&gt;private JMenuItem newItem;&lt;br /&gt;private JMenuItem openItem;&lt;br /&gt;private JMenuItem saveItem;&lt;br /&gt;private JMenuItem saveAsItem;&lt;br /&gt;private JMenuItem exitItem;&lt;br /&gt;&lt;br /&gt;// The radio button menu items&lt;br /&gt;private JRadioButtonMenuItem monoItem;&lt;br /&gt;private JRadioButtonMenuItem serifItem;&lt;br /&gt;private JRadioButtonMenuItem sansSerifItem;&lt;br /&gt;&lt;br /&gt;// The checkbox menu items&lt;br /&gt;private JCheckBoxMenuItem italicItem;&lt;br /&gt;private JCheckBoxMenuItem boldItem;&lt;br /&gt;&lt;br /&gt;private String filename;     // To hold the file name&lt;br /&gt;private JTextArea editorText;// To display the text&lt;br /&gt;private final int NUM_LINES = 20;  // Lines to display&lt;br /&gt;private final int NUM_CHARS = 40;  // Chars per line&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Constructor&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;public TextEditor()&lt;br /&gt;{&lt;br /&gt;   // Set the title.&lt;br /&gt;   setTitle("Text Editor");&lt;br /&gt;&lt;br /&gt;   // Specify what happens when the close&lt;br /&gt;   // button is clicked.&lt;br /&gt;   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;&lt;br /&gt;   // Create the text area.&lt;br /&gt;   editorText = new JTextArea(NUM_LINES, NUM_CHARS);&lt;br /&gt;&lt;br /&gt;   // Turn line wrapping on.&lt;br /&gt;   editorText.setLineWrap(true);&lt;br /&gt;   editorText.setWrapStyleWord(true);&lt;br /&gt;&lt;br /&gt;   // Create a scroll pane and add the text area to it.&lt;br /&gt;   JScrollPane scrollPane = new JScrollPane(editorText);&lt;br /&gt;&lt;br /&gt;   // Add the scroll pane to the content pane.&lt;br /&gt;   add(scrollPane);&lt;br /&gt;&lt;br /&gt;   // Build the menu bar.&lt;br /&gt;   buildMenuBar();&lt;br /&gt;&lt;br /&gt;   // Pack and display the window.&lt;br /&gt;   pack();&lt;br /&gt;   setVisible(true);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   The buildMenuBar method creates a menu bar and&lt;br /&gt;   calls the createFileMenu method to create the&lt;br /&gt;   file menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private void buildMenuBar()&lt;br /&gt;{&lt;br /&gt;   // Build the file and font menus.&lt;br /&gt;   buildFileMenu();&lt;br /&gt;   buildFontMenu();&lt;br /&gt;&lt;br /&gt;   // Create the menu bar.&lt;br /&gt;   menuBar = new JMenuBar();&lt;br /&gt;&lt;br /&gt;   // Add the file and font menus to the menu bar.&lt;br /&gt;   menuBar.add(fileMenu);&lt;br /&gt;   menuBar.add(fontMenu);&lt;br /&gt;&lt;br /&gt;   // Set the menu bar for this frame.&lt;br /&gt;   setJMenuBar(menuBar);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   The buildFileMenu method creates the file menu&lt;br /&gt;   and populates it with its menu items.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private void buildFileMenu()&lt;br /&gt;{&lt;br /&gt;   // Create the New menu item.&lt;br /&gt;   newItem = new JMenuItem("New");&lt;br /&gt;   newItem.setMnemonic(KeyEvent.VK_N);&lt;br /&gt;   newItem.addActionListener(new NewListener());&lt;br /&gt;&lt;br /&gt;   // Create the Open menu item.&lt;br /&gt;   openItem = new JMenuItem("Open");&lt;br /&gt;   openItem.setMnemonic(KeyEvent.VK_O);&lt;br /&gt;   openItem.addActionListener(new OpenListener());&lt;br /&gt;&lt;br /&gt;   // Create the Save menu item.&lt;br /&gt;   saveItem = new JMenuItem("Save");&lt;br /&gt;   saveItem.setMnemonic(KeyEvent.VK_S);&lt;br /&gt;   saveItem.addActionListener(new SaveListener());&lt;br /&gt;&lt;br /&gt;   // Create the Save As menu item.&lt;br /&gt;   saveAsItem = new JMenuItem("Save As");&lt;br /&gt;   saveAsItem.setMnemonic(KeyEvent.VK_A);&lt;br /&gt;   saveAsItem.addActionListener(new SaveListener());&lt;br /&gt;&lt;br /&gt;   // Create the Exit menu item.&lt;br /&gt;   exitItem = new JMenuItem("Exit");&lt;br /&gt;   exitItem.setMnemonic(KeyEvent.VK_X);&lt;br /&gt;   exitItem.addActionListener(new ExitListener());&lt;br /&gt;&lt;br /&gt;   // Create a menu for the items we just created.&lt;br /&gt;   fileMenu = new JMenu("File");&lt;br /&gt;   fileMenu.setMnemonic(KeyEvent.VK_F);&lt;br /&gt;&lt;br /&gt;   // Add the items and some separator bars to the menu.&lt;br /&gt;   fileMenu.add(newItem);&lt;br /&gt;   fileMenu.add(openItem);&lt;br /&gt;   fileMenu.addSeparator();// Separator bar&lt;br /&gt;   fileMenu.add(saveItem);&lt;br /&gt;   fileMenu.add(saveAsItem);&lt;br /&gt;   fileMenu.addSeparator();// Separator bar&lt;br /&gt;   fileMenu.add(exitItem);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   The buildFontMenu method creates the font menu&lt;br /&gt;      and populates it with its menu items.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private void buildFontMenu()&lt;br /&gt;{&lt;br /&gt;   // Create the Monospaced menu item.&lt;br /&gt;   monoItem = new JRadioButtonMenuItem("Monospaced");&lt;br /&gt;   monoItem.addActionListener(new FontListener());&lt;br /&gt;&lt;br /&gt;   // Create the Serif menu item.&lt;br /&gt;   serifItem = new JRadioButtonMenuItem("Serif");&lt;br /&gt;   serifItem.addActionListener(new FontListener());&lt;br /&gt;&lt;br /&gt;   // Create the SansSerif menu item.&lt;br /&gt;   sansSerifItem =&lt;br /&gt;           new JRadioButtonMenuItem("SansSerif", true);&lt;br /&gt;   sansSerifItem.addActionListener(new FontListener());&lt;br /&gt;&lt;br /&gt;   // Group the radio button menu items.&lt;br /&gt;   ButtonGroup group = new ButtonGroup();&lt;br /&gt;   group.add(monoItem);&lt;br /&gt;   group.add(serifItem);&lt;br /&gt;   group.add(sansSerifItem);&lt;br /&gt;&lt;br /&gt;   // Create the Italic menu item.&lt;br /&gt;   italicItem = new JCheckBoxMenuItem("Italic");&lt;br /&gt;   italicItem.addActionListener(new FontListener());&lt;br /&gt;&lt;br /&gt;   // Create the Bold menu item.&lt;br /&gt;   boldItem = new JCheckBoxMenuItem("Bold");&lt;br /&gt;   boldItem.addActionListener(new FontListener());&lt;br /&gt;&lt;br /&gt;   // Create a menu for the items we just created.&lt;br /&gt;   fontMenu = new JMenu("Font");&lt;br /&gt;   fontMenu.setMnemonic(KeyEvent.VK_T);&lt;br /&gt;&lt;br /&gt;   // Add the items and some separator bars to the menu.&lt;br /&gt;   fontMenu.add(monoItem);&lt;br /&gt;   fontMenu.add(serifItem);&lt;br /&gt;   fontMenu.add(sansSerifItem);&lt;br /&gt;   fontMenu.addSeparator();// Separator bar&lt;br /&gt;   fontMenu.add(italicItem);&lt;br /&gt;   fontMenu.add(boldItem);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Private inner class that handles the event that&lt;br /&gt;   is generated when the user selects New from&lt;br /&gt;   the file menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private class NewListener implements ActionListener&lt;br /&gt;{&lt;br /&gt;   public void actionPerformed(ActionEvent e)&lt;br /&gt;   {&lt;br /&gt;      editorText.setText("");&lt;br /&gt;      filename = null;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Private inner class that handles the event that&lt;br /&gt;   is generated when the user selects Open from&lt;br /&gt;   the file menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private class OpenListener implements ActionListener&lt;br /&gt;{&lt;br /&gt;   public void actionPerformed(ActionEvent e)&lt;br /&gt;   {&lt;br /&gt;      int chooserStatus;&lt;br /&gt;&lt;br /&gt;      JFileChooser chooser = new JFileChooser();&lt;br /&gt;      chooserStatus = chooser.showOpenDialog(null);&lt;br /&gt;      if (chooserStatus == JFileChooser.APPROVE_OPTION)&lt;br /&gt;      {&lt;br /&gt;         // Get a reference to the selected file.&lt;br /&gt;         File selectedFile = chooser.getSelectedFile();&lt;br /&gt;&lt;br /&gt;         // Get the path of the selected file.&lt;br /&gt;         filename = selectedFile.getPath();&lt;br /&gt;&lt;br /&gt;         // Open the file.&lt;br /&gt;         if (!openFile(filename))&lt;br /&gt;         {&lt;br /&gt;            JOptionPane.showMessageDialog(null,&lt;br /&gt;                             "Error reading " +&lt;br /&gt;                             filename, "Error",&lt;br /&gt;                             JOptionPane.ERROR_MESSAGE);&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;      The openFile method opens the file specified by&lt;br /&gt;      filename and reads its contents into the text&lt;br /&gt;      area. The method returns true if the file was&lt;br /&gt;      opened and read successfully, or false if an&lt;br /&gt;      error occurred.&lt;br /&gt;      @param filename The name of the file to open.&lt;br /&gt;   */&lt;br /&gt;&lt;br /&gt;   private boolean openFile(String filename)&lt;br /&gt;   {&lt;br /&gt;      boolean success;&lt;br /&gt;      String inputLine, editorString = "";&lt;br /&gt;      FileReader freader;&lt;br /&gt;      BufferedReader inputFile;&lt;br /&gt;&lt;br /&gt;      try&lt;br /&gt;      {&lt;br /&gt;         // Open the file.&lt;br /&gt;         freader = new FileReader(filename);&lt;br /&gt;         inputFile = new BufferedReader(freader);&lt;br /&gt;&lt;br /&gt;         // Read the file contents into the editor.&lt;br /&gt;         inputLine = inputFile.readLine();&lt;br /&gt;         while (inputLine != null)&lt;br /&gt;         {&lt;br /&gt;            editorString = editorString +&lt;br /&gt;                           inputLine + "\n";&lt;br /&gt;            inputLine = inputFile.readLine();&lt;br /&gt;         }&lt;br /&gt;         editorText.setText(editorString);&lt;br /&gt;&lt;br /&gt;         // Close the file.&lt;br /&gt;         inputFile.close();&lt;br /&gt;&lt;br /&gt;         // Indicate that everything went OK.&lt;br /&gt;         success = true;&lt;br /&gt;      }&lt;br /&gt;      catch (IOException e)&lt;br /&gt;      {&lt;br /&gt;         // Something went wrong.&lt;br /&gt;         success = false;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      // Return our status.&lt;br /&gt;      return success;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Private inner class that handles the event that&lt;br /&gt;   is generated when the user selects Save or Save&lt;br /&gt;   As from the file menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private class SaveListener implements ActionListener&lt;br /&gt;{&lt;br /&gt;   public void actionPerformed(ActionEvent e)&lt;br /&gt;   {&lt;br /&gt;      int chooserStatus;&lt;br /&gt;&lt;br /&gt;      // If the user selected Save As, or the contents&lt;br /&gt;      // of the editor have not been saved, use a file&lt;br /&gt;      // chooser to get the file name. Otherwise, save&lt;br /&gt;      // the file under the current file name.&lt;br /&gt;&lt;br /&gt;      if (e.getActionCommand() == "Save As" ||&lt;br /&gt;          filename == null)&lt;br /&gt;      {&lt;br /&gt;         JFileChooser chooser = new JFileChooser();&lt;br /&gt;         chooserStatus = chooser.showSaveDialog(null);&lt;br /&gt;         if (chooserStatus == JFileChooser.APPROVE_OPTION)&lt;br /&gt;         {&lt;br /&gt;            // Get a reference to the selected file.&lt;br /&gt;            File selectedFile =&lt;br /&gt;                          chooser.getSelectedFile();&lt;br /&gt;&lt;br /&gt;            // Get the path of the selected file.&lt;br /&gt;            filename = selectedFile.getPath();&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      // Save the file.&lt;br /&gt;      if (!saveFile(filename))&lt;br /&gt;      {&lt;br /&gt;         JOptionPane.showMessageDialog(null,&lt;br /&gt;                            "Error saving " +&lt;br /&gt;                            filename,&lt;br /&gt;                            "Error",&lt;br /&gt;                            JOptionPane.ERROR_MESSAGE);&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;      The saveFile method saves the contents of the&lt;br /&gt;      text area to a file. The method returns true if&lt;br /&gt;      the file was saved successfully, or false if an&lt;br /&gt;      error occurred.&lt;br /&gt;      @param filename The name of the file.&lt;br /&gt;      @return true if successful, false otherwise.&lt;br /&gt;   */&lt;br /&gt;&lt;br /&gt;   private boolean saveFile(String filename)&lt;br /&gt;   {&lt;br /&gt;      boolean success;&lt;br /&gt;      String editorString;&lt;br /&gt;      FileWriter fwriter;&lt;br /&gt;      PrintWriter outputFile;&lt;br /&gt;&lt;br /&gt;      try&lt;br /&gt;      {&lt;br /&gt;         // Open the file.&lt;br /&gt;         fwriter = new FileWriter(filename);&lt;br /&gt;         outputFile = new PrintWriter(fwriter);&lt;br /&gt;&lt;br /&gt;         // Write the contents of the text area&lt;br /&gt;         // to the file.&lt;br /&gt;         editorString = editorText.getText();&lt;br /&gt;         outputFile.print(editorString);&lt;br /&gt;&lt;br /&gt;         // Close the file.&lt;br /&gt;         outputFile.close();&lt;br /&gt;&lt;br /&gt;         // Indicate that everything went OK.&lt;br /&gt;         success = true;&lt;br /&gt;      }&lt;br /&gt;      catch (IOException e)&lt;br /&gt;      {&lt;br /&gt;         // Something went wrong.&lt;br /&gt;          success = false;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      // Return our status.&lt;br /&gt;      return success;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Private inner class that handles the event that&lt;br /&gt;   is generated when the user selects Exit from&lt;br /&gt;   the file menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private class ExitListener implements ActionListener&lt;br /&gt;{&lt;br /&gt;   public void actionPerformed(ActionEvent e)&lt;br /&gt;   {&lt;br /&gt;      System.exit(0);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   Private inner class that handles the event that&lt;br /&gt;   is generated when the user selects an item from&lt;br /&gt;   the font menu.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;private class FontListener implements ActionListener&lt;br /&gt;{&lt;br /&gt;   public void actionPerformed(ActionEvent e)&lt;br /&gt;   {&lt;br /&gt;      // Get the current font.&lt;br /&gt;      Font textFont = editorText.getFont();&lt;br /&gt;&lt;br /&gt;      // Retrieve the font name and size.&lt;br /&gt;      String fontName = textFont.getName();&lt;br /&gt;      int fontSize = textFont.getSize();&lt;br /&gt;&lt;br /&gt;      // Start with plain style.&lt;br /&gt;      int fontStyle = Font.PLAIN;&lt;br /&gt;&lt;br /&gt;      // Determine which font is selected.&lt;br /&gt;      if (monoItem.isSelected())&lt;br /&gt;         fontName = "Monospaced";&lt;br /&gt;      else if (serifItem.isSelected())&lt;br /&gt;         fontName = "Serif";&lt;br /&gt;      else if (sansSerifItem.isSelected())&lt;br /&gt;         fontName = "SansSerif";&lt;br /&gt;&lt;br /&gt;      // Determine whether italic is selected.&lt;br /&gt;      if (italicItem.isSelected())&lt;br /&gt;         fontStyle += Font.ITALIC;&lt;br /&gt;&lt;br /&gt;      // Determine whether bold is selected.&lt;br /&gt;      if (boldItem.isSelected())&lt;br /&gt;         fontStyle += Font.BOLD;&lt;br /&gt;&lt;br /&gt;      // Set the font as selected.&lt;br /&gt;      editorText.setFont(new Font(fontName,&lt;br /&gt;                             fontStyle, fontSize));&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;   main method&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;public static void main(String[] args)&lt;br /&gt;{&lt;br /&gt;   TextEditor te = new TextEditor();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4151072616417372009?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4151072616417372009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4151072616417372009' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4151072616417372009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4151072616417372009'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/texteditor-class-is-simple-text-editor.html' title='The TextEditor class is a simple text editor.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4013056093316696578</id><published>2008-12-11T07:37:00.000-08:00</published><updated>2008-12-22T21:29:32.539-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Header File and Library Function Reference</title><content type='html'>This appendix provides a reference for the C++ library functions discussed in the book.&lt;br /&gt;The following table gives an alphabetical list of functions. Tables of functions that are&lt;br /&gt;organized by their header files follow it.&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions&lt;br /&gt;Function Details&lt;br /&gt;abs(m)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts an integer argument. Returns the absolute value of the argument&lt;br /&gt;as an integer.&lt;br /&gt;Example:&lt;br /&gt;a = abs(m);&lt;br /&gt;atof(str)&lt;br /&gt;Header File:&lt;br /&gt;cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to a&lt;br /&gt;double&lt;br /&gt;and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atof("3.14159");&lt;br /&gt;atoi(str)&lt;br /&gt;Header File:&lt;br /&gt;cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to an&lt;br /&gt;int&lt;br /&gt;and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atoi("4569");&lt;br /&gt;atol(str)&lt;br /&gt;Header File:&lt;br /&gt;cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to a&lt;br /&gt;long&lt;br /&gt;and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atol("5000000");&lt;br /&gt;2&lt;br /&gt;Appendix I: Header File and Library Function Reference&lt;br /&gt;cos(m)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;double&lt;br /&gt;argument. Returns the cosine of the argument. The&lt;br /&gt;argument should be an angle expressed in radians. The return type is&lt;br /&gt;double&lt;br /&gt;.&lt;br /&gt;Example:&lt;br /&gt;a = cos(m);&lt;br /&gt;exit(status)&lt;br /&gt;Header File:&lt;br /&gt;cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts an&lt;br /&gt;int&lt;br /&gt;argument. Terminates the program and passes the value&lt;br /&gt;of the argument to the operating system.&lt;br /&gt;Example:&lt;br /&gt;exit(0);&lt;br /&gt;exp(m)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;double&lt;br /&gt;argument. Computes the exponential function of the&lt;br /&gt;argument, which is e&lt;br /&gt;x&lt;br /&gt;. The return type is&lt;br /&gt;double&lt;br /&gt;.&lt;br /&gt;Example:&lt;br /&gt;a = exp(m);&lt;br /&gt;fmod(m, n)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts two&lt;br /&gt;double&lt;br /&gt;arguments. Returns, as a&lt;br /&gt;double&lt;br /&gt;, the remainder of&lt;br /&gt;the first argument divided by the second argument. Works like the&lt;br /&gt;modulus operator, but the arguments are doubles. (The modulus operator&lt;br /&gt;only works with integers.) Take care not to pass zero as the second&lt;br /&gt;argument. Doing so would cause division by zero.&lt;br /&gt;Example:&lt;br /&gt;a = fmod(m, n);&lt;br /&gt;isalnum(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a letter of the&lt;br /&gt;alphabet or a digit. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isalnum(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is alphanumeric.\n";&lt;br /&gt;isdigit(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a digit 0 - 9.&lt;br /&gt;Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isdigit(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is a digit.\n";&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions&lt;br /&gt;(continued)&lt;br /&gt;Function Details&lt;br /&gt;Appendix I: Header File and Library Function Reference&lt;br /&gt;3&lt;br /&gt;islower(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a lowercase&lt;br /&gt;letter. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (islower(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is lowercase.\n";&lt;br /&gt;isprint(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a printable&lt;br /&gt;character (including a space). Returns false otherwise.&lt;br /&gt;Example:&lt;br /&gt;if (isprint(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is printable.\n";&lt;br /&gt;ispunct(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a printable&lt;br /&gt;character other than a digit, letter, or space. Returns false otherwise.&lt;br /&gt;Example:&lt;br /&gt;if (ispunct(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is punctuation.\n";&lt;br /&gt;isspace(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is a whitespace&lt;br /&gt;character. Whitespace characters are any of the following:&lt;br /&gt;• space................ ‘ ’&lt;br /&gt;• newline.............. ‘\n’&lt;br /&gt;• tab.................. ‘\t’&lt;br /&gt;• vertical tab......... ‘\v’&lt;br /&gt;Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isspace(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is whitespace.\n";&lt;br /&gt;isupper(ch)&lt;br /&gt;Header File:&lt;br /&gt;cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;char&lt;br /&gt;argument. Returns true if the argument is an uppercase&lt;br /&gt;letter. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isupper(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is uppercase.\n";&lt;br /&gt;log(m)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a&lt;br /&gt;double&lt;br /&gt;argument. Returns, as a&lt;br /&gt;double&lt;br /&gt;, the natural logarithm&lt;br /&gt;of the argument.&lt;br /&gt;Example:&lt;br /&gt;a = log(m);&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions&lt;br /&gt;(continued)&lt;br /&gt;Function Details&lt;br /&gt;4&lt;br /&gt;Appendix I: Header File and Library Function Reference&lt;br /&gt;log10(m)&lt;br /&gt;Header File:&lt;br /&gt;cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the base-10 logarithm&lt;br /&gt;of the argument.&lt;br /&gt;Example:&lt;br /&gt;a = log10(m);&lt;br /&gt;pow(m, n) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts two double arguments. Returns the value of argument 1 raised&lt;br /&gt;to the power of argument 2.&lt;br /&gt;Example:&lt;br /&gt;a = pow(m, n);&lt;br /&gt;rand() Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Generates a pseudorandom number.&lt;br /&gt;Example:&lt;br /&gt;x = rand();&lt;br /&gt;sin(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the sine of the&lt;br /&gt;argument. The argument should be an angle expressed in radians.&lt;br /&gt;Example:&lt;br /&gt;a = sin(m);&lt;br /&gt;sqrt(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the square root of the&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;a = sqrt(m);&lt;br /&gt;srand(m) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts an unsigned int argument. The argument is used as a seed&lt;br /&gt;value to randomize the results of the rand() function.&lt;br /&gt;Example:&lt;br /&gt;srand(m);&lt;br /&gt;strcat(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings as arguments. The function appends the contents&lt;br /&gt;of the second string to the first string. (The first string is altered; the&lt;br /&gt;second string is left unchanged.)&lt;br /&gt;Example:&lt;br /&gt;strcat(string1, string2);&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions (continued)&lt;br /&gt;Function Details&lt;br /&gt;Appendix I: Header File and Library Function Reference 5&lt;br /&gt;strcmp(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts pointers to two string arguments. If string1 and string2 are the&lt;br /&gt;same, this function returns 0. If string2 is alphabetically greater than&lt;br /&gt;string1, it returns a positive number. If string2 is alphabetically less than&lt;br /&gt;string1, it returns a negative number.&lt;br /&gt;Example:&lt;br /&gt;if (strcmp(string1, string2) == 0)&lt;br /&gt;cout &lt;&lt; "The strings are equal.\n";&lt;br /&gt;strcpy(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings as arguments. The function copies the second&lt;br /&gt;string to the first string. The second string is left unchanged.&lt;br /&gt;Example:&lt;br /&gt;strcpy(string1, string2);&lt;br /&gt;strlen(str) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. Returns the length of the string (not&lt;br /&gt;including the null terminator).&lt;br /&gt;Example:&lt;br /&gt;len = strlen(name);&lt;br /&gt;strncpy(str1, str2, n) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings and an integer argument. The third argument, an&lt;br /&gt;integer, indicates how many characters to copy from the second string to&lt;br /&gt;the first string. If string2 has fewer than n characters, string1 is padded&lt;br /&gt;with ‘\0’ characters.&lt;br /&gt;Example:&lt;br /&gt;strncpy(string1, string2, n);&lt;br /&gt;strstr(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Searches for the first occurrence of string2 in string1. If an occurrence of&lt;br /&gt;string2 is found, the function returns a pointer to it. Otherwise, it returns&lt;br /&gt;a NULL pointer (address 0).&lt;br /&gt;Example:&lt;br /&gt;cout &lt;&lt; strstr(string1, string2);&lt;br /&gt;tan(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the tangent of the&lt;br /&gt;argument. The argument should be an angle expressed in radians.&lt;br /&gt;Example:&lt;br /&gt;a = tan(m);&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions (continued)&lt;br /&gt;Function Details&lt;br /&gt;6 Appendix I: Header File and Library Function Reference&lt;br /&gt;tolower(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns the lowercase equivalent of its&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;ch = tolower(ch);&lt;br /&gt;toupper(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns the uppercase equivalent of its&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;ch = toupper(ch);&lt;br /&gt;Table I-2 Selected cstdlib functions&lt;br /&gt;Function Details&lt;br /&gt;atof(str) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to a&lt;br /&gt;double and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atof("3.14159");&lt;br /&gt;atoi(str) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to an&lt;br /&gt;int and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atoi("4569");&lt;br /&gt;atol(str) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. The function converts the string to a&lt;br /&gt;long and returns that value.&lt;br /&gt;Example:&lt;br /&gt;num = atol("5000000");&lt;br /&gt;exit(status) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts an int argument. Terminates the program and passes the value&lt;br /&gt;of the argument to the operating system.&lt;br /&gt;Example:&lt;br /&gt;exit(0);&lt;br /&gt;Table I-1 Alphabetical Listing of Selected Library Functions (continued)&lt;br /&gt;Function Details&lt;br /&gt;Appendix I: Header File and Library Function Reference 7&lt;br /&gt;rand() Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Generates a pseudorandom number.&lt;br /&gt;Example:&lt;br /&gt;x = rand();&lt;br /&gt;srand(m) Header File: cstdlib&lt;br /&gt;Description:&lt;br /&gt;Accepts an unsigned int argument. The argument is used as a seed&lt;br /&gt;value to randomize the results of the rand() function.&lt;br /&gt;Example:&lt;br /&gt;srand(m);&lt;br /&gt;Table I-3 Selected cmath Functions&lt;br /&gt;Function Details&lt;br /&gt;abs(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts an integer argument. Returns the absolute value of the argument&lt;br /&gt;as an integer.&lt;br /&gt;Example:&lt;br /&gt;a = abs(m);&lt;br /&gt;cos(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns the cosine of the argument. The&lt;br /&gt;argument should be an angle expressed in radians. The return type is&lt;br /&gt;double.&lt;br /&gt;Example:&lt;br /&gt;a = cos(m);&lt;br /&gt;exp(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Computes the exponential function of the&lt;br /&gt;argument, which is ex. The return type is double.&lt;br /&gt;Example:&lt;br /&gt;a = exp(m);&lt;br /&gt;fmod(m, n) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts two double arguments. Returns, as a double, the remainder of&lt;br /&gt;the first argument divided by the second argument. Works like the&lt;br /&gt;modulus operator, but the arguments are doubles. (The modulus operator&lt;br /&gt;only works with integers.) Take care not to pass zero as the second&lt;br /&gt;argument. Doing so would cause division by zero.&lt;br /&gt;Example:&lt;br /&gt;a = fmod(m, n);&lt;br /&gt;Table I-2 Selected cstdlib functions (continued)&lt;br /&gt;Function Details&lt;br /&gt;8 Appendix I: Header File and Library Function Reference&lt;br /&gt;log(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the natural logarithm&lt;br /&gt;of the argument.&lt;br /&gt;Example:&lt;br /&gt;a = log(m);&lt;br /&gt;log10(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the base-10 logarithm&lt;br /&gt;of the argument.&lt;br /&gt;Example:&lt;br /&gt;a = log10(m);&lt;br /&gt;pow(m, n) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts two double arguments. Returns the value of argument 1 raised&lt;br /&gt;to the power of argument 2.&lt;br /&gt;Example:&lt;br /&gt;a = pow(m, n);&lt;br /&gt;sin(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the sine of the&lt;br /&gt;argument. The argument should be an angle expressed in radians.&lt;br /&gt;Example:&lt;br /&gt;a = sin(m);&lt;br /&gt;sqrt(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the square root of the&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;a = sqrt(m);&lt;br /&gt;tan(m) Header File: cmath&lt;br /&gt;Description:&lt;br /&gt;Accepts a double argument. Returns, as a double, the tangent of the&lt;br /&gt;argument. The argument should be an angle expressed in radians.&lt;br /&gt;Example:&lt;br /&gt;a = tan(m);&lt;br /&gt;Table I-3 Selected cmath Functions (continued)&lt;br /&gt;Function Details&lt;br /&gt;Appendix I: Header File and Library Function Reference 9&lt;br /&gt;Table I-4 Selected cstring Functions&lt;br /&gt;Function Details&lt;br /&gt;strcat(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings as arguments. The function appends the contents&lt;br /&gt;of the second string to the first string. (The first string is altered; the&lt;br /&gt;second string is left unchanged.)&lt;br /&gt;Example:&lt;br /&gt;strcat(string1, string2);&lt;br /&gt;strcmp(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts pointers to two string arguments. If string1 and string2 are the&lt;br /&gt;same, this function returns 0. If string2 is alphabetically greater than&lt;br /&gt;string1, it returns a positive number. If string2 is alphabetically less than&lt;br /&gt;string1, it returns a negative number.&lt;br /&gt;Example:&lt;br /&gt;if (strcmp(string1, string2) == 0)&lt;br /&gt;cout &lt;&lt; "The strings are equal.\n";&lt;br /&gt;strcpy(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings as arguments. The function copies the second&lt;br /&gt;string to the first string. The second string is left unchanged.&lt;br /&gt;Example:&lt;br /&gt;strcpy(string1, string2);&lt;br /&gt;strlen(str) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts a C-string as an argument. Returns the length of the string (not&lt;br /&gt;including the null terminator)&lt;br /&gt;Example:&lt;br /&gt;len = strlen(name);&lt;br /&gt;strncpy(str1, str2, n) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Accepts two C-strings and an integer argument. The third argument, an&lt;br /&gt;integer, indicates how many characters to copy from the second string to&lt;br /&gt;the first string. If string2 has fewer than n characters, string1 is padded&lt;br /&gt;with ‘\0’ characters.&lt;br /&gt;Example:&lt;br /&gt;strncpy(string1, string2, n);&lt;br /&gt;strstr(str1, str2) Header File: cstring&lt;br /&gt;Description:&lt;br /&gt;Searches for the first occurrence of string2 in string1. If an occurrence of&lt;br /&gt;string2 is found, the function returns a pointer to it. Otherwise, it returns&lt;br /&gt;a NULL pointer (address 0).&lt;br /&gt;Example:&lt;br /&gt;cout &lt;&lt; strstr(string1, string2);&lt;br /&gt;10 Appendix I: Header File and Library Function Reference&lt;br /&gt;Table I-5 Selected cctype Functions&lt;br /&gt;Function Details&lt;br /&gt;isalnum(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a letter of the&lt;br /&gt;alphabet or a digit. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isalnum(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is alphanumeric.\n";&lt;br /&gt;isdigit(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a digit 0 - 9.&lt;br /&gt;Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isdigit(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is a digit.\n";&lt;br /&gt;islower(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a lowercase&lt;br /&gt;letter. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (islower(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is lowercase.\n";&lt;br /&gt;isprint(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a printable&lt;br /&gt;character (including a space). Returns false otherwise.&lt;br /&gt;Example:&lt;br /&gt;if (isprint(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is printable.\n";&lt;br /&gt;ispunct(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a printable&lt;br /&gt;character other than a digit, letter, or space. Returns false otherwise.&lt;br /&gt;Example:&lt;br /&gt;if (ispunct(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is punctuation.\n";&lt;br /&gt;isspace(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is a whitespace&lt;br /&gt;character. Whitespace characters are any of the following:&lt;br /&gt;• space................ ‘ ’&lt;br /&gt;• newline.............. ‘\n’&lt;br /&gt;• tab.................. ‘\t’&lt;br /&gt;• vertical tab......... ‘\v’&lt;br /&gt;Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isspace(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is whitespace.\n";&lt;br /&gt;Appendix I: Header File and Library Function Reference 11&lt;br /&gt;isupper(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns true if the argument is an uppercase&lt;br /&gt;letter. Otherwise, it returns false.&lt;br /&gt;Example:&lt;br /&gt;if (isupper(ch))&lt;br /&gt;cout &lt;&lt; ch &lt;&lt; " is uppercase.\n";&lt;br /&gt;tolower(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns the lowercase equivalent of its&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;ch = tolower(ch);&lt;br /&gt;toupper(ch) Header File: cctype&lt;br /&gt;Description:&lt;br /&gt;Accepts a char argument. Returns the uppercase equivalent of its&lt;br /&gt;argument.&lt;br /&gt;Example:&lt;br /&gt;ch = toupper(ch);&lt;br /&gt;Table I-5 Selected cctype Functions (continued)&lt;br /&gt;Function Details&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4013056093316696578?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4013056093316696578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4013056093316696578' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4013056093316696578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4013056093316696578'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/header-file-and-library-function.html' title='Header File and Library Function Reference'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-3176212160629443815</id><published>2008-12-11T07:10:00.001-08:00</published><updated>2008-12-22T21:29:32.539-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ADA'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Program code for Ada, 4th Edition</title><content type='html'>Chapter 2 Ada Concepts&lt;br /&gt;2.2 Overall structure&lt;br /&gt;with Sqrt, Simple_IO;&lt;br /&gt;procedure Print_Root is&lt;br /&gt;use Simple_IO;&lt;br /&gt;begin&lt;br /&gt;Put(Sqrt(2.5));&lt;br /&gt;end Print_Root;&lt;br /&gt;----&lt;br /&gt;with Sqrt, Simple_IO;&lt;br /&gt;procedure Print_Root is&lt;br /&gt;use Simple_IO;&lt;br /&gt;X: Float;&lt;br /&gt;begin&lt;br /&gt;Get(X);&lt;br /&gt;Put(Sqrt(X));&lt;br /&gt;end Print_Root;&lt;br /&gt;----&lt;br /&gt;with Sqrt, Simple_IO;&lt;br /&gt;procedure Print_Roots is&lt;br /&gt;use Simple_IO;&lt;br /&gt;X: Float;&lt;br /&gt;begin&lt;br /&gt;Put("Roots of various numbers");&lt;br /&gt;New_Line(2);&lt;br /&gt;loop&lt;br /&gt;Get(X);&lt;br /&gt;exit when X = 0.0;&lt;br /&gt;Put(" Root of ");&lt;br /&gt;Put(X);&lt;br /&gt;Put(" is ");&lt;br /&gt;if X &lt; 0.0 then&lt;br /&gt;Put("not calculable");&lt;br /&gt;else&lt;br /&gt;Put(Sqrt(X));&lt;br /&gt;end if;&lt;br /&gt;New_Line;&lt;br /&gt;end loop;&lt;br /&gt;New_Line;&lt;br /&gt;Put("Program finished");&lt;br /&gt;New_Line;&lt;br /&gt;end Print_Roots;&lt;br /&gt;----&lt;br /&gt;function Sqrt(F: Float) return Float is&lt;br /&gt;R: Float;&lt;br /&gt;begin&lt;br /&gt;-- compute value of Sqrt(F) in R&lt;br /&gt;return R;&lt;br /&gt;end Sqrt;&lt;br /&gt;----&lt;br /&gt;package Simple_IO is&lt;br /&gt;procedure Get(F: out Float);&lt;br /&gt;procedure Put(F: in Float);&lt;br /&gt;procedure Put(S: in String);&lt;br /&gt;procedure New_Line(N: in Integer := 1);&lt;br /&gt;end Simple_IO;&lt;br /&gt;----&lt;br /&gt;with Text_IO;&lt;br /&gt;package body Simple_IO is&lt;br /&gt;...&lt;br /&gt;procedure Get(F: out Float) is&lt;br /&gt;...&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end Get;&lt;br /&gt;-- other procedures similarly&lt;br /&gt;end Simple_IO;&lt;br /&gt;2.3 Errors and exceptions&lt;br /&gt;if X &lt; 0.0 then&lt;br /&gt;Put("not calculable");&lt;br /&gt;else&lt;br /&gt;Put(Sqrt(X));&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;begin&lt;br /&gt;Put(Sqrt(X));&lt;br /&gt;exception&lt;br /&gt;when Constraint_Error =&gt;&lt;br /&gt;Put("not calculable");&lt;br /&gt;end;&lt;br /&gt;2.4 The type model&lt;br /&gt;declare&lt;br /&gt;type Colour is (Red, Amber, Green);&lt;br /&gt;type Fish is (Cod, Hake, Plaice);&lt;br /&gt;X, Y: Colour;&lt;br /&gt;A, B: Fish;&lt;br /&gt;begin&lt;br /&gt;X := Red; -- ok&lt;br /&gt;A := Hake; -- ok&lt;br /&gt;B := X; -- illegal&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;type Light is new Colour;&lt;br /&gt;C: Colour;&lt;br /&gt;L: Light;&lt;br /&gt;begin&lt;br /&gt;L := Amber; -- the light amber, not the colour&lt;br /&gt;C := Colour(L); -- explicit conversion&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;2.5 Generics&lt;br /&gt;generic&lt;br /&gt;type Num is digits &lt;&gt;;&lt;br /&gt;package Float_IO is&lt;br /&gt;...&lt;br /&gt;procedure Get(Item: out Num; ... );&lt;br /&gt;procedure Put(Item: in Num; ... );&lt;br /&gt;...&lt;br /&gt;end Float_IO;&lt;br /&gt;----&lt;br /&gt;with Elementary_Functions_Exceptions;&lt;br /&gt;generic&lt;br /&gt;type Float_Type is digits &lt;&gt;;&lt;br /&gt;package Generic_Elementary_Functions is&lt;br /&gt;function Sqrt(X: Float_Type) return Float_Type;&lt;br /&gt;... -- and so on&lt;br /&gt;end;&lt;br /&gt;2.6 Input-output&lt;br /&gt;with IO_Exceptions;&lt;br /&gt;package Text_IO is&lt;br /&gt;type Count is ... -- an integer type&lt;br /&gt;...&lt;br /&gt;procedure New_Line(Spacing: in Count := 1);&lt;br /&gt;procedure Set_Col(To: in Count);&lt;br /&gt;function Col return Count;&lt;br /&gt;...&lt;br /&gt;procedure Get(Item: out Character);&lt;br /&gt;procedure Put(Item: in Character);&lt;br /&gt;procedure Put(Item: in String);&lt;br /&gt;...&lt;br /&gt;-- the package Float_IO outlined in the previous section&lt;br /&gt;-- plus a similar package Integer_IO&lt;br /&gt;...&lt;br /&gt;end Text_IO;&lt;br /&gt;----&lt;br /&gt;C: Character;&lt;br /&gt;...&lt;br /&gt;Put("Do you want to stop? Answer Y if so. ");&lt;br /&gt;Get(C);&lt;br /&gt;if C = 'Y' then&lt;br /&gt;...&lt;br /&gt;2.7 Running a program&lt;br /&gt;with Text_IO, Generic_Elementary_Functions;&lt;br /&gt;procedure Print_Roots is&lt;br /&gt;type Real is digits 7;&lt;br /&gt;X: Real;&lt;br /&gt;use Text_IO;&lt;br /&gt;package Real_IO is new Float_IO(Real);&lt;br /&gt;use Real_IO;&lt;br /&gt;package Real_Maths is&lt;br /&gt;new Generic_Elementary_Functions(Real);&lt;br /&gt;use Real_Maths;&lt;br /&gt;begin&lt;br /&gt;Put("Roots of various numbers");&lt;br /&gt;...&lt;br /&gt;... -- and so on as before&lt;br /&gt;...&lt;br /&gt;end Print_Roots;&lt;br /&gt;----&lt;br /&gt;with Text_IO, Generic_Elementary_Functions;&lt;br /&gt;package Etc is&lt;br /&gt;type Real is digits 7;&lt;br /&gt;package Real_IO is new Text_IO.Float_IO(Real);&lt;br /&gt;package Int_IO is new Text_IO.Integer_IO(Integer);&lt;br /&gt;package Real_Maths is&lt;br /&gt;new Generic_Elementary_Functions(Real);&lt;br /&gt;end Etc;&lt;br /&gt;----&lt;br /&gt;with Text_IO, Etc;&lt;br /&gt;use Text_IO, Etc;&lt;br /&gt;procedure Program is&lt;br /&gt;use Real_IO, Int_IO, Real_Maths; -- as required&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;end Program;&lt;br /&gt;Chapter 4 Scalar Types&lt;br /&gt;4.2 Blocks and scopes&lt;br /&gt;declare&lt;br /&gt;I: Integer := 0; -- declarations here&lt;br /&gt;begin&lt;br /&gt;I := I+1; -- statements here&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;I, J: Integer;&lt;br /&gt;begin&lt;br /&gt;... -- here I is the outer one&lt;br /&gt;declare&lt;br /&gt;I: Integer;&lt;br /&gt;begin&lt;br /&gt;... -- here I is the inner one&lt;br /&gt;end;&lt;br /&gt;... -- here I is the outer one&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;I: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;declare&lt;br /&gt;K: Integer := I;&lt;br /&gt;I: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;Exercise 4.2&lt;br /&gt;declare&lt;br /&gt;I: Integer := 7;&lt;br /&gt;J, K: Integer&lt;br /&gt;begin&lt;br /&gt;J := I+K;&lt;br /&gt;declare&lt;br /&gt;P: Integer=I;&lt;br /&gt;I, J: Integer;&lt;br /&gt;begin&lt;br /&gt;I := P+Q;&lt;br /&gt;J := P-Q;&lt;br /&gt;K := I*J;&lt;br /&gt;end;&lt;br /&gt;Put(K); -- output value of K&lt;br /&gt;end;&lt;br /&gt;4.6 Enumeration types&lt;br /&gt;type Colour is (Red, Amber, Green);&lt;br /&gt;type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);&lt;br /&gt;type Stone is (Amber, Beryl, Quartz);&lt;br /&gt;type Groom is (Tinker, Tailor, Soldier, Sailor,&lt;br /&gt;Rich_Man, Poor_Man, Beggar_Man, Thief);&lt;br /&gt;type Solo is (Alone);&lt;br /&gt;Chapter 5 Control Structures&lt;br /&gt;5.1 If statements&lt;br /&gt;if Hungry then&lt;br /&gt;Cook;&lt;br /&gt;Eat;&lt;br /&gt;Wash_Up;&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;if Today = Sun then&lt;br /&gt;Tomorrow := Mon;&lt;br /&gt;else&lt;br /&gt;Tomorrow := Day'Succ(Today);&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;if A = 0.0 then&lt;br /&gt;-- linear case&lt;br /&gt;else&lt;br /&gt;if B**2 - 4.0*A*C &gt;= 0.0 then&lt;br /&gt;-- real roots&lt;br /&gt;else&lt;br /&gt;-- complex roots&lt;br /&gt;end if;&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;if A = 0.0 then&lt;br /&gt;-- linear case&lt;br /&gt;elsif B**2 - 4.0*A*C &gt;= 0.0 then&lt;br /&gt;-- real roots&lt;br /&gt;else&lt;br /&gt;-- complex roots&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;if Order = Left then&lt;br /&gt;Turn_Left;&lt;br /&gt;else&lt;br /&gt;if Order = Right then&lt;br /&gt;Turn_Right;&lt;br /&gt;else&lt;br /&gt;if Order = Back then&lt;br /&gt;Turn_Back;&lt;br /&gt;end if;&lt;br /&gt;end if;&lt;br /&gt;end if;&lt;br /&gt;----&lt;br /&gt;if Order = Left then&lt;br /&gt;Turn_Left;&lt;br /&gt;elsif Order = Right then&lt;br /&gt;Turn_Right;&lt;br /&gt;elsif Order = Back then&lt;br /&gt;Turn_Back;&lt;br /&gt;end if;&lt;br /&gt;5.2 Case statements&lt;br /&gt;case Order is&lt;br /&gt;when Left =&gt; Turn_Left;&lt;br /&gt;when Right =&gt; Turn_Right;&lt;br /&gt;when Back =&gt; Turn_Back;&lt;br /&gt;when On =&gt; null;&lt;br /&gt;end case;&lt;br /&gt;----&lt;br /&gt;case Today is&lt;br /&gt;when Mon  Tues  Wed  Thu =&gt; Work;&lt;br /&gt;when Fri =&gt; Work; Party;&lt;br /&gt;when Sat  Sun =&gt; null;&lt;br /&gt;end case;&lt;br /&gt;----&lt;br /&gt;case Today is&lt;br /&gt;when Mon .. Thu =&gt; Work;&lt;br /&gt;when Fri =&gt; Work; Party;&lt;br /&gt;when others =&gt; null;&lt;br /&gt;end case;&lt;br /&gt;----&lt;br /&gt;case Today is&lt;br /&gt;when Weekday =&gt; Work;&lt;br /&gt;if Today = Fri then&lt;br /&gt;Party;&lt;br /&gt;end if;&lt;br /&gt;when others =&gt; null;&lt;br /&gt;end case;&lt;br /&gt;----&lt;br /&gt;case Weekday'(Today) is&lt;br /&gt;when Mon .. Thu =&gt; Work;&lt;br /&gt;when Fri =&gt; Work; Party;&lt;br /&gt;end case;&lt;br /&gt;5.3 Loop statements&lt;br /&gt;loop&lt;br /&gt;Work;&lt;br /&gt;Eat;&lt;br /&gt;Sleep;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;E: Real := 1.0;&lt;br /&gt;I: Integer := 0;&lt;br /&gt;Term: Real := 1.0;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;I := I + 1;&lt;br /&gt;Term := Term / Real(I);&lt;br /&gt;E := E + Term;&lt;br /&gt;end loop;&lt;br /&gt;...&lt;br /&gt;----&lt;br /&gt;loop&lt;br /&gt;if I = N then exit; end if;&lt;br /&gt;I := I + 1;&lt;br /&gt;Term := Term / Real(I);&lt;br /&gt;E := E + Term;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;loop&lt;br /&gt;exit when I = N;&lt;br /&gt;I := I + 1;&lt;br /&gt;Term := Term / Real(I);&lt;br /&gt;E := E + Term;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;while I /= N loop&lt;br /&gt;I := I + 1;&lt;br /&gt;Term := Term / Real(I);&lt;br /&gt;E := E + Term;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;for I in 1 .. N loop&lt;br /&gt;Term := Term / Real(I);&lt;br /&gt;E := E + Term;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;for I in 1 .. N loop&lt;br /&gt;for J in 1 .. M loop&lt;br /&gt;-- if values of I and J satisfy&lt;br /&gt;-- some condition then leave nested loop&lt;br /&gt;end loop;&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;Search:&lt;br /&gt;for I in 1 .. N loop&lt;br /&gt;for J in 1 .. M loop&lt;br /&gt;if condition_OK then&lt;br /&gt;I_Value := I;&lt;br /&gt;J_Value := J;&lt;br /&gt;exit Search;&lt;br /&gt;end if;&lt;br /&gt;end loop;&lt;br /&gt;end loop Search;&lt;br /&gt;-- control passes here&lt;br /&gt;Chapter 6 Composite Types&lt;br /&gt;6.1 Arrays&lt;br /&gt;for I in A'Range loop&lt;br /&gt;A(I) := 0.0;&lt;br /&gt;end loop;&lt;br /&gt;for I in AA'Range(1) loop&lt;br /&gt;for J in AA'Range(2) loop&lt;br /&gt;AA(I, J) := 0.0;&lt;br /&gt;end loop;&lt;br /&gt;end loop;&lt;br /&gt;6.3 Array aggregates&lt;br /&gt;type Event is (Birth, Accession, Death);&lt;br /&gt;type Monarch is (William_I, William_II, Henry_I, ... ,&lt;br /&gt;Victoria, Edward_VII, George_V, ... );&lt;br /&gt;...&lt;br /&gt;Royal_Events: constant array (Monarch, Event) of Integer&lt;br /&gt;:= (William_I =&gt; (1027, 1066, 1087),&lt;br /&gt;William_II =&gt; (1056, 1087, 1100),&lt;br /&gt;Henry_I =&gt; (1068, 1100, 1135),&lt;br /&gt;...&lt;br /&gt;Victoria =&gt; (1819, 1837, 1901),&lt;br /&gt;Edward_VII =&gt; (1841, 1901, 1910),&lt;br /&gt;George_V =&gt; (1865, 1910, 1936),&lt;br /&gt;... );&lt;br /&gt;6.5 Arrays of arrays and slices&lt;br /&gt;Zoo: constant String_Array := ("aardvark",&lt;br /&gt;"baboon ",&lt;br /&gt;"camel ",&lt;br /&gt;"dolphin ",&lt;br /&gt;"elephant",&lt;br /&gt;...&lt;br /&gt;"zebra ");&lt;br /&gt;6.6 One-dimensional array operations&lt;br /&gt;White: constant Colour := (F, F, F);&lt;br /&gt;Red: constant Colour := (T, F, F);&lt;br /&gt;Yellow: constant Colour := (F, T, F);&lt;br /&gt;Blue: constant Colour := (F, F, T);&lt;br /&gt;Green: constant Colour := (F, T, T);&lt;br /&gt;Purple: constant Colour := (T, F, T);&lt;br /&gt;Orange: constant Colour := (T, T, F);&lt;br /&gt;Black: constant Colour := (T, T, T);&lt;br /&gt;6.7 Records&lt;br /&gt;type Month_Name is (Jan, Feb, Mar, Apr, May, Jun, Jul,&lt;br /&gt;Aug, Sep, Oct, Nov, Dec);&lt;br /&gt;type Date is&lt;br /&gt;record&lt;br /&gt;Day: Integer range 1 .. 31;&lt;br /&gt;Month: Month_Name;&lt;br /&gt;Year: Integer;&lt;br /&gt;end record;&lt;br /&gt;Chapter 7 Subprograms&lt;br /&gt;7.1 Functions&lt;br /&gt;function Sqrt(X: Real) return Real is&lt;br /&gt;R: Real;&lt;br /&gt;begin&lt;br /&gt;-- compute value of Sqrt(X) in R&lt;br /&gt;return R;&lt;br /&gt;end Sqrt;&lt;br /&gt;----&lt;br /&gt;function Sign(X: Integer) return Integer is&lt;br /&gt;begin&lt;br /&gt;if X &gt; 0 then&lt;br /&gt;return +1;&lt;br /&gt;elsif X &lt; 0 then&lt;br /&gt;return -1;&lt;br /&gt;else&lt;br /&gt;return 0;&lt;br /&gt;end if;&lt;br /&gt;end Sign;&lt;br /&gt;----&lt;br /&gt;function Factorial(N: Positive) return Positive is&lt;br /&gt;begin&lt;br /&gt;if N = 1 then&lt;br /&gt;return 1;&lt;br /&gt;else&lt;br /&gt;return N * Factorial(N-1);&lt;br /&gt;end if;&lt;br /&gt;end Factorial;&lt;br /&gt;----&lt;br /&gt;function Sum(A: Vector) return Real is&lt;br /&gt;Result: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in A'Range loop&lt;br /&gt;Result := Result + A(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end Sum;&lt;br /&gt;----&lt;br /&gt;function Inner(A, B: Vector) return Real is&lt;br /&gt;Result: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in A'Range loop&lt;br /&gt;Result := Result + A(I)*B(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end Inner;&lt;br /&gt;----&lt;br /&gt;function Rev(X: Vector) return Vector is&lt;br /&gt;R: Vector(X'Range);&lt;br /&gt;begin&lt;br /&gt;for I in X'Range loop&lt;br /&gt;R(I) := X(X'First+X'Last-I);&lt;br /&gt;end loop;&lt;br /&gt;return R;&lt;br /&gt;end Rev;&lt;br /&gt;7.2 Operators&lt;br /&gt;function "*" (A, B: Vector) return Real is&lt;br /&gt;Result: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in A'Range loop&lt;br /&gt;Result := Result + A(I)*B(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end "*";&lt;br /&gt;----&lt;br /&gt;function "+" (A: Vector) return Real is&lt;br /&gt;Result: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in A'Range loop&lt;br /&gt;Result := Result + A(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end "+";&lt;br /&gt;7.3 Procedures&lt;br /&gt;declare&lt;br /&gt;A: constant Integer := 2+P; -- in&lt;br /&gt;B: constant Integer := 37; -- in&lt;br /&gt;C: Integer; -- out&lt;br /&gt;begin&lt;br /&gt;C := A+B; -- body&lt;br /&gt;Q := C; -- out&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;X: Integer := I;&lt;br /&gt;begin&lt;br /&gt;X := X+1;&lt;br /&gt;I := X;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;I: Integer;&lt;br /&gt;A: array (1 .. 10) of Integer;&lt;br /&gt;procedure Silly(X: in out Integer) is&lt;br /&gt;begin&lt;br /&gt;I := I+1;&lt;br /&gt;X := X+1;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;procedure Quadratic(A, B, C: in Real; Root_1, Root_2:&lt;br /&gt;out Real; OK: out Boolean) is&lt;br /&gt;D: constant Real := B**2 - 4.0*A*C;&lt;br /&gt;begin&lt;br /&gt;if D &lt; 0.0 or A = 0.0 then&lt;br /&gt;OK := False;&lt;br /&gt;return;&lt;br /&gt;end if;&lt;br /&gt;Root_1 := (-B+Sqrt(D)) / (2.0*A);&lt;br /&gt;Root_2 := (-B-Sqrt(D)) / (2.0*A);&lt;br /&gt;OK := True;&lt;br /&gt;end Quadratic;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;L, M, N: Real;&lt;br /&gt;P, Q: Real;&lt;br /&gt;Status: Boolean;&lt;br /&gt;begin&lt;br /&gt;-- sets values into L, M and N&lt;br /&gt;Quadratic(L, M, N, P, Q, Status);&lt;br /&gt;if Status then&lt;br /&gt;-- roots are in P and Q&lt;br /&gt;else&lt;br /&gt;-- fails&lt;br /&gt;end if;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;begin&lt;br /&gt;OK := D &gt;= 0.0 and A /= 0.0;&lt;br /&gt;if not OK then&lt;br /&gt;return;&lt;br /&gt;end if;&lt;br /&gt;Root_1 := ... ;&lt;br /&gt;Root_2 := ... ;&lt;br /&gt;end Quadratic;&lt;br /&gt;Exercise 7.3&lt;br /&gt;A: Vector(1 .. 1);&lt;br /&gt;procedure P(V: Vector) is&lt;br /&gt;begin&lt;br /&gt;A(1) := V(1)+V(1);&lt;br /&gt;A(1) := V(1)+V(1);&lt;br /&gt;end;&lt;br /&gt;...&lt;br /&gt;A(1) := 1.0;&lt;br /&gt;P(A);&lt;br /&gt;7.6 Declarations, scopes and visibility&lt;br /&gt;procedure F( ... ); -- declaration of F&lt;br /&gt;procedure G( ... ) is -- body of G&lt;br /&gt;begin&lt;br /&gt;F( ... );&lt;br /&gt;end G;&lt;br /&gt;procedure F( ... ) is -- body of F repeats&lt;br /&gt;begin -- its specification&lt;br /&gt;G( ... );&lt;br /&gt;end F;&lt;br /&gt;----&lt;br /&gt;procedure P is&lt;br /&gt;I: Integer := 0;&lt;br /&gt;procedure Q is&lt;br /&gt;K: Integer := I;&lt;br /&gt;I: Integer;&lt;br /&gt;J: Integer;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end Q;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end P;&lt;br /&gt;----&lt;br /&gt;Outer:&lt;br /&gt;declare&lt;br /&gt;I: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;declare&lt;br /&gt;K: Integer := I;&lt;br /&gt;I: Integer;&lt;br /&gt;J: Integer := Outer.I;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;end Outer;&lt;br /&gt;----&lt;br /&gt;L:&lt;br /&gt;for I in AA'Range(1) loop&lt;br /&gt;for I in AA'Range(2) loop&lt;br /&gt;AA(L.I, I) := 0.0;&lt;br /&gt;end loop;&lt;br /&gt;end loop L;&lt;br /&gt;Chapter 8 Overall Structure&lt;br /&gt;8.1 Packages&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;function Pop return Integer is&lt;br /&gt;begin&lt;br /&gt;Top := Top-1;&lt;br /&gt;return S(Top+1);&lt;br /&gt;end Pop;&lt;br /&gt;----&lt;br /&gt;package Stack is -- specification&lt;br /&gt;procedure Push(X: Integer);&lt;br /&gt;function Pop return Integer;&lt;br /&gt;end Stack;&lt;br /&gt;package body Stack is -- body&lt;br /&gt;Max: constant := 100;&lt;br /&gt;S: array (1 .. Max) of Integer;&lt;br /&gt;Top: Integer range 0 .. Max;&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;function Pop return Integer is&lt;br /&gt;begin&lt;br /&gt;Top := Top-1;&lt;br /&gt;return S(Top+1);&lt;br /&gt;end Pop;&lt;br /&gt;begin -- initialization&lt;br /&gt;Top := 0;&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;package Stack is -- specification&lt;br /&gt;... -- and&lt;br /&gt;... -- body&lt;br /&gt;end Stack;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Stack.Push(M);&lt;br /&gt;...&lt;br /&gt;N := Stack.Pop;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Stack;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(M);&lt;br /&gt;...&lt;br /&gt;N := Pop;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package Diurnal is&lt;br /&gt;type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);&lt;br /&gt;subtype Weekday is Day range Mon .. Fri;&lt;br /&gt;Tomorrow: constant array (Day) of Day&lt;br /&gt;:= (Tue, Wed, Thu, Fri, Sat, Sun, Mon);&lt;br /&gt;Next_Work_Day: constant array (Weekday) of Weekday&lt;br /&gt;:= (Tue, Wed, Thu, Fri, Mon);&lt;br /&gt;end Diurnal;&lt;br /&gt;8.2 Library units&lt;br /&gt;package Stack is&lt;br /&gt;...&lt;br /&gt;end Stack;&lt;br /&gt;package body Stack is&lt;br /&gt;...&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;with Stack;&lt;br /&gt;procedure Main is&lt;br /&gt;use Stack;&lt;br /&gt;M, N: Integer;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(M);&lt;br /&gt;...&lt;br /&gt;N := Pop;&lt;br /&gt;...&lt;br /&gt;end Main;&lt;br /&gt;8.3 Subunits&lt;br /&gt;package body Stack is&lt;br /&gt;Max: constant := 100;&lt;br /&gt;S: array (1 .. Max) of Integer;&lt;br /&gt;Top: Integer range 0 .. Max;&lt;br /&gt;procedure Push(X: Integer) is separate; -- stub&lt;br /&gt;function Pop return Integer is separate; -- stub&lt;br /&gt;begin&lt;br /&gt;Top := 0;&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;separate (Stack)&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;8.4 Scope and visibility&lt;br /&gt;declare&lt;br /&gt;type R is&lt;br /&gt;record&lt;br /&gt;I: Integer;&lt;br /&gt;end record;&lt;br /&gt;type S is&lt;br /&gt;record&lt;br /&gt;I: Integer;&lt;br /&gt;end record;&lt;br /&gt;AR: R;&lt;br /&gt;AS: S;&lt;br /&gt;I: Integer;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;I := AR.I+AS.I; -- legal&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package P1 is&lt;br /&gt;package P2 is&lt;br /&gt;...&lt;br /&gt;end P2;&lt;br /&gt;...&lt;br /&gt;end P1;&lt;br /&gt;8.5 Renaming&lt;br /&gt;declare&lt;br /&gt;procedure S_Push(X: Integer) renames Stack.Push;&lt;br /&gt;function S_Pop return Integer renames Stack.Pop;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;S_Push(M);&lt;br /&gt;...&lt;br /&gt;N := S_Pop;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;for I in People'Range loop&lt;br /&gt;Put(People(I).Birth.Day); Put(":");&lt;br /&gt;Put(Month_Name'Pos(People(I).Birth.Month)+1);&lt;br /&gt;Put(":");&lt;br /&gt;Put(People(I).Birth.Year);&lt;br /&gt;end loop;&lt;br /&gt;----&lt;br /&gt;for I in People'Range loop&lt;br /&gt;declare&lt;br /&gt;D: Date renames People(I).Birth;&lt;br /&gt;begin&lt;br /&gt;Put(D.Day); Put(":");&lt;br /&gt;Put(Month_Name'Pos(D.Month)+1);&lt;br /&gt;Put(":");&lt;br /&gt;Put(D.Year);&lt;br /&gt;end;&lt;br /&gt;end loop;&lt;br /&gt;Chapter 9 Private Types&lt;br /&gt;9.1 Normal private types&lt;br /&gt;package Complex_Numbers is&lt;br /&gt;type Complex is&lt;br /&gt;record&lt;br /&gt;Rl, Im: Real;&lt;br /&gt;end record;&lt;br /&gt;I: constant Complex := (0.0, 1.0);&lt;br /&gt;function "+" (X: Complex) return Complex; -- unary +&lt;br /&gt;function "-" (X: Complex) return Complex; -- unary -&lt;br /&gt;function "+" (X, Y: Complex) return Complex;&lt;br /&gt;function "-" (X, Y: Complex) return Complex;&lt;br /&gt;function "*" (X, Y: Complex) return Complex;&lt;br /&gt;function "/" (X, Y: Complex) return Complex;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package Complex_Numbers is&lt;br /&gt;type Complex is private;&lt;br /&gt;I: constant Complex;&lt;br /&gt;function "+" (X: Complex) return Complex;&lt;br /&gt;function "-" (X: Complex) return Complex;&lt;br /&gt;function "+" (X, Y: Complex) return Complex;&lt;br /&gt;function "-" (X, Y: Complex) return Complex;&lt;br /&gt;function "*" (X, Y: Complex) return Complex;&lt;br /&gt;function "/" (X, Y: Complex) return Complex;&lt;br /&gt;function Cons(R, I: Real) return Complex;&lt;br /&gt;function Rl_Part(X: Complex) return Real;&lt;br /&gt;function Im_Part(X: Complex) return Real;&lt;br /&gt;private&lt;br /&gt;type Complex is&lt;br /&gt;record&lt;br /&gt;Rl, Im: Real;&lt;br /&gt;end record;&lt;br /&gt;I: constant Complex := (0.0, 1.0);&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package body Complex_Numbers is&lt;br /&gt;-- unary + -&lt;br /&gt;function "+" (X, Y: Complex) return Complex is&lt;br /&gt;begin&lt;br /&gt;return (X.Rl + Y.Rl, X.Im + Y.Im);&lt;br /&gt;end "+";&lt;br /&gt;-- plus - * / similarly&lt;br /&gt;function Cons(R, I: Real) return Complex is&lt;br /&gt;begin&lt;br /&gt;return (R, I);&lt;br /&gt;end Cons;&lt;br /&gt;function Rl_Part(X: Complex) return Real is&lt;br /&gt;begin&lt;br /&gt;return X.Rl;&lt;br /&gt;end Rl_Part;&lt;br /&gt;-- Im_Part similarly&lt;br /&gt;end Complex_Numbers;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Complex_Numbers;&lt;br /&gt;C, D: Complex;&lt;br /&gt;R, S: Real;&lt;br /&gt;begin&lt;br /&gt;C := Cons(1.5, -6.0);&lt;br /&gt;D := C + I; -- Complex +&lt;br /&gt;R := Rl_Part(D) + 6.0; -- Real +&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;private&lt;br /&gt;Pi: constant := 3.14159_26536;&lt;br /&gt;type Complex is&lt;br /&gt;record&lt;br /&gt;R: Real;&lt;br /&gt;Theta: Real range 0.0 .. 2.0*Pi;&lt;br /&gt;end record;&lt;br /&gt;I: constant Complex := (1.0, 0.5*Pi);&lt;br /&gt;end;&lt;br /&gt;Exercise 9.1&lt;br /&gt;package Rational_Numbers is&lt;br /&gt;type Rational is private;&lt;br /&gt;function "+" (X: Rational) return Rational; -- unary +&lt;br /&gt;function "-" (X: Rational) return Rational; -- unary -&lt;br /&gt;function "+" (X, Y: Rational) return Rational;&lt;br /&gt;function "-" (X, Y: Rational) return Rational;&lt;br /&gt;function "*" (X, Y: Rational) return Rational;&lt;br /&gt;function "/" (X, Y: Rational) return Rational;&lt;br /&gt;function "/" (X: Integer; Y: Positive) return Rational;&lt;br /&gt;function Numerator(R: Rational) return Integer;&lt;br /&gt;function Denominator(R: Rational) return Positive;&lt;br /&gt;private&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;9.2 Limited private types&lt;br /&gt;package Stacks is&lt;br /&gt;type Stack is limited private;&lt;br /&gt;procedure Push(S: in out Stack; X: in Integer);&lt;br /&gt;procedure Pop(S: in out Stack; X: out Integer);&lt;br /&gt;function "=" (S, T: Stack) return Boolean;&lt;br /&gt;private&lt;br /&gt;Max: constant := 100;&lt;br /&gt;type Integer_Vector is array (Integer range &lt;&gt;) of Integer;&lt;br /&gt;type Stack is&lt;br /&gt;record&lt;br /&gt;S: Integer_Vector(1 .. Max);&lt;br /&gt;Top: Integer range 0 .. Max := 0;&lt;br /&gt;end record;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package body Stacks is&lt;br /&gt;procedure Push(S: in out Stack; X: in Integer) is&lt;br /&gt;begin&lt;br /&gt;S.Top := S.Top+1;&lt;br /&gt;S.S(S.Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;procedure Pop(S: in out Stack; X: out Integer) is&lt;br /&gt;begin&lt;br /&gt;X := S.S(S.Top);&lt;br /&gt;S.Top := S.Top-1;&lt;br /&gt;end Pop;&lt;br /&gt;function "=" (S, T: Stack) return Boolean is&lt;br /&gt;begin&lt;br /&gt;if S.Top /= T.Top then&lt;br /&gt;return False;&lt;br /&gt;end if;&lt;br /&gt;for I in 1 .. S.Top loop&lt;br /&gt;if S.S(I) /= T.S(I) then&lt;br /&gt;return False;&lt;br /&gt;end if;&lt;br /&gt;end loop;&lt;br /&gt;return True;&lt;br /&gt;end "=";&lt;br /&gt;end Stacks;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Stacks;&lt;br /&gt;St: Stack;&lt;br /&gt;Empty: Stack;&lt;br /&gt;...&lt;br /&gt;begin&lt;br /&gt;Push(St, N);&lt;br /&gt;...&lt;br /&gt;Pop(St, M);&lt;br /&gt;...&lt;br /&gt;if St = Empty then&lt;br /&gt;...&lt;br /&gt;end if;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;9.3 Resource management&lt;br /&gt;package Key_Manager is&lt;br /&gt;type Key is limited private;&lt;br /&gt;procedure Get_Key(K: in out Key);&lt;br /&gt;procedure Return_Key(K: in out Key);&lt;br /&gt;function Valid(K: Key) return Boolean;&lt;br /&gt;...&lt;br /&gt;procedure Action(K: in Key; ... );&lt;br /&gt;...&lt;br /&gt;private&lt;br /&gt;Max: constant := 100; -- number of keys&lt;br /&gt;subtype Key_Code is Integer range 0 .. Max;&lt;br /&gt;type Key is&lt;br /&gt;record&lt;br /&gt;Code: Key_Code := 0;&lt;br /&gt;end record;&lt;br /&gt;end;&lt;br /&gt;package body Key_Manager is&lt;br /&gt;Free: array (Key_Code range 1 .. Key_Code'Last) of&lt;br /&gt;Boolean := (others =&gt; True);&lt;br /&gt;function Valid(K: Key) return Boolean is&lt;br /&gt;begin&lt;br /&gt;return K.Code /= 0;&lt;br /&gt;end Valid;&lt;br /&gt;procedure Get_Key(K: in out Key) is&lt;br /&gt;begin&lt;br /&gt;if K.Code = 0 then&lt;br /&gt;for I in Free'Range loop&lt;br /&gt;if Free(I) then&lt;br /&gt;Free(I) := False;&lt;br /&gt;K.Code := I;&lt;br /&gt;return;&lt;br /&gt;end if;&lt;br /&gt;end loop;&lt;br /&gt;-- all keys in use&lt;br /&gt;end if;&lt;br /&gt;end Get_Key;&lt;br /&gt;procedure Return_Key(K: in out Key) is&lt;br /&gt;begin&lt;br /&gt;if K.Code /= 0 then&lt;br /&gt;Free(K.Code) := True;&lt;br /&gt;K.Code := 0;&lt;br /&gt;end if;&lt;br /&gt;end Return_Key;&lt;br /&gt;...&lt;br /&gt;procedure Action(K: in Key; ... ) is&lt;br /&gt;begin&lt;br /&gt;if Valid(K) then&lt;br /&gt;...&lt;br /&gt;end Action;&lt;br /&gt;end Key_Manager;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Key_Manager;&lt;br /&gt;My_Key: Key;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Get_Key(My_Key);&lt;br /&gt;...&lt;br /&gt;Action(My_Key, ... );&lt;br /&gt;...&lt;br /&gt;Return_Key(My_Key);&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;Exercise 9.3&lt;br /&gt;package Bank is&lt;br /&gt;subtype Money is Natural;&lt;br /&gt;type Key is limited private;&lt;br /&gt;procedure Open_Account(K: in out Key; M: in Money);&lt;br /&gt;-- open account with initial deposit M&lt;br /&gt;procedure Close_Account(K: in out Key; M: out Money);&lt;br /&gt;-- close account and return balance&lt;br /&gt;procedure Deposit(K: in Key; M: in Money);&lt;br /&gt;-- deposit amount M&lt;br /&gt;procedure Withdraw(K: in out Key; M in out Money);&lt;br /&gt;-- withdraw amount M; if account does not contain M&lt;br /&gt;-- then return what is there and close account&lt;br /&gt;function Statement(K: Key) return Money;&lt;br /&gt;-- returns a statement of current balance&lt;br /&gt;function Valid(K: Key) return Boolean;&lt;br /&gt;-- checks the key is valid&lt;br /&gt;private&lt;br /&gt;...&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Key_Manager;&lt;br /&gt;My_Key: Key;&lt;br /&gt;procedure Cheat(Copy: in out Key) is&lt;br /&gt;begin&lt;br /&gt;Return_Key(My_Key);&lt;br /&gt;Action(Copy, ... );&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;begin&lt;br /&gt;Get_Key(My_Key);&lt;br /&gt;Cheat(My_Key);&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Key_Manager;&lt;br /&gt;My_Key: Key;&lt;br /&gt;procedure Destroy(K: out Key) is&lt;br /&gt;begin&lt;br /&gt;null;&lt;br /&gt;end;&lt;br /&gt;begin&lt;br /&gt;Get_Key(My_Key);&lt;br /&gt;Destroy(My_Key);&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;Chapter 10 Exceptions&lt;br /&gt;10.1 Handling exceptions&lt;br /&gt;begin&lt;br /&gt;-- sequence of statements&lt;br /&gt;exception&lt;br /&gt;when Constraint_Error =&gt;&lt;br /&gt;-- do something&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;begin&lt;br /&gt;Tomorrow := Day'Succ(Today);&lt;br /&gt;exception&lt;br /&gt;when Constraint_Error =&gt;&lt;br /&gt;Tomorrow := Day'First;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;begin&lt;br /&gt;-- sequence of statements&lt;br /&gt;exception&lt;br /&gt;when Numeric_Error  Constraint_Error =&gt;&lt;br /&gt;Put("Numeric or Constraint Error occurred");&lt;br /&gt;...&lt;br /&gt;when Storage_Error =&gt;&lt;br /&gt;Put("Ran out of space");&lt;br /&gt;...&lt;br /&gt;when others =&gt;&lt;br /&gt;Put("Something else went wrong");&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;function Tomorrow(Today: Day) return Day is&lt;br /&gt;begin&lt;br /&gt;return Day'Succ(Today);&lt;br /&gt;exception&lt;br /&gt;when Constraint_Error =&gt;&lt;br /&gt;return Day'First;&lt;br /&gt;end Tomorrow;&lt;br /&gt;10.2 Declaring and raising exceptions&lt;br /&gt;declare&lt;br /&gt;use Stack;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(M);&lt;br /&gt;...&lt;br /&gt;N := Pop;&lt;br /&gt;...&lt;br /&gt;exception&lt;br /&gt;when Constraint_Error =&gt;&lt;br /&gt;-- stack manipulation incorrect?&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package Stack is&lt;br /&gt;Error: exception;&lt;br /&gt;procedure Push(X: Integer);&lt;br /&gt;function Pop return Integer;&lt;br /&gt;end Stack;&lt;br /&gt;package body Stack is&lt;br /&gt;Max: constant := 100;&lt;br /&gt;S: array (1 .. Max) of Integer;&lt;br /&gt;Top: Integer range 0 .. Max;&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;if Top = Max then&lt;br /&gt;raise Error;&lt;br /&gt;end if;&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;function Pop return Integer is&lt;br /&gt;begin&lt;br /&gt;if Top = 0 then&lt;br /&gt;raise Error;&lt;br /&gt;end if;&lt;br /&gt;Top := Top-1;&lt;br /&gt;return S(Top+1);&lt;br /&gt;end Pop;&lt;br /&gt;begin&lt;br /&gt;Top := 0;&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Stack;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(M);&lt;br /&gt;...&lt;br /&gt;N := Pop;&lt;br /&gt;...&lt;br /&gt;exception&lt;br /&gt;when Error =&gt;&lt;br /&gt;-- stack manipulation incorrect&lt;br /&gt;when others =&gt;&lt;br /&gt;-- something else went wrong&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Stack, Key_Manager;&lt;br /&gt;My_Key: Key;&lt;br /&gt;procedure Clean_Up is&lt;br /&gt;begin&lt;br /&gt;Reset;&lt;br /&gt;Return_Key(My_Key);&lt;br /&gt;end;&lt;br /&gt;begin&lt;br /&gt;Get_Key(My_Key);&lt;br /&gt;...&lt;br /&gt;Push(M);&lt;br /&gt;...&lt;br /&gt;Action(My_Key, ... );&lt;br /&gt;...&lt;br /&gt;N := Pop;&lt;br /&gt;...&lt;br /&gt;Return_Key(My_Key);&lt;br /&gt;exception&lt;br /&gt;when Error =&gt;&lt;br /&gt;Put("Stack used incorrectly");&lt;br /&gt;Clean_Up;&lt;br /&gt;when others =&gt;&lt;br /&gt;Put("Something else went wrong");&lt;br /&gt;Clean_Up;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;procedure Reset is&lt;br /&gt;Junk: Integer;&lt;br /&gt;use Stack;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;Junk := Pop;&lt;br /&gt;end loop;&lt;br /&gt;exception&lt;br /&gt;when Error =&gt;&lt;br /&gt;null;&lt;br /&gt;end Reset;&lt;br /&gt;----&lt;br /&gt;exception&lt;br /&gt;when Error =&gt;&lt;br /&gt;Put("Stack used incorrectly");&lt;br /&gt;Clean_Up;&lt;br /&gt;raise Another_Error;&lt;br /&gt;when others =&gt;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Stack;&lt;br /&gt;OK: Boolean;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(M, OK);&lt;br /&gt;if not OK then ... end if;&lt;br /&gt;...&lt;br /&gt;Pop(N, OK);&lt;br /&gt;if not OK then ... end if;&lt;br /&gt;end;&lt;br /&gt;10.3 Checking and exceptions&lt;br /&gt;...&lt;br /&gt;S: array (1 .. Max) of Integer;&lt;br /&gt;Top: Integer range 0 .. Max;&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;----&lt;br /&gt;procedure Push(X: Integer) is&lt;br /&gt;begin&lt;br /&gt;if Top = Max then&lt;br /&gt;raise Error;&lt;br /&gt;end if;&lt;br /&gt;Top := Top+1;&lt;br /&gt;S(Top) := X;&lt;br /&gt;end Push;&lt;br /&gt;10.4 Scope of exceptions&lt;br /&gt;declare&lt;br /&gt;procedure P is&lt;br /&gt;X: exception;&lt;br /&gt;begin&lt;br /&gt;raise X;&lt;br /&gt;end P;&lt;br /&gt;begin&lt;br /&gt;P;&lt;br /&gt;exception&lt;br /&gt;when others =&gt;&lt;br /&gt;-- X handled here&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;package P is&lt;br /&gt;procedure F;&lt;br /&gt;procedure H;&lt;br /&gt;end P;&lt;br /&gt;procedure G is&lt;br /&gt;begin&lt;br /&gt;P.H;&lt;br /&gt;exception&lt;br /&gt;when others =&gt;&lt;br /&gt;raise;&lt;br /&gt;end G;&lt;br /&gt;package body P is&lt;br /&gt;X: exception;&lt;br /&gt;procedure F is&lt;br /&gt;begin&lt;br /&gt;G;&lt;br /&gt;exception&lt;br /&gt;when X =&gt;&lt;br /&gt;Put("Got it!");&lt;br /&gt;end F;&lt;br /&gt;procedure H is&lt;br /&gt;begin&lt;br /&gt;raise X;&lt;br /&gt;end H;&lt;br /&gt;end P;&lt;br /&gt;begin&lt;br /&gt;P.F;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;procedure F(N: Integer) is&lt;br /&gt;X: exception;&lt;br /&gt;begin&lt;br /&gt;if N = 0 then&lt;br /&gt;raise X;&lt;br /&gt;else&lt;br /&gt;F(N-1);&lt;br /&gt;end if;&lt;br /&gt;exception&lt;br /&gt;when X =&gt;&lt;br /&gt;Put("Got it!");&lt;br /&gt;raise;&lt;br /&gt;when others =&gt;&lt;br /&gt;null;&lt;br /&gt;end F;&lt;br /&gt;----&lt;br /&gt;procedure Withdraw (K: in out Key; M: in out Money) is&lt;br /&gt;begin&lt;br /&gt;if Valid (K) then&lt;br /&gt;if M &gt; amount remaining then&lt;br /&gt;M := amount remaining;&lt;br /&gt;Free(K.Code) := True;&lt;br /&gt;K.Code := 0;&lt;br /&gt;raise Alarm;&lt;br /&gt;else&lt;br /&gt;...&lt;br /&gt;end if;&lt;br /&gt;end if;&lt;br /&gt;end Withdraw;&lt;br /&gt;Exercise 10.4&lt;br /&gt;procedure P is&lt;br /&gt;begin&lt;br /&gt;P;&lt;br /&gt;exception&lt;br /&gt;when Storage_Error =&gt;&lt;br /&gt;P;&lt;br /&gt;end P;&lt;br /&gt;Chapter 11 Advanced Types&lt;br /&gt;11.1 Discriminated record types&lt;br /&gt;function Trace(M: Matrix) return Real is&lt;br /&gt;Sum: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;if M'First(1) /= M'First(2) or M'Last(1) /= M'Last(2) then&lt;br /&gt;raise Non_Square;&lt;br /&gt;end if;&lt;br /&gt;for I in M'Range loop&lt;br /&gt;Sum := Sum + M(I, I);&lt;br /&gt;end loop;&lt;br /&gt;return Sum;&lt;br /&gt;end Trace;&lt;br /&gt;----&lt;br /&gt;function Trace(M: Square) return Real is&lt;br /&gt;Sum: Real := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in M.Mat'Range loop&lt;br /&gt;Sum := Sum + M.Mat(I, I);&lt;br /&gt;end loop;&lt;br /&gt;return Sum;&lt;br /&gt;end Trace;&lt;br /&gt;----&lt;br /&gt;function Transpose(M: Square) return Square is&lt;br /&gt;R: Square(M.Order);&lt;br /&gt;begin&lt;br /&gt;for I in 1 .. M.Order loop&lt;br /&gt;for J in 1 .. M.Order loop&lt;br /&gt;R.Mat(I, J) := M.Mat(J, I);&lt;br /&gt;end loop;&lt;br /&gt;end loop;&lt;br /&gt;return R;&lt;br /&gt;end Transpose;&lt;br /&gt;----&lt;br /&gt;package Stacks is&lt;br /&gt;type Stack(Max: Natural) is limited private;&lt;br /&gt;procedure Push(S: in out Stack; X: in Integer);&lt;br /&gt;procedure Pop(S: in out Stack; X out Integer);&lt;br /&gt;function "=" (S, T: Stack) return Boolean;&lt;br /&gt;private&lt;br /&gt;type Integer_Vector is array (Integer range &lt;&gt;) of Integer;&lt;br /&gt;type Stack(Max: Natural) is&lt;br /&gt;record&lt;br /&gt;S: Integer_Vector(1 .. Max);&lt;br /&gt;Top: Integer := 0;&lt;br /&gt;end record;&lt;br /&gt;end;&lt;br /&gt;11.2 Default discriminants&lt;br /&gt;function Normal(P: Polynomial) return Polynomial is&lt;br /&gt;Size: Integer := P.N;&lt;br /&gt;begin&lt;br /&gt;while Size &gt; 0 and P.A(Size) = 0 loop&lt;br /&gt;Size := Size-1;&lt;br /&gt;end loop;&lt;br /&gt;return (Size, P.A(0 .. Size));&lt;br /&gt;end Normal;&lt;br /&gt;----&lt;br /&gt;subtype String_Size is Integer range 0 .. 80;&lt;br /&gt;type V_String(N: String_Size := 0) is&lt;br /&gt;record&lt;br /&gt;S: String(1 .. N);&lt;br /&gt;end record;&lt;br /&gt;11.3 Variant parts&lt;br /&gt;type Gender is (Male, Female);&lt;br /&gt;type Person(Sex: Gender) is&lt;br /&gt;record&lt;br /&gt;Birth: Date;&lt;br /&gt;case Sex is&lt;br /&gt;when Male =&gt;&lt;br /&gt;Bearded: Boolean;&lt;br /&gt;when Female =&gt;&lt;br /&gt;Children: Integer;&lt;br /&gt;end case;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;type Gender is (Male, Female, Neuter);&lt;br /&gt;type Mutant(Sex: Gender := Neuter) is&lt;br /&gt;record&lt;br /&gt;Birth: Date;&lt;br /&gt;case Sex is&lt;br /&gt;when Male =&gt;&lt;br /&gt;Bearded: Boolean;&lt;br /&gt;when Female =&gt;&lt;br /&gt;Children: Integer;&lt;br /&gt;when Neuter =&gt;&lt;br /&gt;null;&lt;br /&gt;end case;&lt;br /&gt;end record;&lt;br /&gt;11.4 Access Types&lt;br /&gt;type Cell;&lt;br /&gt;type Link is access Cell;&lt;br /&gt;type Cell is&lt;br /&gt;record&lt;br /&gt;Value: Integer;&lt;br /&gt;Next: Link;&lt;br /&gt;end record;&lt;br /&gt;L: Link;&lt;br /&gt;----&lt;br /&gt;function Sum(List: Link) return Integer is&lt;br /&gt;L: Link := List;&lt;br /&gt;S: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;while L /= null loop&lt;br /&gt;S := S+L.Value;&lt;br /&gt;L := L.Next;&lt;br /&gt;end loop;&lt;br /&gt;return S;&lt;br /&gt;end Sum;&lt;br /&gt;----&lt;br /&gt;type Node;&lt;br /&gt;type Tree is access Node;&lt;br /&gt;type Node is&lt;br /&gt;record&lt;br /&gt;Value: Real;&lt;br /&gt;Left, Right: Tree;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;procedure Sort(A: in out Vector) is&lt;br /&gt;I: Integer;&lt;br /&gt;Base: Tree := null;&lt;br /&gt;procedure Insert(T: in out Tree; V: Real) is&lt;br /&gt;begin&lt;br /&gt;if T = null then&lt;br /&gt;T := new Node'(V, null, null);&lt;br /&gt;else&lt;br /&gt;if V &lt; T.Value then&lt;br /&gt;Insert(T.Left, V);&lt;br /&gt;else&lt;br /&gt;Insert(T.Right, V);&lt;br /&gt;end if;&lt;br /&gt;end if;&lt;br /&gt;end Insert;&lt;br /&gt;procedure Output(T: Tree) is&lt;br /&gt;begin&lt;br /&gt;if T /= null then&lt;br /&gt;Output(T.Left);&lt;br /&gt;A(I) := T.Value;&lt;br /&gt;I := I+1;&lt;br /&gt;Output(T.Right);&lt;br /&gt;end if;&lt;br /&gt;end Output;&lt;br /&gt;begin -- body of Sort&lt;br /&gt;for J in A'Range loop&lt;br /&gt;Insert(Base, A(J));&lt;br /&gt;end loop;&lt;br /&gt;I := A'First;&lt;br /&gt;Output(Base);&lt;br /&gt;end Sort;&lt;br /&gt;11.5 Access types and private types&lt;br /&gt;package Stacks is&lt;br /&gt;type Stack is limited private;&lt;br /&gt;procedure Push(S: in out Stack; X: in Integer);&lt;br /&gt;procedure Pop(S: in out Stack; X: out Integer);&lt;br /&gt;private&lt;br /&gt;type Cell;&lt;br /&gt;type Stack is access Cell;&lt;br /&gt;type Cell is&lt;br /&gt;record&lt;br /&gt;Value: Integer;&lt;br /&gt;Next: Stack;&lt;br /&gt;end record;&lt;br /&gt;end;&lt;br /&gt;package body Stacks is&lt;br /&gt;procedure Push(S: in out Stack; X: in Integer) is&lt;br /&gt;begin&lt;br /&gt;S := new Cell'(X, S);&lt;br /&gt;end;&lt;br /&gt;procedure Pop(S: in out Stack; X: out Integer) is&lt;br /&gt;begin&lt;br /&gt;X := S.Value;&lt;br /&gt;S := S.Next;&lt;br /&gt;end;&lt;br /&gt;end Stacks;&lt;br /&gt;----&lt;br /&gt;function "=" (S, T: Stack) return Boolean is&lt;br /&gt;SS: Stack := S;&lt;br /&gt;TT: Stack := T;&lt;br /&gt;begin&lt;br /&gt;while SS /= null and TT /= null loop&lt;br /&gt;SS := SS.Next;&lt;br /&gt;TT := TT.Next;&lt;br /&gt;if SS.Value /= TT.Value then&lt;br /&gt;return False;&lt;br /&gt;end if;&lt;br /&gt;end loop;&lt;br /&gt;return SS = TT; -- True if both null&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;type Cell;&lt;br /&gt;type Link is access Cell;&lt;br /&gt;type Cell is&lt;br /&gt;record&lt;br /&gt;Value: Integer;&lt;br /&gt;Next: Link;&lt;br /&gt;end record;&lt;br /&gt;type Stack is&lt;br /&gt;record&lt;br /&gt;List: Link;&lt;br /&gt;end record;&lt;br /&gt;Exercise 11.5&lt;br /&gt;package Queues is&lt;br /&gt;Empty: exception;&lt;br /&gt;type Queue is limited private;&lt;br /&gt;procedure Join(Q: in out Queue; X: in Item);&lt;br /&gt;procedure Remove(Q: in out Queue; X: out Item);&lt;br /&gt;function Length(Q: Queue) return Integer;&lt;br /&gt;private&lt;br /&gt;11.6 Access types and constraints&lt;br /&gt;type Person;&lt;br /&gt;type Person_Name is access Person;&lt;br /&gt;type Person is&lt;br /&gt;record&lt;br /&gt;Sex: Gender;&lt;br /&gt;Birth: Date;&lt;br /&gt;Spouse: Person_Name;&lt;br /&gt;Father: Person_Name;&lt;br /&gt;First_Child: Person_Name;&lt;br /&gt;Next_Sibling: Person_Name;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;type Person(Sex: Gender);&lt;br /&gt;type Person_Name is access Person;&lt;br /&gt;type Person(Sex: Gender) is&lt;br /&gt;record&lt;br /&gt;Birth: Date;&lt;br /&gt;Father: Person_Name(Male);&lt;br /&gt;Next_Sibling: Person_Name;&lt;br /&gt;case Sex is&lt;br /&gt;when Male =&gt;&lt;br /&gt;Wife: Person_Name(Female);&lt;br /&gt;when Female =&gt;&lt;br /&gt;Husband: Person_Name(Male);&lt;br /&gt;First_Child: Person_Name;&lt;br /&gt;end case;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;procedure Marry(Bride: Womans_Name;&lt;br /&gt;Groom: Mans_Name) is&lt;br /&gt;begin&lt;br /&gt;if Bride.Husband /= null or Groom.Wife /= null then&lt;br /&gt;raise Bigamy;&lt;br /&gt;end if;&lt;br /&gt;Bride.Husband := Groom;&lt;br /&gt;Groom.Wife := Bride;&lt;br /&gt;end Marry;&lt;br /&gt;----&lt;br /&gt;function Spouse(P: Person_Name) return Person_Name is&lt;br /&gt;begin&lt;br /&gt;case P.Sex is&lt;br /&gt;when Male =&gt;&lt;br /&gt;return P.Wife;&lt;br /&gt;when Female =&gt;&lt;br /&gt;return P.Husband;&lt;br /&gt;end case;&lt;br /&gt;end Spouse;&lt;br /&gt;----&lt;br /&gt;function New_Child(Mother: Womans_Name;&lt;br /&gt;Boy_Or_Girl: Gender; Birthday: Date)&lt;br /&gt;return Person_Name is&lt;br /&gt;Child: Person_Name;&lt;br /&gt;begin&lt;br /&gt;if Mother.Husband = null then&lt;br /&gt;raise Illegitimate;&lt;br /&gt;end if;&lt;br /&gt;Child := new Person(Boy_Or_Girl);&lt;br /&gt;Child.Birth := Birthday;&lt;br /&gt;Child.Father := Mother.Husband;&lt;br /&gt;declare&lt;br /&gt;Last: Person_Name := Mother.First_Child;&lt;br /&gt;begin&lt;br /&gt;if Last = null then&lt;br /&gt;Mother.First_Child := Child;&lt;br /&gt;else&lt;br /&gt;while Last.Next_Sibling /= null loop&lt;br /&gt;Last := Last.Next_Sibling;&lt;br /&gt;end loop;&lt;br /&gt;Last.Next_Sibling := Child;&lt;br /&gt;end if;&lt;br /&gt;end;&lt;br /&gt;return Child;&lt;br /&gt;end New_Child;&lt;br /&gt;11.7 Derived types&lt;br /&gt;type Cell;&lt;br /&gt;type Link is access Cell;&lt;br /&gt;type Cell is&lt;br /&gt;record&lt;br /&gt;Value: Integer;&lt;br /&gt;Next: Link;&lt;br /&gt;end record;&lt;br /&gt;type Stack is new Link;&lt;br /&gt;----&lt;br /&gt;function "=" (S, T: Stack) return Boolean is&lt;br /&gt;SL: Link := Link(S);&lt;br /&gt;TL: Link := Link(T);&lt;br /&gt;begin&lt;br /&gt;-- as the answer to Exercise 11.5(2)&lt;br /&gt;end "=";&lt;br /&gt;Chapter 12 Numeric Types&lt;br /&gt;12.4 Fixed point types&lt;br /&gt;private&lt;br /&gt;Pi: constant := 3.14159_26536;&lt;br /&gt;type Angle is delta 0.1 range -4*Pi .. 4*Pi;&lt;br /&gt;for Angle'Small use Pi*2**(-13);&lt;br /&gt;type Complex is&lt;br /&gt;record&lt;br /&gt;R: Real;&lt;br /&gt;Theta: Angle range -Pi .. Pi;&lt;br /&gt;end record;&lt;br /&gt;I: constant Complex := (1.0, 0.5*Pi);&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;function Normal(A: Angle) return Angle is&lt;br /&gt;begin&lt;br /&gt;if A &gt;= Pi then&lt;br /&gt;return A - Angle(2*Pi);&lt;br /&gt;elsif A &lt; -Pi then&lt;br /&gt;return A + Angle(2*Pi);&lt;br /&gt;else&lt;br /&gt;return A;&lt;br /&gt;end if;&lt;br /&gt;end Normal;&lt;br /&gt;----&lt;br /&gt;package body Complex_Numbers is&lt;br /&gt;function Normal ... -- as above&lt;br /&gt;...&lt;br /&gt;function "*" (X, Y: Complex) return Complex is&lt;br /&gt;begin&lt;br /&gt;return (X.R * Y.R, Normal(X.Theta + Y.Theta));&lt;br /&gt;end "*";&lt;br /&gt;...&lt;br /&gt;function Rl_Part(X: Complex) return Real is&lt;br /&gt;begin&lt;br /&gt;return X.R * Cos(X.Theta);&lt;br /&gt;end Rl_Part;&lt;br /&gt;...&lt;br /&gt;end Complex_Numbers;&lt;br /&gt;Chapter 13 Generics&lt;br /&gt;13.1 Declarations and instantiations&lt;br /&gt;procedure Swap(X, Y: in out Real) is&lt;br /&gt;T: Real;&lt;br /&gt;begin&lt;br /&gt;T := X; X := Y; Y := T;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Item is private;&lt;br /&gt;procedure Exchange(X, Y: in out Item);&lt;br /&gt;procedure Exchange(X, Y: in out Item) is&lt;br /&gt;T: Item;&lt;br /&gt;begin&lt;br /&gt;T := X; X := Y; Y := T;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;Max: Positive;&lt;br /&gt;type Item is private;&lt;br /&gt;package Stack is&lt;br /&gt;procedure Push(X: Item);&lt;br /&gt;function Pop return Item;&lt;br /&gt;end Stack;&lt;br /&gt;package body Stack is&lt;br /&gt;S: array (1 .. Max) of Item;&lt;br /&gt;Top: Integer range 0 .. Max;&lt;br /&gt;-- etc. as before but with Integer&lt;br /&gt;-- replaced by Item&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;package My_Stack is new Stack(100, Real);&lt;br /&gt;use My_Stack;&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;Push(X);&lt;br /&gt;...&lt;br /&gt;Y := Pop;&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;Max: Positive;&lt;br /&gt;type Item is private;&lt;br /&gt;package Stack is&lt;br /&gt;Error: exception;&lt;br /&gt;procedure Push(X: Item);&lt;br /&gt;function Pop return Item;&lt;br /&gt;end Stack;&lt;br /&gt;----&lt;br /&gt;package All_Stacks is&lt;br /&gt;Error: exception;&lt;br /&gt;generic&lt;br /&gt;Max: Positive;&lt;br /&gt;type Item is private;&lt;br /&gt;package Stack is&lt;br /&gt;procedure Push(X: Item);&lt;br /&gt;function Pop return Item;&lt;br /&gt;end Stack;&lt;br /&gt;end All_Stacks;&lt;br /&gt;package body All_Stacks is&lt;br /&gt;package body Stack is&lt;br /&gt;...&lt;br /&gt;end Stack;&lt;br /&gt;end All_Stacks;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Thing is private;&lt;br /&gt;procedure Cab(A, B, C: in out Thing);&lt;br /&gt;procedure Cab(A, B, C: in out Thing) is&lt;br /&gt;procedure Swap is new Exchange(Item =&gt; Thing);&lt;br /&gt;begin&lt;br /&gt;Swap(A, B);&lt;br /&gt;Swap(A, C);&lt;br /&gt;end Cab;&lt;br /&gt;13.2 Type parameters&lt;br /&gt;generic&lt;br /&gt;type T is (&lt;&gt;);&lt;br /&gt;function Next(X: T) return T;&lt;br /&gt;function Next(X: T) return T is&lt;br /&gt;begin&lt;br /&gt;if X=T'Last then&lt;br /&gt;return T'First;&lt;br /&gt;else&lt;br /&gt;return T'Succ(X);&lt;br /&gt;end if;&lt;br /&gt;end Next;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Real is digits &lt;&gt;;&lt;br /&gt;package Generic_Complex_Numbers is&lt;br /&gt;type Complex is private;&lt;br /&gt;-- as before&lt;br /&gt;I: constant Complex := (0.0, 1.0);&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Index is (&lt;&gt;);&lt;br /&gt;type Floating is digits &lt;&gt;;&lt;br /&gt;type Vec is array (Index range &lt;&gt;) of Floating;&lt;br /&gt;function Sum(A: Vec) return Floating;&lt;br /&gt;function Sum(A: Vec) return Floating is&lt;br /&gt;Result: Floating := 0.0;&lt;br /&gt;begin&lt;br /&gt;for I in A'Range loop&lt;br /&gt;Result := Result+A(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end Sum;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Base is (&lt;&gt;);&lt;br /&gt;package Set_Of is&lt;br /&gt;type Set is private;&lt;br /&gt;type List is array (Positive range &lt;&gt;) of Base;&lt;br /&gt;Empty, Full: constant Set;&lt;br /&gt;function Make_Set(X: List) return Set;&lt;br /&gt;function Make_Set(X: Base) return Set;&lt;br /&gt;function Decompose(X: Set) return List;&lt;br /&gt;function "+" (X, Y: Set) return Set; -- union&lt;br /&gt;function "*" (X, Y: Set) return Set; -- intersection&lt;br /&gt;function "-" (X, Y: Set) return Set; -- symmetric difference&lt;br /&gt;function "&lt;" (X: Base; Y: Set) return Boolean; -- inclusion&lt;br /&gt;function "&lt;=" (X, Y: Set) return Boolean; -- contains&lt;br /&gt;function Size(X: Set) return Natural; -- no of elements&lt;br /&gt;private&lt;br /&gt;type Set is array (Base) of Boolean;&lt;br /&gt;Empty: constant Set := (Set'Range =&gt; False);&lt;br /&gt;Full: constant Set := (Set'Range =&gt; True);&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Base is (&lt;&gt;);&lt;br /&gt;type Index is (&lt;&gt;);&lt;br /&gt;type List is array (Index range &lt;&gt;) of Base;&lt;br /&gt;package Nice_Set_Of is&lt;br /&gt;type Set is private;&lt;br /&gt;function Empty return Set;&lt;br /&gt;function Full return Set;&lt;br /&gt;...&lt;br /&gt;private&lt;br /&gt;----&lt;br /&gt;type Primary_List is array (Positive range &lt;&gt;) of Primary;&lt;br /&gt;package Primary_Sets is new Nice_Set_Of(Base =&gt; Primary,&lt;br /&gt;Index =&gt; Positive,&lt;br /&gt;List =&gt; Primary_List);&lt;br /&gt;type Colour is new Primary_Sets.Set;&lt;br /&gt;13.3 Subprogram parameters&lt;br /&gt;generic&lt;br /&gt;type Index is (&lt;&gt;);&lt;br /&gt;type Item is (&lt;&gt;);&lt;br /&gt;type Collection is array (Index range &lt;&gt;) of Item;&lt;br /&gt;procedure Sort(C: in out Collection);&lt;br /&gt;----&lt;br /&gt;procedure Sort(C: in out Collection) is&lt;br /&gt;Min: Index;&lt;br /&gt;Temp: Item;&lt;br /&gt;begin&lt;br /&gt;for I in C'First .. Index'Pred(C'Last) loop&lt;br /&gt;Min := I;&lt;br /&gt;for J in Index'Succ(I) .. C'Last loop&lt;br /&gt;if C(J) &lt; C(Min) then Min := J; end if; -- use of &lt;&lt;br /&gt;end loop;&lt;br /&gt;Temp := C(I); C(I) := C(Min); C(Min) := Temp;&lt;br /&gt;end loop;&lt;br /&gt;end Sort;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Index is (&lt;&gt;);&lt;br /&gt;type Item is private;&lt;br /&gt;type Collection is array (Index range &lt;&gt;) of Item;&lt;br /&gt;with function "&lt;" (X, Y: Item) return Boolean;&lt;br /&gt;procedure Sort(C: in out Collection);&lt;br /&gt;----&lt;br /&gt;procedure Reverse_Sort_Vector is&lt;br /&gt;new Sort(Index =&gt; Integer,&lt;br /&gt;Item =&gt; Real,&lt;br /&gt;Collection =&gt; Vector,&lt;br /&gt;"&lt;" =&gt; "&gt;");&lt;br /&gt;----&lt;br /&gt;subtype String_3 is String(1 .. 3);&lt;br /&gt;procedure Sort_String_3_Array is&lt;br /&gt;new Sort(Positive, String_3, String_3_Array, "&lt;");&lt;br /&gt;...&lt;br /&gt;Sort_String_3_Array(Farmyard);&lt;br /&gt;----&lt;br /&gt;type Date_Array is array (Positive range &lt;&gt;) of Date;&lt;br /&gt;function "&lt;" (X, Y: Date) return Boolean is&lt;br /&gt;begin&lt;br /&gt;if X.Year /= Y.Year then&lt;br /&gt;return X.Year &lt; Y.Year;&lt;br /&gt;elsif X.Month /= Y.Month then&lt;br /&gt;return X.Month &lt; Y.Month;&lt;br /&gt;else&lt;br /&gt;return X.Day &lt; Y.Day;&lt;br /&gt;end if;&lt;br /&gt;end "&lt;";&lt;br /&gt;procedure Sort_Date_Array is&lt;br /&gt;new Sort(Positive, Date, Date_Array);&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Index is (&lt;&gt;);&lt;br /&gt;type Item is private;&lt;br /&gt;type Vec is array (Index range &lt;&gt;) of Item;&lt;br /&gt;with function "+" (X, Y: Item) return Item;&lt;br /&gt;function Apply(A: Vec) return Item;&lt;br /&gt;function Apply(A: Vec) return Item is&lt;br /&gt;Result: Item := A(A'First);&lt;br /&gt;begin&lt;br /&gt;for I in Index'Succ(A'First) .. A'Last loop&lt;br /&gt;Result := Result+A(I);&lt;br /&gt;end loop;&lt;br /&gt;return Result;&lt;br /&gt;end Apply;&lt;br /&gt;----&lt;br /&gt;function G(T: Real) return Real is&lt;br /&gt;begin&lt;br /&gt;return Exp(T)*Sin(T);&lt;br /&gt;end;&lt;br /&gt;function Integrate_G is new Integrate(G);&lt;br /&gt;13.4 The mathematical library&lt;br /&gt;with Elementary_Functions_Exceptions;&lt;br /&gt;generic&lt;br /&gt;type Float_Type is digits &lt;&gt;;&lt;br /&gt;package Generic_Elementary_Functions is&lt;br /&gt;function Sqrt (X: Float_Type) return Float_Type;&lt;br /&gt;function Log (X: Float_Type) return Float_Type;&lt;br /&gt;function Log (X, Base: Float_Type) return Float_Type;&lt;br /&gt;function Exp (X: Float_Type) return Float_Type;&lt;br /&gt;function "**" (Left, Right: Float_Type) return Float_Type;&lt;br /&gt;function Sin (X: Float_Type) return Float_Type;&lt;br /&gt;function Sin (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Cos (X: Float_Type) return Float_Type;&lt;br /&gt;function Cos (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Tan (X: Float_Type) return Float_Type;&lt;br /&gt;function Tan (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Cot (X: Float_Type) return Float_Type;&lt;br /&gt;function Cot (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Arcsin (X: Float_Type) return Float_Type;&lt;br /&gt;function Arcsin (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Arccos (X: Float_Type) return Float_Type;&lt;br /&gt;function Arccos (X, Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Arctan (Y: Float_Type; X: Float_Type := 1.0)&lt;br /&gt;return Float_Type;&lt;br /&gt;function Arctan (Y: Float_Type; X: Float_Type := 1.0;&lt;br /&gt;Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Arccot (X: Float_Type; Y: Float_Type := 1.0)&lt;br /&gt;return Float_Type;&lt;br /&gt;function Arccot (X: Float_Type; Y: Float_Type := 1.0;&lt;br /&gt;Cycle: Float_Type) return Float_Type;&lt;br /&gt;function Sinh (X: Float_Type) return Float_Type;&lt;br /&gt;function Cosh (X: Float_Type) return Float_Type;&lt;br /&gt;function Tanh (X: Float_Type) return Float_Type;&lt;br /&gt;function Coth (X: Float_Type) return Float_Type;&lt;br /&gt;function Arcsinh (X: Float_Type) return Float_Type;&lt;br /&gt;function Arccosh (X: Float_Type) return Float_Type;&lt;br /&gt;function Arctanh (X: Float_Type) return Float_Type;&lt;br /&gt;function Arccoth (X: Float_Type) return Float_Type;&lt;br /&gt;Argument_Error: exception&lt;br /&gt;renames Elementary_Functions_Exceptions.Argument_Error;&lt;br /&gt;end Generic_Elementary_Functions;&lt;br /&gt;----&lt;br /&gt;generic&lt;br /&gt;type Real_Type is digits &lt;&gt;;&lt;br /&gt;type Complex_Type is private;&lt;br /&gt;with function Cons(R, I: Real_Type) return Complex_Type is &lt;&gt;;&lt;br /&gt;with function Cons_Polar(R, Theta: Real_Type) return&lt;br /&gt;Complex_Type is &lt;&gt;;&lt;br /&gt;with function Rl_Part(X: Complex_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Im_Part(X: Complex_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function "abs" (X: Complex_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Arg (X: Complex_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Sqrt (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Log (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Exp (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Sin (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Cos (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Sinh (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;with function Cosh (X: Real_Type) return Real_Type is &lt;&gt;;&lt;br /&gt;package Generic_Complex_Functions is&lt;br /&gt;function Sqrt(X: Complex_Type) return Complex_Type;&lt;br /&gt;function Log (X: Complex_Type) return Complex_Type;&lt;br /&gt;function Exp (X: Complex_Type) return Complex_Type;&lt;br /&gt;function Sin (X: Complex_Type) return Complex_Type;&lt;br /&gt;function Cos (X: Complex_Type) return Complex_Type;&lt;br /&gt;end Generic_Complex_Functions;&lt;br /&gt;----&lt;br /&gt;type My_Real is digits 9;&lt;br /&gt;package My_Elementary_Functions is&lt;br /&gt;new Generic_Elementary_Functions(Float_Type =&gt; My_Real);&lt;br /&gt;package My_Complex_Numbers is&lt;br /&gt;new Generic_Complex_Numbers(Real =&gt; My_Real);&lt;br /&gt;use My_Elementary_Functions, My_Complex_Numbers;&lt;br /&gt;package My_Complex_Functions is&lt;br /&gt;new Generic_Complex_Functions(My_Real, Complex);&lt;br /&gt;use My_Complex_Functions;&lt;br /&gt;Chapter 14 Tasking&lt;br /&gt;14.1 Parallelism&lt;br /&gt;task T is -- specification&lt;br /&gt;...&lt;br /&gt;end T;&lt;br /&gt;task body T is -- body&lt;br /&gt;...&lt;br /&gt;end T;&lt;br /&gt;----&lt;br /&gt;procedure Shopping is&lt;br /&gt;begin&lt;br /&gt;Buy_Meat;&lt;br /&gt;Buy_Salad;&lt;br /&gt;Buy_Wine;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;procedure Shopping is&lt;br /&gt;task Get_Salad;&lt;br /&gt;task body Get_Salad is&lt;br /&gt;begin&lt;br /&gt;Buy_Salad;&lt;br /&gt;end Get_Salad;&lt;br /&gt;task Get_Wine;&lt;br /&gt;task body Get_Wine is&lt;br /&gt;begin&lt;br /&gt;Buy_Wine;&lt;br /&gt;end Get_Wine;&lt;br /&gt;begin&lt;br /&gt;Buy_Meat;&lt;br /&gt;end Shopping;&lt;br /&gt;14.2 The rendezvous&lt;br /&gt;procedure Shopping is&lt;br /&gt;task Get_Salad is&lt;br /&gt;entry Pay(M: in Money);&lt;br /&gt;entry Collect(S: out Salad);&lt;br /&gt;end Get_Salad;&lt;br /&gt;task body Get_Salad is&lt;br /&gt;Cash: Money;&lt;br /&gt;Food: Salad;&lt;br /&gt;begin&lt;br /&gt;accept Pay(M: in Money) do&lt;br /&gt;Cash := M;&lt;br /&gt;end Pay;&lt;br /&gt;Food := Buy_Salad(Cash);&lt;br /&gt;accept Collect(S: out Salad) do&lt;br /&gt;S := Food;&lt;br /&gt;end Collect;&lt;br /&gt;end Get_Salad;&lt;br /&gt;-- Get_Wine similarly&lt;br /&gt;begin&lt;br /&gt;Get_Salad.Pay(50);&lt;br /&gt;Get_Wine.Pay(100);&lt;br /&gt;MM := Buy_Meat(200);&lt;br /&gt;Get_Salad.Collect(SS);&lt;br /&gt;Get_Wine.Collect(WW);&lt;br /&gt;end Shopping;&lt;br /&gt;----&lt;br /&gt;task Buffering is&lt;br /&gt;entry Put(X: in Item);&lt;br /&gt;entry Get(X: out Item);&lt;br /&gt;end;&lt;br /&gt;task body Buffering is&lt;br /&gt;V: Item;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;accept Put(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end Put;&lt;br /&gt;accept Get(X: out Item) do&lt;br /&gt;X := V;&lt;br /&gt;end Get;&lt;br /&gt;end loop;&lt;br /&gt;end Buffering;&lt;br /&gt;Exercise 14.2&lt;br /&gt;task Build_Complex is&lt;br /&gt;entry Put_Rl(X: in Real);&lt;br /&gt;entry Put_Im(X: in Real);&lt;br /&gt;entry Get_Comp(X: out Complex);&lt;br /&gt;end;&lt;br /&gt;14.3 Timing and scheduling&lt;br /&gt;task Buffering is&lt;br /&gt;pragma Priority(7);&lt;br /&gt;entry Put ...&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;package Calendar is&lt;br /&gt;type Time is private;&lt;br /&gt;subtype Year_Number is Integer range 1901 .. 2099;&lt;br /&gt;subtype Month_Number is Integer range 1 .. 12;&lt;br /&gt;subtype Day_Number is Integer range 1 .. 31;&lt;br /&gt;subtype Day_Duration is Duration range 0.0 .. 86_400.0;&lt;br /&gt;function Clock return Time;&lt;br /&gt;function Year(Date: Time) return Year_Number;&lt;br /&gt;function Month(Date: Time) return Month_Number;&lt;br /&gt;function Day(Date: Time) return Day_Number;&lt;br /&gt;function Seconds(Date: Time) return Day_Duration;&lt;br /&gt;procedure Split(Date: in Time;&lt;br /&gt;Year: out Year_Number;&lt;br /&gt;Month: out Month_Number;&lt;br /&gt;Day: out Day_Number;&lt;br /&gt;Seconds: out Day_Duration);&lt;br /&gt;function Time_Of(Year: Year_Number;&lt;br /&gt;Month: Month_Number;&lt;br /&gt;Day: Day_Number;&lt;br /&gt;Seconds: Day_Duration := 0.0) return Time;&lt;br /&gt;function "+" (Left: Time; Right: Duration) return Time;&lt;br /&gt;function "+" (Left: Duration; Right: Time) return Time;&lt;br /&gt;function "-" (Left: Time; Right: Duration) return Time;&lt;br /&gt;function "-" (Left: Time; Right: Time) return Duration;&lt;br /&gt;function "&lt;" (Left, Right: Time) return Boolean;&lt;br /&gt;function "&lt;=" (Left, Right: Time) return Boolean;&lt;br /&gt;function "&gt;" (Left, Right: Time) return Boolean;&lt;br /&gt;function "&gt;=" (Left, Right: Time) return Boolean;&lt;br /&gt;Time_Error: exception;&lt;br /&gt;-- can be raised by Time_Of, +, and -&lt;br /&gt;private&lt;br /&gt;-- implementation dependent&lt;br /&gt;end Calendar;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;use Calendar;&lt;br /&gt;Interval: constant Duration := 5*Minutes;&lt;br /&gt;Next_Time: Time := First_Time;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;delay Next_Time - Clock;&lt;br /&gt;Action;&lt;br /&gt;Next_Time := Next_Time + Interval;&lt;br /&gt;end loop;&lt;br /&gt;end;&lt;br /&gt;14.4 Simple select statements&lt;br /&gt;package Protected_Variable is&lt;br /&gt;procedure Read(X: out Item);&lt;br /&gt;procedure Write(X: in Item);&lt;br /&gt;end;&lt;br /&gt;package body Protected_Variable is&lt;br /&gt;V: Item;&lt;br /&gt;procedure Read(X: out Item) is&lt;br /&gt;begin&lt;br /&gt;X := V;&lt;br /&gt;end;&lt;br /&gt;procedure Write(X: in Item) is&lt;br /&gt;begin&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;begin&lt;br /&gt;V := initial value;&lt;br /&gt;end Protected_Variable;&lt;br /&gt;----&lt;br /&gt;type Item is&lt;br /&gt;record&lt;br /&gt;X_Coord: Real;&lt;br /&gt;Y_Coord: Real;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;task Protected_Variable is&lt;br /&gt;entry Read(X: out Item);&lt;br /&gt;entry Write(X: in Item);&lt;br /&gt;end;&lt;br /&gt;task body Protected_Variable is&lt;br /&gt;V: Item;&lt;br /&gt;begin&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;accept Read(X: out Item) do&lt;br /&gt;X := V;&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Protected_Variable;&lt;br /&gt;----&lt;br /&gt;task Buffering is&lt;br /&gt;entry Put(X: in Item);&lt;br /&gt;entry Get(X: out Item);&lt;br /&gt;end;&lt;br /&gt;task body Buffering is&lt;br /&gt;N: constant := 8; -- for instance&lt;br /&gt;A: array (1 .. N) of Item;&lt;br /&gt;I, J: Integer range 1 .. N := 1;&lt;br /&gt;Count: Integer range 0 .. N := 0;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;when Count &lt; n =""&gt;&lt;br /&gt;accept Put(X: in Item) do&lt;br /&gt;A(I) := X;&lt;br /&gt;end;&lt;br /&gt;I := I mod N+1; Count := Count+1;&lt;br /&gt;or&lt;br /&gt;when Count &gt; 0 =&gt;&lt;br /&gt;accept Get(X: out Item) do&lt;br /&gt;X := A(J);&lt;br /&gt;end;&lt;br /&gt;J := J mod N+1; Count := Count-1;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Buffering;&lt;br /&gt;----&lt;br /&gt;package Reader_Writer is&lt;br /&gt;procedure Read(X: out Item);&lt;br /&gt;procedure Write(X: in Item);&lt;br /&gt;end;&lt;br /&gt;package body Reader_Writer is&lt;br /&gt;V: Item;&lt;br /&gt;task Control is&lt;br /&gt;entry Start;&lt;br /&gt;entry Stop;&lt;br /&gt;entry Write(X: in Item);&lt;br /&gt;end;&lt;br /&gt;task body Control is&lt;br /&gt;Readers: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;accept Start;&lt;br /&gt;Readers := Readers+1;&lt;br /&gt;or&lt;br /&gt;accept Stop;&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;or&lt;br /&gt;when Readers = 0 =&gt;&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Control;&lt;br /&gt;procedure Read(X: out Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Start;&lt;br /&gt;X := V;&lt;br /&gt;Control.Stop;&lt;br /&gt;end Read;&lt;br /&gt;procedure Write(X: in Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Write(X);&lt;br /&gt;end Write;&lt;br /&gt;end Reader_Writer;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;when Write'Count = 0 =&gt;&lt;br /&gt;accept Start;&lt;br /&gt;Readers := Readers+1;&lt;br /&gt;or&lt;br /&gt;accept Stop;&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;or&lt;br /&gt;when Readers = 0 =&gt;&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;end select;&lt;br /&gt;14.5 Timed and conditional rendezvous&lt;br /&gt;select&lt;br /&gt;accept Read( ... ) do&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;accept Write( ... ) do&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;delay 10*Minutes;&lt;br /&gt;-- time out statements&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;Operator.Call("Put out fire");&lt;br /&gt;select&lt;br /&gt;accept Acknowledge;&lt;br /&gt;or&lt;br /&gt;delay 1*Minutes;&lt;br /&gt;Fire_Brigade.Call;&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;accept Read( ... ) do&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;accept Write( ... ) do&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;else&lt;br /&gt;-- alternative statements&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;accept Acknowledge;&lt;br /&gt;else&lt;br /&gt;delay 1*Minutes;&lt;br /&gt;Fire_Brigade.Call;&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;Operator.Call("Put out fire");&lt;br /&gt;or&lt;br /&gt;delay 1*Minutes;&lt;br /&gt;Fire_Brigade.Call;&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;Operator.Call("Put out fire");&lt;br /&gt;else&lt;br /&gt;Fire_Brigade.Call;&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;procedure Write(X: in Item; T: Duration; OK: out Boolean) is&lt;br /&gt;begin&lt;br /&gt;select&lt;br /&gt;Control.Write(X);&lt;br /&gt;OK := True;&lt;br /&gt;or&lt;br /&gt;delay T;&lt;br /&gt;OK := False;&lt;br /&gt;end select;&lt;br /&gt;end Write;&lt;br /&gt;----&lt;br /&gt;package body Reader_Writer is&lt;br /&gt;V: Item;&lt;br /&gt;type Service is (Read, Write);&lt;br /&gt;task Control is&lt;br /&gt;entry Start(S: Service);&lt;br /&gt;entry Stop_Read;&lt;br /&gt;entry Write;&lt;br /&gt;entry Stop_Write;&lt;br /&gt;end Control;&lt;br /&gt;task body Control is&lt;br /&gt;Readers: Integer := 0;&lt;br /&gt;Writers: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;when Writers = 0 =&gt;&lt;br /&gt;accept Start(S: Service) do&lt;br /&gt;case S is&lt;br /&gt;when Read =&gt;&lt;br /&gt;Readers := Readers+1;&lt;br /&gt;when Write =&gt;&lt;br /&gt;Writers := 1;&lt;br /&gt;end case;&lt;br /&gt;end Start;&lt;br /&gt;or&lt;br /&gt;accept Stop_Read;&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;or&lt;br /&gt;when Readers = 0 =&gt;&lt;br /&gt;accept Write;&lt;br /&gt;or&lt;br /&gt;accept Stop_Write;&lt;br /&gt;Writers := 0;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Control;&lt;br /&gt;procedure Read(X: out Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Start(Read);&lt;br /&gt;X := V;&lt;br /&gt;Control.Stop_Read;&lt;br /&gt;end Read;&lt;br /&gt;procedure Write(X: in Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Start(Write);&lt;br /&gt;Control.Write;&lt;br /&gt;V := X;&lt;br /&gt;Control.Stop_Write;&lt;br /&gt;end Write;&lt;br /&gt;end Reader_Writer;&lt;br /&gt;----&lt;br /&gt;task Control is&lt;br /&gt;entry Start(S: Service);&lt;br /&gt;entry Stop;&lt;br /&gt;end Control;&lt;br /&gt;task body Control is&lt;br /&gt;Readers: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;accept Start(S: Service) do&lt;br /&gt;case S is&lt;br /&gt;when Read =&gt;&lt;br /&gt;Readers := Readers+1;&lt;br /&gt;when Write =&gt;&lt;br /&gt;while Readers &gt; 0 loop&lt;br /&gt;accept Stop; -- from readers&lt;br /&gt;Readers := Readers-1&lt;br /&gt;end loop;&lt;br /&gt;end case;&lt;br /&gt;end Start;&lt;br /&gt;if Readers = 0 then&lt;br /&gt;accept Stop; -- from the writer&lt;br /&gt;end if;&lt;br /&gt;or&lt;br /&gt;accept Stop; -- from a reader&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Control;&lt;br /&gt;procedure Read(X: out Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Start(Read);&lt;br /&gt;X := V;&lt;br /&gt;Control.Stop;&lt;br /&gt;end Read;&lt;br /&gt;procedure Write(X: in Item) is&lt;br /&gt;begin&lt;br /&gt;Control.Start(Write);&lt;br /&gt;V := X;&lt;br /&gt;Control.Stop;&lt;br /&gt;end Write;&lt;br /&gt;14.6 Task types and activation&lt;br /&gt;task type T is&lt;br /&gt;entry E( ... );&lt;br /&gt;end T;&lt;br /&gt;task body T is&lt;br /&gt;...&lt;br /&gt;end T;&lt;br /&gt;----&lt;br /&gt;type Rec is&lt;br /&gt;record&lt;br /&gt;CT: T;&lt;br /&gt;...&lt;br /&gt;end record;&lt;br /&gt;R: Rec;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;...&lt;br /&gt;A: T;&lt;br /&gt;B: T;&lt;br /&gt;...&lt;br /&gt;begin&lt;br /&gt;...&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;type R is&lt;br /&gt;record&lt;br /&gt;A: T;&lt;br /&gt;I: Integer := E;&lt;br /&gt;B: T;&lt;br /&gt;end record;&lt;br /&gt;----&lt;br /&gt;declare&lt;br /&gt;XA: T;&lt;br /&gt;XI: Integer := E;&lt;br /&gt;XB: T;&lt;br /&gt;begin&lt;br /&gt;----&lt;br /&gt;task type Mailbox is&lt;br /&gt;entry Deposit(X: in Item);&lt;br /&gt;entry Collect(X: out Item);&lt;br /&gt;end;&lt;br /&gt;task body Mailbox is&lt;br /&gt;Local: Item;&lt;br /&gt;begin&lt;br /&gt;accept Deposit(X: in Item) do&lt;br /&gt;Local := X;&lt;br /&gt;end;&lt;br /&gt;accept Collect(X: out Item) do&lt;br /&gt;X := Local;&lt;br /&gt;end;&lt;br /&gt;end Mailbox;&lt;br /&gt;----&lt;br /&gt;task Server is&lt;br /&gt;entry Request(A: Address; X: Item);&lt;br /&gt;end;&lt;br /&gt;task body Server is&lt;br /&gt;Reply: Address;&lt;br /&gt;Job: Item;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;accept Request(A: Address; X: Item) do&lt;br /&gt;Reply := A;&lt;br /&gt;Job := X;&lt;br /&gt;end;&lt;br /&gt;-- work on job&lt;br /&gt;Reply.Deposit(Job);&lt;br /&gt;end loop;&lt;br /&gt;end Server;&lt;br /&gt;task User;&lt;br /&gt;task body User is&lt;br /&gt;My_Box: Address := new Mailbox;&lt;br /&gt;My_Item: Item;&lt;br /&gt;begin&lt;br /&gt;Server.Request(My_Box, My_Item);&lt;br /&gt;-- do something while waiting&lt;br /&gt;My_Box.Collect(My_Item);&lt;br /&gt;end User;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;My_Box.Collect(My_Item);&lt;br /&gt;-- item collected successfully&lt;br /&gt;else&lt;br /&gt;-- not ready yet&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;task body Mailbox is&lt;br /&gt;begin&lt;br /&gt;accept Deposit(X: in Item) do&lt;br /&gt;accept Collect(X: out Item) do&lt;br /&gt;Collect.X := Deposit.X;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end Mailbox;&lt;br /&gt;14.7 Termination and exceptions&lt;br /&gt;task body Protected_Variable is&lt;br /&gt;V: Item;&lt;br /&gt;begin&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;accept Read(X: out Item) do&lt;br /&gt;X := V;&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;accept Write(X: in Item) do&lt;br /&gt;V := X;&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;terminate;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Protected_Variable;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;T.Closedown;&lt;br /&gt;or&lt;br /&gt;delay 60*Seconds;&lt;br /&gt;abort T;&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;accept Closedown;&lt;br /&gt;-- tidy up and die&lt;br /&gt;else&lt;br /&gt;-- carry on normally&lt;br /&gt;end select;&lt;br /&gt;----&lt;br /&gt;select&lt;br /&gt;T.Closedown;&lt;br /&gt;delay 10*Seconds;&lt;br /&gt;or&lt;br /&gt;delay 60*Seconds;&lt;br /&gt;end select;&lt;br /&gt;abort T;&lt;br /&gt;----&lt;br /&gt;accept Closedown do&lt;br /&gt;loop&lt;br /&gt;Put("Can't catch me");&lt;br /&gt;end loop;&lt;br /&gt;end;&lt;br /&gt;----&lt;br /&gt;task body Control is&lt;br /&gt;Readers: Integer := 0;&lt;br /&gt;begin&lt;br /&gt;loop&lt;br /&gt;select&lt;br /&gt;accept Start(S: Service) do&lt;br /&gt;case S is&lt;br /&gt;when Read =&gt;&lt;br /&gt;Readers := Readers+1;&lt;br /&gt;when Write =&gt;&lt;br /&gt;while Readers &gt; 0 loop&lt;br /&gt;accept Stop; -- from readers&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;end loop;&lt;br /&gt;end case;&lt;br /&gt;end Start;&lt;br /&gt;if Readers = 0 then&lt;br /&gt;accept Stop; -- from the writer&lt;br /&gt;end if;&lt;br /&gt;or&lt;br /&gt;accept Stop; -- from a reader&lt;br /&gt;Readers := Readers-1;&lt;br /&gt;end select;&lt;br /&gt;end loop;&lt;br /&gt;end Control;&lt;br /&gt;----&lt;br /&gt;package body Reader_Writer is&lt;br /&gt;V: Item;&lt;br /&gt;type Service is (Read, Write);&lt;br /&gt;task type Read_Agent is&lt;br /&gt;entry Read(X: out Item);&lt;br /&gt;end;&lt;br /&gt;type RRA is access Read_Agent;&lt;br /&gt;task Control is&lt;br /&gt;entry Start(S: Service);&lt;br /&gt;entry Stop;&lt;br /&gt;end;&lt;br /&gt;task body Control is&lt;br /&gt;-- as before&lt;br /&gt;end Control;&lt;br /&gt;task body Read_Agent is&lt;br /&gt;begin&lt;br /&gt;select&lt;br /&gt;accept Read(X: out Item) do&lt;br /&gt;Control.Start(Read);&lt;br /&gt;X := V;&lt;br /&gt;Control.Stop;&lt;br /&gt;end;&lt;br /&gt;or&lt;br /&gt;terminate;&lt;br /&gt;end select;&lt;br /&gt;end Read_Agent;&lt;br /&gt;procedure Read&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-3176212160629443815?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/3176212160629443815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=3176212160629443815' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3176212160629443815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3176212160629443815'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/program-code-for-ada-4th-edition.html' title='Program code for Ada, 4th Edition'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4185144357140522282</id><published>2008-12-11T06:46:00.001-08:00</published><updated>2008-12-22T21:29:32.540-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenGL'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Drawing Single Cube</title><content type='html'>#include &lt;gl/gl.h&gt;&lt;br /&gt;#include &lt;gl/glu.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;#include "glut.h"&lt;br /&gt;GLfloat vertices[][3] = {{-1.0,-1.0,-1.0},{1.0,-1.0,-1.0},&lt;br /&gt;{1.0,1.0,-1.0}, {-1.0,1.0,-1.0}, {-1.0,-1.0,1.0},&lt;br /&gt;{1.0,-1.0,1.0}, {1.0,1.0,1.0}, {-1.0,1.0,1.0}};&lt;br /&gt;GLfloat normals[][3] = {{-1.0,-1.0,-1.0},{1.0,-1.0,-1.0},&lt;br /&gt;{1.0,1.0,-1.0}, {-1.0,1.0,-1.0}, {-1.0,-1.0,1.0},&lt;br /&gt;{1.0,-1.0,1.0}, {1.0,1.0,1.0}, {-1.0,1.0,1.0}};&lt;br /&gt;GLfloat colors[][3] = {{0.0,0.0,0.0},{1.0,0.0,0.0},&lt;br /&gt;{1.0,1.0,0.0}, {0.0,1.0,0.0}, {0.0,0.0,1.0},&lt;br /&gt;{1.0,0.0,1.0}, {1.0,1.0,1.0}, {0.0,1.0,1.0}};&lt;br /&gt;void&lt;br /&gt;polygon(int a, int b, int c , int d)&lt;br /&gt;{&lt;br /&gt;glBegin(GL_POLYGON);&lt;br /&gt;glColor3fv(colors[a]);&lt;br /&gt;glNormal3fv(normals[a]);&lt;br /&gt;glVertex3fv(vertices[a]);&lt;br /&gt;glColor3fv(colors[b]);&lt;br /&gt;glNormal3fv(normals[b]);&lt;br /&gt;glVertex3fv(vertices[b]);&lt;br /&gt;glColor3fv(colors[c]);&lt;br /&gt;glNormal3fv(normals[c]);&lt;br /&gt;glVertex3fv(vertices[c]);&lt;br /&gt;glColor3fv(colors[d]);&lt;br /&gt;glNormal3fv(normals[d]);&lt;br /&gt;glVertex3fv(vertices[d]);&lt;br /&gt;glEnd();&lt;br /&gt;}&lt;br /&gt;void&lt;br /&gt;colorcube()&lt;br /&gt;{&lt;br /&gt;polygon(0,3,2,1);&lt;br /&gt;polygon(2,3,7,6);&lt;br /&gt;polygon(0,4,7,3);&lt;br /&gt;polygon(1,2,6,5);&lt;br /&gt;polygon(4,5,6,7);&lt;br /&gt;polygon(0,1,5,4);&lt;br /&gt;}&lt;br /&gt;static GLfloat theta[] = {0.0,0.0,0.0};&lt;br /&gt;static GLint axis = 2;&lt;br /&gt;void&lt;br /&gt;display(void)&lt;br /&gt;{&lt;br /&gt;glClear(GL_COLOR_BUFFER_BIT  GL_DEPTH_BUFFER_BIT);&lt;br /&gt;glLoadIdentity();&lt;br /&gt;glRotatef(theta[0], 1.0, 0.0, 0.0);&lt;br /&gt;glRotatef(theta[1], 0.0, 1.0, 0.0);&lt;br /&gt;glRotatef(theta[2], 0.0, 0.0, 1.0);&lt;br /&gt;colorcube();&lt;br /&gt;glFlush();&lt;br /&gt;}&lt;br /&gt;void spinCube()&lt;br /&gt;{&lt;br /&gt;theta[axis] += 2.0;&lt;br /&gt;if( theta[axis] &gt; 360.0 ) theta[axis] -= 360.0;&lt;br /&gt;display();&lt;br /&gt;}&lt;br /&gt;void mouse(int btn, int state, int x, int y)&lt;br /&gt;{&lt;br /&gt;if(btn==GLUT_LEFT_BUTTON &amp;amp; state == GLUT_DOWN) axis = 0;&lt;br /&gt;if(btn==GLUT_MIDDLE_BUTTON &amp;amp; state == GLUT_DOWN) axis = 1;&lt;br /&gt;if(btn==GLUT_RIGHT_BUTTON &amp;amp; state == GLUT_DOWN) axis = 2;&lt;br /&gt;}&lt;br /&gt;void&lt;br /&gt;myReshape(int w, int h)&lt;br /&gt;{&lt;br /&gt;glViewport(0, 0, w, h);&lt;br /&gt;glMatrixMode(GL_PROJECTION);&lt;br /&gt;glLoadIdentity();&lt;br /&gt;if (w &lt;= h)&lt;br /&gt;glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w,&lt;br /&gt;2.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0);&lt;br /&gt;else&lt;br /&gt;glOrtho(-2.0 * (GLfloat) w / (GLfloat) h,&lt;br /&gt;2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, -10.0, 10.0);&lt;br /&gt;glMatrixMode(GL_MODELVIEW);&lt;br /&gt;}&lt;br /&gt;void&lt;br /&gt;main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt;glutInit(&amp;amp;argc, argv);&lt;br /&gt;glutInitDisplayMode(GLUT_SINGLE  GLUT_RGB  GLUT_DEPTH);&lt;br /&gt;glutInitWindowSize(500, 500);&lt;br /&gt;glutCreateWindow("colorcube");&lt;br /&gt;glutReshapeFunc(myReshape);&lt;br /&gt;glutDisplayFunc(display);&lt;br /&gt;glutIdleFunc(spinCube);&lt;br /&gt;glutMouseFunc(mouse);&lt;br /&gt;glEnable(GL_DEPTH_TEST);&lt;br /&gt;glutMainLoop();&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4185144357140522282?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4185144357140522282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4185144357140522282' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4185144357140522282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4185144357140522282'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/drawing-single-cube.html' title='Drawing Single Cube'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-6948580261528397240</id><published>2008-12-11T06:18:00.000-08:00</published><updated>2008-12-22T21:29:32.540-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>program has a variable</title><content type='html'>#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int main(){&lt;br /&gt;  int number;   number = 5; &lt;br /&gt; cout &lt;&lt; "The value in number is " &lt;&lt; number &lt;&lt; endl;  &lt;br /&gt;return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-6948580261528397240?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/6948580261528397240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=6948580261528397240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6948580261528397240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6948580261528397240'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/program-has-variable.html' title='program has a variable'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7439006819870477841</id><published>2008-12-11T06:17:00.002-08:00</published><updated>2008-12-22T21:29:32.541-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>well-adjusted printing program</title><content type='html'>#include &lt;iostream&gt;using namespace std;int main()&lt;br /&gt;{  &lt;br /&gt;cout &lt;&lt; "The following items were top sellers" &lt;&lt; endl;   cout &lt;&lt; "during the month of June:" &lt;&lt; endl;   cout &lt;&lt; "Computer games" &lt;&lt; endl;   cout &lt;&lt; "Coffee" &lt;&lt; endl;   cout &lt;&lt; "Aspirin" &lt;&lt; endl;   return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7439006819870477841?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7439006819870477841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7439006819870477841' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7439006819870477841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7439006819870477841'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/well-adjusted-printing-program.html' title='well-adjusted printing program'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1505285731268387136</id><published>2008-12-11T06:17:00.001-08:00</published><updated>2008-12-22T21:29:32.541-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>printing program</title><content type='html'>// An unruly printing program&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;cout &lt;&lt; "The following items were top sellers";&lt;br /&gt;cout &lt;&lt; "during the month of June:";&lt;br /&gt;cout &lt;&lt; "Computer games";&lt;br /&gt;cout &lt;&lt; "Coffee";&lt;br /&gt;cout &lt;&lt; "Aspirin";&lt;br /&gt;return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1505285731268387136?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1505285731268387136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1505285731268387136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1505285731268387136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1505285731268387136'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/printing-program.html' title='printing program'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5594250930708027024</id><published>2008-12-11T06:15:00.000-08:00</published><updated>2008-12-22T21:29:32.541-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>calculates the user's pay</title><content type='html'>// This progam calculates the user's pay.&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;double hours, rate, pay;&lt;br /&gt;// Get the number of hours worked.&lt;br /&gt;cout &lt;&lt; "How many hours did you work? ";&lt;br /&gt;cin &gt;&gt; hours;&lt;br /&gt;&lt;br /&gt;// Get the hourly pay rate.&lt;br /&gt;cout &lt;&lt; "How much do you get paid per hour? ";&lt;br /&gt;cin &gt;&gt; rate;&lt;br /&gt;&lt;br /&gt;// Calculate the pay.&lt;br /&gt;pay = hours * rate;&lt;br /&gt;&lt;br /&gt;// Display the pay.&lt;br /&gt;cout &lt;&lt; "You have earned $" &lt;&lt; pay &lt;&lt; endl;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5594250930708027024?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5594250930708027024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5594250930708027024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5594250930708027024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5594250930708027024'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/12/calculates-users-pay.html' title='calculates the user&apos;s pay'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-2852502368434535436</id><published>2008-11-19T21:51:00.000-08:00</published><updated>2008-12-22T21:29:32.542-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>User Authentication</title><content type='html'>&lt;?php&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;user.authenticate&lt;br /&gt;Determine if the user blackbeard with a password of avast888 is valid.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;include('xmlrpc-2_1/lib/xmlrpc.inc');&lt;br /&gt;include('class.RevverAPI.php');&lt;br /&gt;&lt;br /&gt;$api = new RevverAPI('https://api.staging.revver.com/xml/1.0?login=revtester&amp;amp;passwd=testacct');&lt;br /&gt;&lt;br /&gt;$username = 'blackbeard';&lt;br /&gt;$password = 'avast888';&lt;br /&gt;&lt;br /&gt;$results = $api-&gt;callRemote('user.authenticate', $username, $password);&lt;br /&gt;&lt;br /&gt;echo '&lt;pre&gt;';&lt;br /&gt;var_dump($results);&lt;br /&gt;echo '&lt;/pre&gt;';&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-2852502368434535436?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/2852502368434535436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=2852502368434535436' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2852502368434535436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2852502368434535436'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/11/user-authentication.html' title='User Authentication'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-6215215077762264124</id><published>2008-11-19T21:50:00.000-08:00</published><updated>2008-12-22T21:29:32.542-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Create Video</title><content type='html'>&lt;?php&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;video.create&lt;br /&gt;Create the metadata for video 65535.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;include('xmlrpc-2_1/lib/xmlrpc.inc');&lt;br /&gt;include('class.RevverAPI.php');&lt;br /&gt;&lt;br /&gt;$api = new RevverAPI('https://api.staging.revver.com/xml/1.0?login=revtester&amp;amp;passwd=testacct');&lt;br /&gt;&lt;br /&gt;$id = 65535;&lt;br /&gt;$title = 'My New Parrot';&lt;br /&gt;$keywords = array('parrot', 'pet');&lt;br /&gt;$ageRestriction = 1;&lt;br /&gt;$options = array('url' =&gt; 'arrvideos.example.com', 'author' =&gt; 'Billy Doyle');&lt;br /&gt;&lt;br /&gt;$results = $api-&gt;callRemote('video.create', $id, $title, $keywords, $ageRestriction, $options);&lt;br /&gt;&lt;br /&gt;echo '&lt;pre&gt;';&lt;br /&gt;var_dump($results);&lt;br /&gt;echo '&lt;/pre&gt;';&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-6215215077762264124?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/6215215077762264124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=6215215077762264124' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6215215077762264124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6215215077762264124'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/11/create-video.html' title='Create Video'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5352513399143507828</id><published>2008-11-09T22:04:00.000-08:00</published><updated>2008-12-22T21:29:32.542-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Heap'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Heap Demo project</title><content type='html'>Heap Demo is a project designed to show the relationship between virtual and committed&lt;br /&gt;memory during heap use.  Using a contrived scenario, a stair-step growth of virtual&lt;br /&gt;memory can be observed in perfmon.&lt;br /&gt;&lt;br /&gt;Open a new cpp file in Visual Studio. copy and paste  code from this post. compile the file it will create project for u. then u can proceed further&lt;br /&gt;&lt;br /&gt;1. Start the HeapDemo application.&lt;br /&gt;2. Open perfmon.&lt;br /&gt;3. Add counters for Virtual Bytes and Private Bytes for the HeapDemo Process.&lt;br /&gt;4. Change the scale for each counter to 0.0000001 (lowest value).&lt;br /&gt;5. Press ENTER on the console for HeapDemo to start the allocations.&lt;br /&gt;6. Watch the perfmon window as memory is allocated.&lt;br /&gt;&lt;br /&gt;Note the stair step behavior of virtual memory.  Each time the private bytes nears the amount&lt;br /&gt;of virtual bytes reserved, the memory manager extends the heap by reserving more virtual&lt;br /&gt;memory.  Each time the heap is extended, it reserves twice as much as the previous reservation.&lt;br /&gt;&lt;br /&gt;// Tthe entry point for the console application.&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;void Test();&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;   Test();&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void Test()&lt;br /&gt;{&lt;br /&gt;   int nCount = 0;&lt;br /&gt;   int nTotal = 0;&lt;br /&gt;   char c;&lt;br /&gt;&lt;br /&gt;   // scanf in here only to hold process in initial loaded state to set up PerfMon.&lt;br /&gt;   printf("Set up Process Object's Private and Virtual Bytes for Heapdemo.exe, then hit ENTER to start the test\n");&lt;br /&gt;   scanf(&amp;amp;c);&lt;br /&gt;&lt;br /&gt;   Sleep(1000);&lt;br /&gt;   while(nTotal &lt; 200000)&lt;br /&gt;   {&lt;br /&gt;      nCount++;&lt;br /&gt;      int (*i)[1024] = new int[100][1024];&lt;br /&gt;      nTotal += 100;&lt;br /&gt;      printf("Allocated: %d KB\n", nTotal);&lt;br /&gt;      Sleep(50);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   printf("Hit any key to end the test and release all memory\n");&lt;br /&gt;   scanf(&amp;amp;c);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5352513399143507828?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5352513399143507828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5352513399143507828' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5352513399143507828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5352513399143507828'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/11/heap-demo-project.html' title='Heap Demo project'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7585428123095330678</id><published>2008-10-23T03:29:00.001-07:00</published><updated>2008-12-22T21:29:32.543-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>TCPDate Server / Client </title><content type='html'>&lt;title&gt;Welcome to Learn C# - the easy way , by Saurabh Nandu.&lt;/title&gt;&lt;link href="tcpdate_files/mystyle.css" type="text/css" rel="stylesheet"&gt;&lt;h3 class="newsheading" align="center"&gt;&lt;br /&gt;&lt;/h3&gt; &lt;table border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="10"&gt;&lt;/td&gt; &lt;td width="97%"&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;    This is the implementation of  "System.Net.Sockets". In this example we will learn how to use the "TCPListener"  and "TCPClient" classes from the "System.Net.Sockets" namespace.&lt;br /&gt;    This  example consists of two files. The "DateServer" class which uses the  "TCPListener" class to accept requests from new clients. Once the client is  connected with the server, the server will send it the the Current Date and Time  and then disconnect it, and listen for more clients.&lt;br /&gt;The "DateClient" class  uses the 'TCPClient" class. It connects to the server on the specified port and  send the clients name to the server upon connection.&lt;br /&gt;Once connected it  receives the current Date Time from the server and then disconnects from the  server.&lt;br /&gt;&lt;br /&gt;Execution :&lt;br /&gt;1) Run the DateServer.exe first to start the  server .(The server by default listens for connection on port 4554).&lt;br /&gt;2) Run  the DateClient.exe which will connect to the server and get the current date  time from it.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;"&gt;&lt;a href="http://aspx1.brinkster.com/sanddy19/download.htm"&gt;&lt;span style="font-size:85%;"&gt;Download  The Code&lt;/span&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;(TCPDate.zip)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td width="20"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Code:&lt;br /&gt;1) &lt;i&gt;DateServer.cs :- The Date Time  Server&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;table class="titbody" border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;pre&gt;&lt;span style="font-family:Verdana;font-size:78%;"&gt;namespace SaurabhNet {  using System;  using System.Net.Sockets;  using System.Net ;  using System.Threading ;  &lt;span style="color:#0000cc;"&gt;//Import the necessary Namespaces&lt;/span&gt;   &lt;span style="color:#0000cc;"&gt;//Class which shows the implementation of the TCP Date server&lt;/span&gt; 	  public class DateServer   {    private TCPListener myListener ;    private int port = 4554 ;    &lt;span style="color:#0000cc;"&gt;//The constructor which make the TCPListener start listening on the    //given port.    //It also calls a Thread on the method StartListen(). &lt;see cref="StartListen"&gt;&lt;/see&gt;&lt;/span&gt;    public DateServer()    {      try{ 	  &lt;span style="color:#0000cc;"&gt;//start listing on the given port&lt;/span&gt; 	  myListener = new TCPListener(port) ; 	  myListener.Start(); 	  Console.WriteLine("Server Ready - Listining for new Connections ...") ; 	  &lt;span style="color:#0000cc;"&gt;//start the thread which calls the method 'StartListen'&lt;/span&gt; 	  Thread th = new Thread(new ThreadStart(StartListen)); 	  th.Start() ; 					 	} 	catch(Exception e) 	{ 	  Console.WriteLine("An Exception Occured while Listing :"+e.ToString()); 	}     } 				     &lt;span style="color:#0000cc;"&gt;//main entry point of the class&lt;/span&gt;     public static void Main(String[] argv)     {       DateServer dts = new DateServer();     }      &lt;span style="color:#0000cc;"&gt;//This method Accepts new connection and     //First it receives the welcome massage from the client,     //Then it sends the Current time to the Client.&lt;/span&gt;     public void StartListen()     {       while(true)       { 	&lt;span style="color:#0000cc;"&gt;//Accept a new connection&lt;/span&gt; 	Socket mySocket = myListener.Accept() ; 	if(mySocket.Connected) 	{ 	  Console.WriteLine("Client Connected!!") ; 	  &lt;span style="color:#0000cc;"&gt;//make a byte array and receive data from the client &lt;/span&gt; 	  Byte[] receive = new Byte[64] ; 	  int i=mySocket.Receive(receive,receive.Length,0) ; 	  char[] unwanted = {' ',' ',' '}; 	  string rece = System.Text.Encoding.ASCII.GetString(receive); 	  Console.WriteLine(rece.TrimEnd(unwanted)) ; 	  &lt;span style="color:#0000cc;"&gt;//get the current date/time and convert it to string&lt;/span&gt; 	  DateTime now = DateTime.Now; 	  String strDateLine ="Server: The Date/Time Now is: "+ now.ToShortDateString()  		+ " " + now.ToShortTimeString(); 	  &lt;span style="color:#0000cc;"&gt;// Convert to byte array and send&lt;/span&gt; 	  Byte[] byteDateLine=Text.Encoding.ASCII.GetBytes(strDateLine.ToCharArray()); 	  mySocket.Send(byteDateLine,byteDateLine.Length,0); 	}       }     }   } }	&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;2)&lt;i&gt; DateClient.cs:- The Date Time Client&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;table class="titbody" border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;pre&gt;&lt;span style="font-family:Verdana;font-size:78%;"&gt;namespace SaurabhNet {   using System ;   using System.Net.Sockets ;   using System.Net ;   using System.Threading ; 		   &lt;span style="color:#0000cc;"&gt;//Class which shows the implementation of the TCP Date Client&lt;/span&gt;   public class DateClient    {     &lt;span style="color:#0000cc;"&gt;//the needed member fields&lt;/span&gt;     private TCPClient tcpc;     private string name ;     private int port=4554 ;     private bool readData=false ; 		     &lt;span style="color:#0000cc;"&gt;//Constructor which contains all the code for the client.     //It connects to the server and sends the clients name,      //Then it waits and receives the date from the server&lt;/span&gt;     public DateClient(string name)     {       &lt;span style="color:#0000cc;"&gt;//a label&lt;/span&gt;       tryagain :       this.name=name ;       try       { 	&lt;span style="color:#0000cc;"&gt;//connect to the "localhost" at the give port 	//if you have some other server name then you can use that  	//instead of "localhost"&lt;/span&gt; 	tcpc =new TCPClient("localhost",port) ; 	&lt;span style="color:#0000cc;"&gt;//get a Network stream from the server&lt;/span&gt; 	NetworkStream nts = tcpc.GetStream() ; 	&lt;span style="color:#0000cc;"&gt;//if the stream is writiable then write to the server&lt;/span&gt; 	if(nts.CanWrite) 	{ 	  string sender = "Hi Server I am "+name ; 	  Byte[] sends = System.Text.Encoding.ASCII.GetBytes(sender.ToCharArray()); 	  nts.Write(sends,0,sends.Length) ; 	  &lt;span style="color:#0000cc;"&gt;//flush to stream &lt;/span&gt; 	  nts.Flush() ; 	} 	&lt;span style="color:#0000cc;"&gt;//make a loop to wait until some data is read from the stream&lt;/span&gt; 	while(!readData&amp;amp;&amp;amp;nts.CanRead) 	{ 	  &lt;span style="color:#0000cc;"&gt;//if data available then read from the stream&lt;/span&gt; 	  if(nts.DataAvailable) 	  { 	    byte[] rcd = new byte[128]; 	    int i=nts.Read( rcd,0,128); 	    string ree = System.Text.Encoding.ASCII.GetString(rcd); 	    char[] unwanted = {' ',' ',' '}; 	    Console.WriteLine(ree.TrimEnd(unwanted)) ; 	    &lt;span style="color:#0000cc;"&gt;//Exit the loop  &lt;/span&gt;  	    readData=true ; 	   } 	}       }       catch(Exception e)       { 	Console.WriteLine("Could not Connect to server because "+e.ToString()); 	&lt;span style="color:#0000cc;"&gt;//Here an exception can be cause if the client is started before starting 	//the server. 	//A good way to handle such exceptions and give the client  	//a chance to re-try to connect to the server&lt;/span&gt; 	Console.Write("Do you want to try Again? [y/n]: ") ; 	char check = Console.ReadLine().ToChar(); 	if(check=='y'|| check=='Y') 	goto tryagain ;       }     }      &lt;span style="color:#0000cc;"&gt;//Main Entry point of the client class&lt;/span&gt;     public static void Main(string[] argv)     {       &lt;span style="color:#0000cc;"&gt;//check to see if the user has entered his name       //if not ask him if he wants to enter his name.&lt;/span&gt;       if(argv.Length&lt;=0)       { 	Console.WriteLine("Usage: DataClient &lt;yourname&gt;") ; 	Console.Write("Would You like to enter your name now [y/n] ?") ; 	char check = Console.ReadLine().ToChar(); 	if(check=='y'|| check=='Y') 	{ 	  Console.Write("Please enter you name :") ; 	  string newname=Console.ReadLine(); 	  DateClient dc = new DateClient(newname) ; 	  Console.WriteLine("Disconnected!!") ; 	  Console.ReadLine() ; 	}       }       else       { 	DateClient dc = new DateClient(argv[0]) ; 	Console.WriteLine("Disconnected!!") ; 	Console.ReadLine() ;       }     }   } }&lt;/yourname&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7585428123095330678?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7585428123095330678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7585428123095330678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7585428123095330678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7585428123095330678'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/10/tcpdate-server-client.html' title='TCPDate Server / Client '/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1691890477424608037</id><published>2008-10-23T03:27:00.001-07:00</published><updated>2008-12-22T21:29:32.543-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Symmetric File Encryption / Decryption </title><content type='html'>&lt;title&gt;Welcome to Learn C# - the easy way , by Saurabh Nandu.&lt;/title&gt;&lt;link href="symencryption_files/mystyle.css" type="text/css" rel="stylesheet"&gt;&lt;h3 class="newsheading" align="center"&gt;&lt;br /&gt;&lt;/h3&gt; &lt;table border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="10"&gt;&lt;/td&gt; &lt;td width="97%"&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;   Cryptography ..... Storing your  files in such a way that no-one except you can view the file, does have a lot of  importance today. Cryptography is basically of 2 types Asymmetric and Symmetric.  Asymmetric encryption is based on the concept of Public and Private Key's. On  the other hand Symmetric encryption is based on a single 'Key' . Hence it up to  the person to first send the password to the receiver of the file so that he can  decrypt it.&lt;br /&gt;  In this example we learn how to use 2 of the Symmetric  encryption algorithms namely Data Encryption Standard (DES) and RC2. Both these  are Key based algorithms. Here we use 64 bit encryption in DES and 40 bit  encryption in RC2 .&lt;br /&gt;Also in this example you will learn how to write your own  implementations of the "ICryptoStream" interface.&lt;br /&gt;  To encrypt the file the  user has to select the file to encrypt and the file to save the encrypted data  in. The file gets encrypted with the password provided by the user using either  of the two algorithms selected by the user.&lt;br /&gt;Decryption checks the input file  for validity and the algorithm used in encryption automatically. So you do not  have to provide with the encryption algorithm used. The program reads it from  the automatically from the encrypted file. If the password provided for  decryption is same as the one used for encryption then the file will  decrypt.&lt;br /&gt;Both binary and text files can be encrypted / decrypted .&lt;br /&gt;  If  you have gone through the .NET SDK then you will find that I have used the  Microsoft's Example on DES encryption example and built my code on it.&lt;br /&gt;  I  will give you a rough Idea of how the encryption takes place.&lt;br /&gt;First the  Password given by the user is Hashed by the "SHA1_CSP" class. By default the  SHA1_CSP class returns a Hash of 20bytes maximum. As I said we are using  Symmetric Algorithms which require a 'Key' to work, so then depending on the  algorithm the size of the Key defers. In DES we use a 64 bit 'Key' while in  'RC2' we use a 40 bit key. Hence depending on the Key size we store the Hash of  the password in a byte array. Also required by the encryption /decryption  algorithms is a initialization 'Vector'. The size of the 'Key' and 'Vector'  remain the same. So for DES which requires a 64 bit Key, we use a 64 Bit Vector  similarly for 'RC2' we use a 40 bit Vector.&lt;br /&gt;  Once the Key and Vector are  generated these are feed into a "SymmetricStreamEncryptor" class which encrypts  / decrypts the bytes depending on the Algorithm , Key and Vector and writes it  out to a File. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;"&gt;&lt;a href="http://aspx1.brinkster.com/sanddy19/download.htm"&gt;&lt;span style="font-size:85%;"&gt;Download  The Code&lt;/span&gt;&lt;/a&gt; &lt;span style="font-size:85%;"&gt;(SymEncryptor.zip)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td width="20"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="center"&gt;&lt;img src="symencryption_files/symenc.jpg" border="0" width="400" height="400" /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Code:&lt;br /&gt;1) &lt;i&gt;SymEncryptor.cs :- The File Encryptor / Decryptor  (Only relevant code)&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;table class="titbody" border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;pre&gt;&lt;span style="font-family:Verdana;font-size:78%;"&gt;namespace SaurabhCrypto {   using System;   using System.Drawing;   using System.ComponentModel;   using System.WinForms;   using System.IO ;   using System.Security;   using System.Security.Cryptography;    &lt;span style="color:#0000ff;"&gt;//    Class which will Encrypt and Decrypt files&lt;/span&gt;   public class SymEncryptor : System.WinForms.Form {      &lt;span style="color:#0000ff;"&gt;//    Required by the Win Forms designer&lt;/span&gt;      private System.ComponentModel.Container components;     private System.WinForms.SaveFileDialog saveFileDialog1;     private System.WinForms.OpenFileDialog openFileDialog1;     private System.WinForms.StatusBar statusBar1;     private System.WinForms.Button decryptb;     private System.WinForms.Button encryptb;     private System.WinForms.RadioButton radioButton2;     private System.WinForms.RadioButton radioButton1;     private System.WinForms.Label infol;     private System.WinForms.TextBox passt;     private System.WinForms.Label passl;     private System.WinForms.Button saveb;     private System.WinForms.Button openb;     private System.WinForms.TextBox savet;     private System.WinForms.TextBox opent;     private System.WinForms.Label savel;     private System.WinForms.Label openl;          &lt;span style="color:#0000ff;"&gt;//these byte arrays will contain the 'KEY' and 'Vector' used in      //encryption and decryption .&lt;/span&gt;     private byte[] symKey ;     private byte[] symIV ;            &lt;span style="color:#0000ff;"&gt;//This is the constructor of the class.     //It calls only one method 'InitlizeComponent' which draws the WinForm .&lt;/span&gt;     public SymEncryptor() {      &lt;span style="color:#0000ff;"&gt; // Call the method to make the WinForm&lt;/span&gt;       InitializeComponent();     }      &lt;span style="color:#0000ff;"&gt;//This method is called when the WinForm exits and it     //Cleans up any resources being used&lt;/span&gt;     public override void Dispose() {       base.Dispose();       components.Dispose();     }     &lt;span style="color:#0000ff;"&gt;//    The main entry point for the application.&lt;/span&gt;     public static void Main(string[] args) {       Application.Run(new SymEncryptor());     }     &lt;span style="color:#0000ff;"&gt;//Method called from the constructor     //It initialises all the WinForm components&lt;/span&gt;     private void InitializeComponent()     { 	&lt;span style="color:#0000ff;"&gt;//Here the WinForm components are placed 	//I have removed this code for explanation purpose 	//You can get the full code when you download the example	&lt;/span&gt;     }     &lt;span style="color:#0000ff;"&gt;//This method is called when the 'Decrypt' button is clicked by the user.     //It first checks the file type and then calls the required methods to       //decrypt the file .&lt;/span&gt;     protected void decryptb_click(object sender, System.EventArgs e)     {       &lt;span style="color:#0000ff;"&gt;//call the method 'ValidateBoxes()' which checks all the fields of the WinForm and        //returns a 'true' if everything is filled properly       //if there are some errors it returns a 'false'	&lt;/span&gt;       if(ValidateBoxes())       { 	&lt;span style="color:#0000ff;"&gt;//if all the Fields of the WinForm are valid then call the method 'DecryptData() ' 	//this method takes care of all the decrypting to do&lt;/span&gt; 	DecryptData(); 			 	&lt;span style="color:#0000ff;"&gt;//after decrypting set all the TextBoxes to their default values 	//this is not necessary but more user friendly...&lt;/span&gt; 	opent.Text=""; 	savet.Text="" ; 	passt.Text="" ; 	radioButton1.Checked=true ;       }     }    &lt;span style="color:#0000ff;"&gt; //This method is called when the 'Encrypt' button is pressed in the WinForm.     //It checks the file and encrypts it according to the algoritm specified by the user.&lt;/span&gt;     protected void encryptb_click(object sender, System.EventArgs e)     {       &lt;span style="color:#0000ff;"&gt;//a method 'ValidateBoxes()' is called which returns a true only if all the fields of the        //WinForm are properly filled &lt;/span&gt;       if(ValidateBoxes())       { 	&lt;span style="color:#0000ff;"&gt;//Here we make a call the a method 'GenerateKee(bool variable)'  	//this method takes in a bool value and generates the Hash 'Key' 	//and 'Initialization Vector' which will be used in encryption / decryption 	//it returns a 'true' if everything is properly generated 	//Here we Pass the 'radioButton1.Checked' as an argument since the method generates  	//'key' and 'vector' depending on which algorithm to use 	//so if 'radioButton1.Checked=true' it means we are using the 'DES' algorithm 	//else we are using the 'RC2' algorithm&lt;/span&gt; 	if(GenerateKee(radioButton1.Checked)) 	{&lt;span style="color:#0000ff;"&gt; 	  //call the method 'EncryptData()' which will take care of all the encrypting&lt;/span&gt; 	  EncryptData() ; 				 	  &lt;span style="color:#0000ff;"&gt;//Set the TextBoxes to their default values 	  //this can be omitted , but its more user friendly&lt;/span&gt; 	  opent.Text=""; 	  savet.Text="" ; 	  passt.Text="" ; 	  radioButton1.Checked=true ; 	} 			       }     }      &lt;span style="color:#0000ff;"&gt;//This method is called when the 'Save' button is clicked     //	It opens a 'SaveFileDialog' and takes the file to be saved to&lt;/span&gt;     protected void saveb_click(object sender, System.EventArgs e)     {       &lt;span style="color:#0000ff;"&gt;//different parameters of the 'SaveFileDialog' are set here&lt;/span&gt;       saveFileDialog1.Filter = "All files (*.*)|*.* | Encryptor files (*.enc)|*.enc"  ;       saveFileDialog1.FilterIndex = 2 ;       saveFileDialog1.RestoreDirectory = true ;       &lt;span style="color:#0000ff;"&gt;//check if the user has already typed a file to save in the TextBox&lt;/span&gt;       if(savet.Text!="")       { 	&lt;span style="color:#0000ff;"&gt;//if the user has typed a filename in the TextBox then assign that  	//to the dialogs 'FileName' property&lt;/span&gt; 	saveFileDialog1.FileName=savet.Text ;       }       if(saveFileDialog1.ShowDialog() == DialogResult.OK)       {     	&lt;span style="color:#0000ff;"&gt;//when the user presses 'Ok' on the 'SaveFileDialog' then set the  	//text of the TextBox 'savet' to the file selected&lt;/span&gt;        	savet.Text = saveFileDialog1.FileName ;       }     }      &lt;span style="color:#0000ff;"&gt;//This method is called when the 'Open' button is clicked by the user&lt;/span&gt;     protected void openb_click(object sender, System.EventArgs e)     {       &lt;span style="color:#0000ff;"&gt;//Set the various properties of the 'OpenFileDialog'	&lt;/span&gt;       openFileDialog1.Filter = "Encryptor files (*.enc)|*.enc|All files (*.*)|*.*"  ;       openFileDialog1.FilterIndex = 2 ;       openFileDialog1.RestoreDirectory = true ;       &lt;span style="color:#0000ff;"&gt;//check if the user has already typed the file to open in the textbox&lt;/span&gt;       if(opent.Text!="")       { 	&lt;span style="color:#0000ff;"&gt;//Then assign the Dialog the Filename from the TextBox&lt;/span&gt; 	openFileDialog1.FileName = opent.Text ;       }       if(openFileDialog1.ShowDialog() == DialogResult.OK)       {     	&lt;span style="color:#0000ff;"&gt;//if the user presses 'Ok' in the 'OpenFileDialog' then assign the     	//file selected to the textbox&lt;/span&gt;         opent.Text = openFileDialog1.FileName ;       }     }     &lt;span style="color:#0000ff;"&gt;//this method checks if any of the TextBoxes are left empty by the user      //and it generates the error required     //it returns 'true' if all values are proper&lt;/span&gt;     private bool ValidateBoxes()     {       &lt;span style="color:#0000ff;"&gt;//check the 'Open' File textbox	&lt;/span&gt;       if(opent.Text=="")       { 	MessageBox.Show("Please Enter the file to Encrypt / Decrypt !") ; 	return false ;       }       &lt;span style="color:#0000ff;"&gt;//check the 'Save' file textbox&lt;/span&gt;       if(savet.Text=="")       { 	MessageBox.Show("Please Enter the filename to save !") ; 	return false ;       }       &lt;span style="color:#0000ff;"&gt;//check the password textbox&lt;/span&gt;       if(passt.Text=="")       { 	MessageBox.Show("Please Enter the Password Encrypt / Decrypt your file with.") ; 	return false ;       }       &lt;span style="color:#0000ff;"&gt;//if everything is alright return true&lt;/span&gt;       return true ;     }      &lt;span style="color:#0000ff;"&gt;//This Method computes the 'Key' and the 'Vector' to be used in encrypting / decrypting.     //It generates the key according to the algorithm.     //It returns is key generation is successful      //	If the algorithm to be used is 'DES' then it generates a 64bit Key and 64bit Vector     //from the provided 'Password' .Then this is stored in to a 'byte' array having length '8'.      //since 1 byte = 8 bits , hence a byte array having length '8' will contain a key of     //8 x 8 =64 bits.     //We use a 64bit key since DES supports a minimum 64 bit key     //	If the algorithm to be used is 'RC2' then it generates a 40bit Key and a 40 bit Vector     //from the provided 'Password'.     //We use a 40 bit key here since RC2 supports a minimum 40 bit key      //(it does not support a 64bit key).&lt;/span&gt;     private bool GenerateKee(bool isDES)     {       &lt;span style="color:#0000ff;"&gt;//try-catch block&lt;/span&gt;       try       { 	&lt;span style="color:#0000ff;"&gt;//store the password in a string &lt;/span&gt; 	string pass =passt.Text ; 	int i ; 	int len ; 	&lt;span style="color:#0000ff;"&gt;//convert the password in to a Char array&lt;/span&gt; 	char[] cp = pass.ToCharArray() ; 	len = cp.GetLength(0) ; 	&lt;span style="color:#0000ff;"&gt;//initialize a byte array &lt;/span&gt; 	byte[] bt = new byte[len] ; 	&lt;span style="color:#0000ff;"&gt;//convert the Char array of the Password to a byte array&lt;/span&gt; 	for(i=0 ; i&lt;len color="#0000ff"&gt;//if we are producing a Key-Vector for the 'DES' algorithm&lt;/span&gt; 	if(isDES) 	{ 	  &lt;span style="color:#0000ff;"&gt;//initialize the byte arrays which will contain the 'Key' and the 'Vector'  	  //to a length of '8' (see above why we use a array of length '8')&lt;/span&gt; 	  symKey=new byte[8] ; 	  symIV = new byte[8] ; 	 &lt;span style="color:#0000ff;"&gt; //make a instance of the class 'SHA1_CSP()'  	  //this class is useful in converting 'byte' into 'Hash'.	&lt;/span&gt;		 	  SHA1_CSP sha = new SHA1_CSP() ; 	&lt;span style="color:#0000ff;"&gt;  //write the Hash of the byte array containing the password&lt;/span&gt; 	  sha.Write(bt) ; 	  &lt;span style="color:#0000ff;"&gt;//close the stream&lt;/span&gt; 	  sha.CloseStream() ; 	  &lt;span style="color:#0000ff;"&gt;//now Initialize the 'Key' array with the lower 64bits of the Hash of   	  //the 'Password' provided by the user&lt;/span&gt; 	  for(i=0 ; i&lt;8 color="#0000ff"&gt;//initialize the 'Vector' array with the higher 64 bits of Hash of the  	  //'Password' provided by the user&lt;/span&gt; 	  for(i=8 ; i&lt;16 color="#0000ff"&gt;//if the algorithm is 'RC2' then generate the following Key 	  //initialize the Key and Vector arrays to a length of '5' (see above why we use '5') &lt;/span&gt; 	  symKey=new byte[5] ; 	  symIV = new byte[5] ; 	  &lt;span style="color:#0000ff;"&gt;//make a instance of the class 'SHA1_CSP'  	  //this class writes the hash of a given byte		&lt;/span&gt;	 	  SHA1_CSP sha = new SHA1_CSP() ; 	  &lt;span style="color:#0000ff;"&gt;//write the Hash of the byte array containing the user password&lt;/span&gt; 	  sha.Write(bt) ; 	  &lt;span style="color:#0000ff;"&gt;//close the stream&lt;/span&gt; 	  sha.CloseStream() ; 	  &lt;span style="color:#0000ff;"&gt;//now Initialize the Key array to lower 40 bits of the Hash of the 'Password'.&lt;/span&gt; 	  for(i=0 ; i&lt;5 color="#0000ff"&gt;//initilize the Vector array to 40bits of hash &lt;/span&gt; 	  for(i=5 ; i&lt;10 color="#0000ff"&gt;//since every thing went properly return 'true'&lt;/span&gt; 	return true ;	       }       catch(Exception e)       { 	MessageBox.Show("A Exception Occured in Generating Keys :"+e.ToString()) ; 	&lt;span style="color:#0000ff;"&gt;//return false since there was a error&lt;/span&gt; 	return false ;       }     }     &lt;span style="color:#0000ff;"&gt;//This method encrypts the given input file in either of the 2 algorithms 'DES' or 'RC2'.     //Then it writes out the encrypted file     //This method first reads the input file to check to see if its already encrypted by this     //same program. If its already encrypted it gives a error.     //According to the algorithm specified it then encrypts the file.     //Also in the first 8 bytes of the new Encrypted it writes out "[saudes]" or "[saurc2]"     //This is done so the while decrypting the program can know which algorithm was used to     //	encrypt the file. Also it used to check if the file has already encrypted&lt;/span&gt;     private void EncryptData()     {       &lt;span style="color:#0000ff;"&gt;//try-catch block&lt;/span&gt;       try       {	 	bool algo ;  &lt;span style="color:#0000ff;"&gt;//a boolean variable to check which algorithm to use in encrypting&lt;/span&gt; 	&lt;span style="color:#0000ff;"&gt;//open the 'FileStream' on the file to be encrypted&lt;/span&gt; 	FileStream fin = new FileStream(opent.Text , FileMode.Open , FileAccess.Read) ; 	&lt;span style="color:#0000ff;"&gt;//Make a file to save the encrypted data to and open a 'FileStream' on it&lt;/span&gt; 	FileStream fout = new FileStream(savet.Text , FileMode.OpenOrCreate , FileAccess.Write); 	&lt;span style="color:#0000ff;"&gt;//set the position of the 'cursor' to the start of the file&lt;/span&gt; 	fout.SetLength(0) ; 	&lt;span style="color:#0000ff;"&gt;//make a byte array of the size 64 bits 	//this is called the 'Buffer Size' of the algorithm 	//i.e. while encrypting blocks of the size 64bits are processed at a single time 	//later other blocks are of the same size. 	//we use 64bits because both 'DES' and 'RC2' both algorithms have 64 bit 'Buffer Size'&lt;/span&gt; 	byte[] bin = new byte[4096] ; 	&lt;span style="color:#0000ff;"&gt;//set the total length of the file to me encrypted to a variable &lt;/span&gt; 	long totlen = fin.Length ; 	long rdlen=0; 	int len ; 	&lt;span style="color:#0000ff;"&gt;//the code below is used to check if the file has already been encrypted  	//make a byte array of length '4' &lt;/span&gt; 	byte[] tag = new byte[4]; 	&lt;span style="color:#0000ff;"&gt;//read the first 4 bytes from the file to be encrypted&lt;/span&gt;         fin.Read(tag,0,tag.Length);         &lt;span style="color:#0000ff;"&gt;//if it contains the chars "[sau" then it has been already encrypted by this program&lt;/span&gt;         if ((tag[0]==(byte)'[')&amp;amp;&amp;amp;(tag[1]==(byte)'S')&amp;amp;&amp;amp;(tag[2]==(byte)'a')&amp;amp;&amp;amp;(tag[3]==(byte)'u'))         {           &lt;span style="color:#0000ff;"&gt;//generate a error to let the user know of the error&lt;/span&gt;           MessageBox.Show("This file is already Encrypted or in Invalid format!") ;           statusBar1.Text="Error - Invalid File Format !!"  ;                        }         else {           &lt;span style="color:#0000ff;"&gt;//if the file if ok the proceed with encryption&lt;/span&gt;           statusBar1.Text="Encrypting...";           &lt;span style="color:#0000ff;"&gt;//set the file read cursor back to the 'Beginning' of the opened file &lt;/span&gt;           fin.Seek(0, SeekOrigin.Begin);         } 	&lt;span style="color:#0000ff;"&gt;//make a object of the class 'SymmetricAlgorithm'&lt;/span&gt; 	SymmetricAlgorithm des ;         if(radioButton1.Checked)         {           &lt;span style="color:#0000ff;"&gt;//if the algorithm to be used is 'DES' then initialize the 'SymmetricAlgorithm'  	  //to 'DES_CSP'&lt;/span&gt;           des = new DES_CSP();           &lt;span style="color:#0000ff;"&gt;//set the variable to true because we are using 'DES' algorithm.&lt;/span&gt;           algo=true ;         }         else         {           &lt;span style="color:#0000ff;"&gt;//if the algorithm to be used is 'RC2' then initialize the variable 'des'  	  //to 'RC2_CSP'&lt;/span&gt;           des=new RC2_CSP() ;           &lt;span style="color:#0000ff;"&gt;//set the key size of the algorithm to 40 bits since we are using a 40 bit key&lt;/span&gt;           des.KeySize=40 ;           &lt;span style="color:#0000ff;"&gt;//uncomment the below code to find out the bits of keys supported by RC2 algorithm &lt;/span&gt;            	           /*KeySizes[] ks = des.LegalKeySizes ;           Console.WriteLine("Key Sizes Supported :") ;           Console.WriteLine("Minimum Size:" +ks[0].MinSize) ;           Console.WriteLine("Skip size of key: "+ks[0].SkipSize) ;           Console.WriteLine("Maximum Size: "+ks[0].MaxSize) ;           */             	           &lt;span style="color:#0000ff;"&gt;//set the bool variable to false since we are using the RC2 algorithm&lt;/span&gt;           algo=false ;                }         &lt;span style="color:#0000ff;"&gt;//Make a object of the inner class 'StoreCryptoStream' we pass the bool variable         //containing the algorithm information and the FileStream &lt;/span&gt;         StoreCryptoStream scs = new StoreCryptoStream(algo,fout);         &lt;span style="color:#0000ff;"&gt;//make an object of the 'SymmetricStreamEncryptor' class and pass it the          //'Key' and the 'Vector' this stream helps to encrypt data according to the algorithm&lt;/span&gt;         SymmetricStreamEncryptor sse = des.CreateEncryptor(symKey, symIV);         &lt;span style="color:#0000ff;"&gt;// a little extra feature here to show how to compose crypto          // components that support ICryptoStream&lt;/span&gt;         SHA1_CSP sha = new SHA1_CSP();         &lt;span style="color:#0000ff;"&gt;// wire up the encryptor - hash - StoreCryptoStream&lt;/span&gt;         sse.SetSink(sha);	         sha.SetSource(sse);         sha.SetSink(scs);	         scs.SetSource(sha);        &lt;span style="color:#0000ff;"&gt; //read from the file to encrypt &lt;/span&gt;         while (rdlen &lt; color="#0000ff"&gt;//set the number of bytes read&lt;/span&gt;           len = fin.Read(bin,0,4096);           &lt;span style="color:#0000ff;"&gt;//write the encrypted data&lt;/span&gt;           sse.Write(bin,0,len);           &lt;span style="color:#0000ff;"&gt;//increase the size of bytes read&lt;/span&gt;           rdlen = rdlen + len;         }         &lt;span style="color:#0000ff;"&gt;//free up the resources&lt;/span&gt;         sse.CloseStream();         fin.Close(); 	fout.Close() ; 	statusBar1.Text="Encryption Compelete !" ;       }       catch(Exception e)       { 	MessageBox.Show("An exception occured while encrypting :"+e.ToString()) ; 	statusBar1.Text="Error" ;       }     }     &lt;span style="color:#0000ff;"&gt;//This method decrypts the given input file in either of the 2 algorithms 'DES' or 'RC2'.     //Then it writes out the decrypted file     //This method first reads the input file to check to see if its encrypted by which     //algorithm. then it automatically decrypts the file.      //It reads the first 8 bytes of the encrypted file to find the custom tag that we place     //while encrypting.     //If it finds "[saudes]" it uses the 'DES' algorithm to decrypt     //If it finds "[saurc2]" it uses the 'RC2' algorithm to decrypt&lt;/span&gt;     private void DecryptData()     {      &lt;span style="color:#0000ff;"&gt; //try-catch block&lt;/span&gt;       try       { 	statusBar1.Text="Decrypting...." ; 	&lt;span style="color:#0000ff;"&gt;//open file streams to the input and outfiles &lt;/span&gt; 	FileStream fin = new FileStream(opent.Text , FileMode.Open , FileAccess.Read) ; 	FileStream fout = new FileStream(savet.Text ,FileMode.OpenOrCreate ,FileAccess.Write); 	fout.SetLength(0) ; 	&lt;span style="color:#0000ff;"&gt;//a variable to check the validity of the input file&lt;/span&gt; 	bool filecheck = false ; 	&lt;span style="color:#0000ff;"&gt;//make a byte array of the size 64 bits 	//this is called the 'Buffer Size' of the algorithm 	//i.e. while encrypting blocks of the size 64bits are processed at a single time 	//later other blocks are of the same size. 	//we use 64bits because both 'DES' and 'RC2' both algorithms have 64 bit 'Buffer Size'&lt;/span&gt;         byte[] bin = new byte[4096] ; 	long totlen = fin.Length ; 	long rdlen=8; 	int len ; 	&lt;span style="color:#0000ff;"&gt;// declare a object of type 'SymmetricAlgorithm'&lt;/span&gt; 	SymmetricAlgorithm des ; 	&lt;span style="color:#0000ff;"&gt;//set a temporary variable to length '8' (we use '8' since the size of  	//the tag put in the file is 8)&lt;/span&gt; 	byte[] tag = new byte[8]; 	&lt;span style="color:#0000ff;"&gt;//read the first 8 bytes from the input file to check which algorithm is used to  	//encrypt the file&lt;/span&gt;         fin.Read(tag,0,tag.Length);         if ((tag[0]==(byte)'[')&amp;amp;&amp;amp;(tag[1]==(byte)'S')&amp;amp;&amp;amp;(tag[2]==(byte)'a')&amp;amp;&amp;amp;(tag[3]==(byte)'u') 	 &amp;amp;&amp;amp;(tag[4]==(byte)'d')&amp;amp;&amp;amp;(tag[5]==(byte)'e')&amp;amp;&amp;amp;(tag[6]==(byte)'s')&amp;amp;&amp;amp;(tag[7]==(byte)']'))  	{ 	  &lt;span style="color:#0000ff;"&gt;//If this is true then the 'DES' algorithm has been used to encrypt the file 	  //so set the variable 'des' to new 'DES_CSP' &lt;/span&gt; 	  des = new DES_CSP() ; 	  &lt;span style="color:#0000ff;"&gt;//set the variable to true since the file is encrypted&lt;/span&gt; 	  filecheck=true ; 	  &lt;span style="color:#0000ff;"&gt;//generate the Key and Vector from the given password 	  //we send 'true' here since the algorithm used is 'DES' &lt;/span&gt; 	  GenerateKee(true) ; 	} 	else if((tag[0]==(byte)'[')&amp;amp;&amp;amp;(tag[1]==(byte)'S')&amp;amp;&amp;amp;(tag[2]==(byte)'a') 	&amp;amp;&amp;amp;(tag[3]==(byte)'u')&amp;amp;&amp;amp;(tag[4]==(byte)'r')&amp;amp;&amp;amp;(tag[5]==(byte)'c') 	&amp;amp;&amp;amp;(tag[6]==(byte)'2')&amp;amp;&amp;amp;(tag[7]==(byte)']'))  	{ 	  &lt;span style="color:#0000ff;"&gt;//if this is true then the 'RC2' algorithm has been used to encrypt the file 	  //so we set the variable 'des' to new 'RC2_CSP'&lt;/span&gt; 	  des = new RC2_CSP() ; 	  &lt;span style="color:#0000ff;"&gt;//set the keysize of the algorithm&lt;/span&gt; 	  des.KeySize=40 ; 	  &lt;span style="color:#0000ff;"&gt;//set the variable to true since it is encrypted&lt;/span&gt; 	  filecheck=true ; 	  &lt;span style="color:#0000ff;"&gt;//generate the Key and Vector from the password given by the user 	  //we pass false here since we are using 'RC2' algorithm &lt;/span&gt; 	  GenerateKee(false) ; 	} 	else  	{ 	  MessageBox.Show("File Error !! File is not encrypted by SymEncryptor !!") ; 	  &lt;span style="color:#0000ff;"&gt;//set the des to null so no encryption occurs&lt;/span&gt; 	  des=null ; 	  statusBar1.Text="Error "; 	} 	&lt;span style="color:#0000ff;"&gt;//if the file is encrypted then decrypt it&lt;/span&gt; 	if(filecheck){ 	  &lt;span style="color:#0000ff;"&gt;//create a object of the inner class 'StoreCryptoStream'  	  //we pass it the FileStream&lt;/span&gt; 	  StoreCryptoStream scs = new StoreCryptoStream(fout); 	  &lt;span style="color:#0000ff;"&gt;//make a object of this stream passing the Key and Vector 	  //we use this stream since it helps us decrypt data from a 	  //encrypted file&lt;/span&gt; 	  SymmetricStreamDecryptor ssd = des.CreateDecryptor(symKey, symIV);           &lt;span style="color:#0000ff;"&gt;//set up the streams&lt;/span&gt;           ssd.SetSink(scs);           scs.SetSource(ssd);           &lt;span style="color:#0000ff;"&gt;//read the full encrypted file and decrypt&lt;/span&gt;           while (rdlen &lt; color="#0000ff"&gt;//set the length of the number of bytes read&lt;/span&gt;             len = fin.Read(bin,0,4096);             &lt;span style="color:#0000ff;"&gt;//write the decrypted data &lt;/span&gt;             ssd.Write(bin,0,len);             &lt;span style="color:#0000ff;"&gt;//increase the total read bytes variable&lt;/span&gt;             rdlen = rdlen + len;           }           &lt;span style="color:#0000ff;"&gt;//free up the resources&lt;/span&gt;           ssd.CloseStream(); 	} 	fin.Close(); 	fout.Close(); 	statusBar1.Text="Decryption Compelete" ;       }       catch(Exception e)       { 	MessageBox.Show("An exception occured while decrypting :"+e.ToString()) ; 	statusBar1.Text="Error" ;       }	     }      &lt;span style="color:#0000ff;"&gt;//This is a inner class which Implements the 'ICryptoStream' interface     //we write this class so that it will provide us with a custom stream     //which will write and read the way we want it to&lt;/span&gt;     public class StoreCryptoStream : ICryptoStream     {       &lt;span style="color:#0000ff;"&gt;//two byte arrays containing the bytes to be written while encrypting&lt;/span&gt;       static byte[] tag1 = {(byte)'[',(byte)'S',(byte)'a',(byte)'u' ,(byte)'d'  				,(byte)'e',(byte)'s' ,(byte)']'};       static byte[] tag2=  {(byte)'[',(byte)'S',(byte)'a',(byte)'u' ,(byte)'r'  				,(byte)'c',(byte)'2' ,(byte)']'};        FileStream fs;       &lt;span style="color:#0000ff;"&gt;//This is the constructor of this class       //it takes 2 parameters       //1)a bool varable to indicate which algorithm has called it       //if it 'true' then 'DES' has called it , if its 'false' then        //'RC2' has called it.       //2)the FileStream to the output file&lt;/span&gt;       public StoreCryptoStream(bool algo, FileStream fout)        {         fs = fout;         if (algo){          &lt;span style="color:#0000ff;"&gt;//we are here since the variable 'algo' is 'true' indicating that 'DES' algorithm  	 //is being used          //hence it writes the byte array 'tag1' to the output file &lt;/span&gt;          fs.Write(tag1,0,8);         }         else         {           &lt;span style="color:#0000ff;"&gt;//we are here since the variable 'algo' is 'false' indicating that 'RC2'algorithm  	  //is being used           //hence it writes the byte array 'tag2' to the output file &lt;/span&gt;        	  fs.Write(tag2,0,8) ;         }       }    &lt;span style="color:#0000ff;"&gt; //This is another constructor which takes one parameter "FileStream"     //It is called from the decrypting method&lt;/span&gt;     public StoreCryptoStream(FileStream fout)     {       fs=fout ;     }          &lt;span style="color:#0000ff;"&gt;//other methods which have to be implemented&lt;/span&gt;     public virtual void CloseStream() {fs.Close();}     public virtual void CloseStream(Object obj) {fs.Close();}     public virtual void SetSink(ICryptoStream pstm) {}     public virtual void  SetSource(CryptographicObject co) {}     public virtual ICryptoStream  GetSink () {return null;}             &lt;span style="color:#0000ff;"&gt; // Write routines just copy output to the target file&lt;/span&gt;     public virtual void Write(byte[] bin)     {         int len = bin.GetLength(0);         Write(bin, 0, len);     }          public virtual void Write(byte[] bin, int start, int len )     {         fs.Write(bin,start,len);     }   }//StoreCryptoStream class  }//SymEncryptor class }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1691890477424608037?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1691890477424608037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1691890477424608037' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1691890477424608037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1691890477424608037'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/10/symmetric-file-encryption-decryption.html' title='Symmetric File Encryption / Decryption '/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-2854499127819770212</id><published>2008-10-23T03:25:00.000-07:00</published><updated>2008-12-22T21:29:32.543-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C# - The Ping Utility</title><content type='html'>&lt;title&gt;Welcome to Learn C# - the easy way , by Saurabh Nandu.&lt;/title&gt;&lt;link href="ping_files/mystyle.css" type="text/css" rel="stylesheet"&gt; &lt;table border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="97%"&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Ping is a very useful utility used to determine the speed of a Network  Connection. It establishes a socket connection with the given hostname and sends  a Data Packet using ICMP Protocol. The Host then in reply send back a Packet.  The time taken to Send and Receive a Data Packet is calculated in Milliseconds.  This helps us to know the speed of the connection.  &lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;i&gt;Usage:&lt;/i&gt;&lt;br /&gt;Ping &lt;hostname&gt;  /r&lt;br /&gt;where :&lt;br /&gt;&lt;hostname&gt; -  is the Host Address of the Server to  Ping&lt;br /&gt;/r - Optional Switch to ping continuously to the HostName&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;a href="http://aspx1.brinkster.com/sanddy19/download.htm"&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt; &lt;td width="20"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Code:&lt;br /&gt;1) &lt;i&gt;Ping.cs :- The Ping Utility&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;table class="titbody" border="0" width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;pre&gt;&lt;span style="font-family:Verdana;font-size:78%;"&gt;namespace SaurabhPing {   using System;   using System.Net;   using System.Net.Sockets;   &lt;span style="color:#0000cc;"&gt;/// &lt;summary&gt;   ///		The Main Ping Class   /// &lt;/summary&gt;&lt;/span&gt;   class Ping   {     &lt;span style="color:#0000cc;"&gt;//Declare some Constant Variables&lt;/span&gt;     const int SOCKET_ERROR = -1;             const int ICMP_ECHO = 8;     &lt;span style="color:#0000cc;"&gt;/// &lt;summary&gt;     ///		The Starting Point of the Class     ///		It Takes the Hostname parameter     /// &lt;/summary&gt;&lt;/span&gt;     public static void Main(string[] argv)     {       if(argv.Length==0)       { 	&lt;span style="color:#0000cc;"&gt;//If user did not enter any Parameter inform him&lt;/span&gt; 	Console.WriteLine("Usage:Ping &lt;hostname&gt; /r") ; 	Console.WriteLine("&lt;hostname&gt; The name of the Host who you want to ping"); 	Console.WriteLine("/r Ping the host continuously") ;       }       else if(argv.Length==1)       { 	&lt;span style="color:#0000cc;"&gt;//Just the hostname provided by the user 	//call the method "PingHost" and pass the HostName as a parameter&lt;/span&gt; 	PingHost(argv[0]) ;       }       else if(argv.Length==2)       { 	&lt;span style="color:#0000cc;"&gt;//the user provided the hostname and the switch&lt;/span&gt; 	if(argv[1]=="/r") 	{ 	  //loop the ping program 	  while(true) 	  { 		&lt;span style="color:#0000cc;"&gt;//call the method "PingHost" and pass the HostName as a parameter&lt;/span&gt; 		PingHost(argv[0]) ; 	  }         } 	else 	{ 	  &lt;span style="color:#0000cc;"&gt;//if the user provided some other switch&lt;/span&gt; 	  PingHost(argv[0]) ; 	 }        }        else        { 	 &lt;span style="color:#0000cc;"&gt;//Some error occurred&lt;/span&gt; 	 Console.WriteLine("Error in Arguments") ;         }      } 		      &lt;span style="color:#0000cc;"&gt; /// &lt;summary&gt;       ///		This method takes the "hostname" of the server       ///		and then it ping's it and shows the response time       /// &lt;/summary&gt;&lt;/span&gt;       public static void PingHost(string host)       { 	&lt;span style="color:#0000cc;"&gt;//Declare the IPHostEntry &lt;/span&gt; 	IPHostEntry serverHE, fromHE; 	int nBytes = 0; 	int dwStart = 0, dwStop = 0; 	&lt;span style="color:#0000cc;"&gt;//Initilize a Socket of the Type ICMP&lt;/span&gt; 	Socket socket =  	new Socket(AddressFamily.AfINet, SocketType.SockRaw, ProtocolType.ProtICMP); 	 	&lt;span style="color:#0000cc;"&gt;// Get the server endpoint&lt;/span&gt; 	try 	{ 	  serverHE = DNS.GetHostByName(host);	 	} 	catch(Exception) 	{ 	  Console.WriteLine("Host not found"); // fail 	  return ; 	}  	&lt;span style="color:#0000cc;"&gt;// Convert the server IP_EndPoint to an EndPoint&lt;/span&gt; 	IPEndPoint ipepServer = new IPEndPoint(serverHE.AddressList[0], 0); 	EndPoint epServer = (ipepServer);	  	&lt;span style="color:#0000cc;"&gt;// Set the receiving endpoint to the client machine&lt;/span&gt; 	fromHE = DNS.GetHostByName(DNS.GetHostName()); 	IPEndPoint ipEndPointFrom = new IPEndPoint(fromHE.AddressList[0], 0);         	EndPoint EndPointFrom = (ipEndPointFrom);  	int PacketSize = 0; 	IcmpPacket packet = new IcmpPacket(); 	&lt;span style="color:#0000cc;"&gt;// Construct the packet to send&lt;/span&gt; 	packet.Type = ICMP_ECHO; //8 	packet.SubCode = 0; 	packet.CheckSum = UInt16.Parse("0"); 	packet.Identifier   = UInt16.Parse("45");  	packet.SequenceNumber  = UInt16.Parse("0");  	int PingData = 32; // sizeof(IcmpPacket) - 8; 	packet.Data = new Byte[PingData]; 	&lt;span style="color:#0000cc;"&gt;//Initilize the Packet.Data&lt;/span&gt; 	for (int i = 0; i &lt; color="#0000cc"&gt;//Variable to hold the total Packet size&lt;/span&gt; 	PacketSize = PingData + 8; 	Byte [] icmp_pkt_buffer = new Byte[ PacketSize ];  	Int32 Index = 0; 	&lt;span style="color:#0000cc;"&gt;//Call a Method Serialize which counts 	//The total number of Bytes in the Packet&lt;/span&gt; 	Index = Serialize(   	                  packet,  	                 icmp_pkt_buffer,  	                  PacketSize,  	                   PingData ); 	&lt;span style="color:#0000cc;"&gt;//Error in Packet Size&lt;/span&gt; 	if( Index == -1 ) 	{ 	  Console.WriteLine("Error in Making Packet"); 	  return ; 	}            	&lt;span style="color:#0000cc;"&gt;// now get this critter into a UInt16 array 	          	//Get the Half size of the Packet&lt;/span&gt; 	Double double_length = Convert.ToDouble(Index); 	Double dtemp = Math.Ceil( double_length / 2); 	int cksum_buffer_length = Convert.ToInt32(dtemp); 	&lt;span style="color:#0000cc;"&gt;//Create a Byte Array&lt;/span&gt; 	UInt16 [] cksum_buffer = new UInt16[cksum_buffer_length]; 	&lt;span style="color:#0000cc;"&gt;//Code to initialize the Uint16 array &lt;/span&gt; 	int icmp_header_buffer_index = 0; 	for( int i = 0; i &lt; color="#0000cc"&gt;//Call a method which will return a checksum  &lt;/span&gt;            	UInt16 u_cksum = checksum(cksum_buffer, cksum_buffer_length); 	&lt;span style="color:#0000cc;"&gt;//Save the checksum to the Packet&lt;/span&gt; 	packet.CheckSum  = u_cksum;  	             	&lt;span style="color:#0000cc;"&gt;// Now that we have the checksum, serialize the packet again&lt;/span&gt; 	Byte [] sendbuf = new Byte[ PacketSize ];  	&lt;span style="color:#0000cc;"&gt;//again check the packet size&lt;/span&gt; 	Index = Serialize(   	                  packet,  	                  sendbuf,  	                  PacketSize,  	                  PingData ); 	&lt;span style="color:#0000cc;"&gt;//if there is a error report it&lt;/span&gt; 	if( Index == -1 ) 	{ 	  Console.WriteLine("Error in Making Packet"); 	  return ; 	} 	                  	dwStart = System.Environment.TickCount; &lt;span style="color:#0000cc;"&gt;// Start timing&lt;/span&gt; 	&lt;span style="color:#0000cc;"&gt;//send the Pack over the socket&lt;/span&gt; 	if ((nBytes = socket.SendTo(sendbuf, PacketSize, 0, epServer)) == SOCKET_ERROR)  	{		 	  Console.WriteLine("Socket Error cannot Send Packet"); 	} 	&lt;span style="color:#0000cc;"&gt;// Initialize the buffers. The receive buffer is the size of the 	// ICMP header plus the IP header (20 bytes)&lt;/span&gt; 	Byte [] ReceiveBuffer = new Byte[256];  	nBytes = 0; 	&lt;span style="color:#0000cc;"&gt;//Receive the bytes&lt;/span&gt; 	bool recd =false ; 	int timeout=0 ;   	&lt;span style="color:#0000cc;"&gt;//loop for checking the time of the server responding &lt;/span&gt; 	while(!recd) 	{ 	  nBytes = socket.ReceiveFrom(ReceiveBuffer, 256, 0, ref EndPointFrom); 	  if (nBytes == SOCKET_ERROR)  	  { 	    Console.WriteLine("Host not Responding") ; 	    recd=true ; 	    break; 	  } 	  else if(nBytes&gt;0) 	  { 	    dwStop = System.Environment.TickCount - dwStart; &lt;span style="color:#0000cc;"&gt;// stop timing&lt;/span&gt; 	    Console.WriteLine("Reply from "+epServer.ToString()+" in " 		+dwStop+"MS :Bytes Received"+nBytes); 	    recd=true; 	    break; 	  } 	  timeout=System.Environment.TickCount - dwStart; 	  if(timeout&gt;1000) 	  { 	    Console.WriteLine("Time Out") ; 	    recd=true; 	  }         } 	             	&lt;span style="color:#0000cc;"&gt;//close the socket&lt;/span&gt; 	socket.Close();            }       &lt;span style="color:#0000cc;"&gt;/// &lt;summary&gt;       ///  This method get the Packet and calculates the total size        ///  of the Pack by converting it to byte array       /// &lt;/summary&gt;&lt;/span&gt;       public static Int32 Serialize(IcmpPacket packet, Byte[] Buffer, 			Int32 PacketSize, Int32 PingData )       { 	Int32 cbReturn = 0; 	&lt;span style="color:#0000cc;"&gt;// serialize the struct into the array&lt;/span&gt; 	int Index=0;  	Byte [] b_type = new Byte[1]; 	b_type[0] = (packet.Type);  	Byte [] b_code = new Byte[1]; 	b_code[0] = (packet.SubCode);  	Byte [] b_cksum = BitConverter.GetBytes(packet.CheckSum); 	Byte [] b_id = BitConverter.GetBytes(packet.Identifier); 	Byte [] b_seq = BitConverter.GetBytes(packet.SequenceNumber); 	         	&lt;span style="color:#0000cc;"&gt;// Console.WriteLine("Serialize type ");&lt;/span&gt; 	Array.Copy( b_type, 0, Buffer, Index, b_type.Length ); 	Index += b_type.Length; 	         	&lt;span style="color:#0000cc;"&gt;// Console.WriteLine("Serialize code ");&lt;/span&gt; 	Array.Copy( b_code, 0, Buffer, Index, b_code.Length ); 	Index += b_code.Length;  	&lt;span style="color:#0000cc;"&gt;// Console.WriteLine("Serialize cksum ");&lt;/span&gt; 	Array.Copy( b_cksum, 0, Buffer, Index, b_cksum.Length ); 	Index += b_cksum.Length;  	&lt;span style="color:#0000cc;"&gt;// Console.WriteLine("Serialize id ");&lt;/span&gt; 	Array.Copy( b_id, 0, Buffer, Index, b_id.Length ); 	Index += b_id.Length;  	Array.Copy( b_seq, 0, Buffer, Index, b_seq.Length ); 	Index += b_seq.Length;  	&lt;span style="color:#0000cc;"&gt;// copy the data	 &lt;/span&gt;        	Array.Copy( packet.Data, 0, Buffer, Index, PingData ); 	Index += PingData; 	if( Index != PacketSize/* sizeof(IcmpPacket)  */) { 	  cbReturn = -1; 	  return cbReturn; 	}  	cbReturn = Index; 	return cbReturn;       }       &lt;span style="color:#0000cc;"&gt;/// &lt;summary&gt;       ///		This Method has the algorithm to make a checksum        /// &lt;/summary&gt;&lt;/span&gt;       public static UInt16 checksum( UInt16[] buffer, int size )       { 	Int32 cksum = 0; 	int counter;  	counter = 0;  	while ( size &gt; 0 ) {           UInt16 val = buffer[counter];  	  cksum += Convert.ToInt32( buffer[counter] ); 	  counter += 1; 	  size -= 1; 	}  	cksum = (cksum &gt;&gt; 16) + (cksum &amp;amp; 0xffff); 	cksum += (cksum &gt;&gt; 16); 	return (UInt16)(~cksum);       }     } &lt;span style="color:#0000cc;"&gt;// class ping&lt;/span&gt;     &lt;span style="color:#0000cc;"&gt;/// &lt;summary&gt;     ///		Class that holds the Pack information     /// &lt;/summary&gt;&lt;/span&gt;     public class IcmpPacket      {         public Byte  Type;    &lt;span style="color:#0000cc;"&gt;// type of message&lt;/span&gt;        public Byte  SubCode;    &lt;span style="color:#0000cc;"&gt;// type of sub code&lt;/span&gt;        public UInt16 CheckSum;   &lt;span style="color:#0000cc;"&gt;// ones complement checksum of struct&lt;/span&gt;        public UInt16 Identifier;      &lt;span style="color:#0000cc;"&gt;// identifier&lt;/span&gt;        public UInt16 SequenceNumber;     &lt;span style="color:#0000cc;"&gt;// sequence number  &lt;/span&gt;        public Byte [] Data;       } &lt;span style="color:#0000cc;"&gt;// class IcmpPacket&lt;/span&gt; }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-2854499127819770212?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/2854499127819770212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=2854499127819770212' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2854499127819770212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2854499127819770212'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/10/ping-utility.html' title='C# - The Ping Utility'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7372911267121238441</id><published>2008-09-15T05:41:00.000-07:00</published><updated>2008-12-22T21:29:32.544-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threading'/><category scheme='http://www.blogger.com/atom/ns#' term='Synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='MDI'/><category scheme='http://www.blogger.com/atom/ns#' term='SDI'/><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><category scheme='http://www.blogger.com/atom/ns#' term='Doc-View Architecture'/><title type='text'>SDI,MDI, Views, MFC, Doc View Architecture, threading applications</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;SDI/Splitter Window/MDI&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="81" href="http://www.kicit.com/freebies/vcpp/SDISplitter%20WindowMDI/A_simple_splitter_window_example.zip"&gt;A simple splitter window example&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="82" href="http://www.kicit.com/freebies/vcpp/SDISplitter%20WindowMDI/Dynamic_splitter_window.zip"&gt;Dynamic splitter window&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="83" href="http://www.kicit.com/freebies/vcpp/SDISplitter%20WindowMDI/An_MDI_application.zip"&gt;An MDI application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="84" set="yes" href="http://www.kicit.com/freebies/vcpp/SDISplitter%20WindowMDI/Opening_different_types_of_documents_in_MDI_application.zip"&gt;Opening different types of documents in MDI application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Shell&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="85" href="http://www.kicit.com/freebies/vcpp/Shell/Displaying_icon_in_the_system_tray.zip"&gt;Displaying icon in the system tray&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="86" set="yes" href="http://www.kicit.com/freebies/vcpp/Shell/Using_Shell_File_Operation.zip"&gt;Using Shell File Operation&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Threads&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="87" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Creating_and_closing_threads_programmatically.zip"&gt;Creating and closing threads programmatically&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="88" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Displaying_list_of_processes_running_in_the_system.zip"&gt;Displaying list of processes running in the system&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="89" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Worker_Thread.zip"&gt;Worker Thread&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="90" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/User_Interface_Thread.zip"&gt;User Interface Thread&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="91" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Thread_Synchronization_Using_Mutex.zip"&gt;Thread Synchronization Using Mutex&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="92" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Threads_Synchronization_Using_Events%20.zip"&gt;Threads Synchronization Using Events&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="93" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/Using_Critical_Section.zip"&gt;Using Critical Section&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="94" set="yes" href="http://www.kicit.com/freebies/vcpp/threads/More_On_User_Interface_Thread.zip"&gt;More On User Interface Thread&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Views&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="95" set="yes" href="http://www.kicit.com/freebies/vcpp/Views/Windows_Explorer_like_application.zip"&gt;Windows Explorer like application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="96" set="yes" href="http://www.kicit.com/freebies/vcpp/Views/Sorting_items_of_a_list_view_control_on_clicking_on_the_column.zip"&gt;Sorting items of a list view control on clicking on the column&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="97" set="yes" href="http://www.kicit.com/freebies/vcpp/Views/Creating_Wordpad_like_application_using_Rich_Edit_view.zip"&gt;Creating Wordpad like application using Rich Edit view&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="98" href="http://www.kicit.com/freebies/vcpp/Views/A_Scroll_view_application.zip"&gt;A Scroll view application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="99" href="http://www.kicit.com/freebies/vcpp/Views/Creating_a_Browser.zip"&gt;Creating a Browser&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7372911267121238441?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7372911267121238441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7372911267121238441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7372911267121238441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7372911267121238441'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/sdimdi-views-mfc-doc-view-architecture.html' title='SDI,MDI, Views, MFC, Doc View Architecture, threading applications'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7786765562054553499</id><published>2008-09-15T05:39:00.000-07:00</published><updated>2008-12-22T21:29:32.545-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Visual C++ Projects</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;File I/O&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="43" href="http://www.kicit.com/freebies/vcpp/FileIO/Sorting_the_text_file.zip"&gt;Sorting the text file&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="44" set="yes" href="http://www.kicit.com/freebies/vcpp/FileIO/Joker.zip"&gt;Joker&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="45" set="yes" href="http://www.kicit.com/freebies/vcpp/FileIO/File_Properties.zip"&gt;File Properties&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Disk&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="38" href="http://www.kicit.com/freebies/vcpp/Disk/Full%20Disk%20information.zip"&gt;Full Disk information&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;GDI&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="46" href="http://www.kicit.com/freebies/vcpp/GDI/Rotating_Text.zip"&gt;Rotating Text&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="47" href="http://www.kicit.com/freebies/vcpp/GDI/Creating_cliparts.zip"&gt;Creating cliparts&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="48" href="http://www.kicit.com/freebies/vcpp/GDI/Marquee_rectangle.zip"&gt;Marquee rectangle&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="49" href="http://www.kicit.com/freebies/vcpp/GDI/Game_Bow_and_Arrow.zip"&gt;Bow and Arrow&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="50" href="http://www.kicit.com/freebies/vcpp/GDI/Rolling_Your_Own_Mapping_Modes.zip"&gt;Rolling Your Own Mapping Modes&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="51" href="http://www.kicit.com/freebies/vcpp/GDI/Gradient_Fill.zip"&gt;Gradient Fill&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Help&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="52" href="http://www.kicit.com/freebies/vcpp/help/Creating_HTML_help_system.zip"&gt;Creating HTML help system&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Internet&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="53" href="http://www.kicit.com/freebies/vcpp/internet/Browser_application.zip"&gt;Browser application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="54" href="http://www.kicit.com/freebies/vcpp/internet/FTP_Explorer.zip"&gt;FTP Explorer&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="55" href="http://www.kicit.com/freebies/vcpp/internet/MAPI.zip"&gt;MAPI&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="56" href="http://www.kicit.com/freebies/vcpp/internet/File_Operations_Using_HTTP.zip"&gt;File Operations Using HTTP&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="57" href="http://www.kicit.com/freebies/vcpp/internet/File_Operations_Using_FTP.zip"&gt;File Operations Using FTP&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="58" href="http://www.kicit.com/freebies/vcpp/internet/Internet_Programming_Using_FTP.zip"&gt;Internet Programming - Using FTP&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="59" href="http://www.kicit.com/freebies/vcpp/internet/Using_ISAPI_Extension_DLL.zip"&gt;Using ISAPI Extension DLL&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="60" href="http://www.kicit.com/freebies/vcpp/internet/Accessing_Database_Using_ISAPI.zip"&gt;Accessing Database Using ISAPI&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Keyboard&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="61" href="http://www.kicit.com/freebies/vcpp/keyboard/Recognizing_which_shift_toggle_key_is_pressed.zip"&gt;Recognizing which shift/toggle key is pressed&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="62" href="http://www.kicit.com/freebies/vcpp/keyboard/Toggle%20Num%20Lock_Caps%20Lock%20and%20Scroll%20Lock%20keys%20programatically.zip"&gt;Toggle Num Lock, Caps Lock and Scroll Lock keys programatically&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="63" href="http://www.kicit.com/freebies/vcpp/keyboard/Game_Shuffle.zip"&gt;Shuffle&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Menu&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="64" href="http://www.kicit.com/freebies/vcpp/menu/Ownerdrawn_menu_with_colored_lines.zip"&gt;Ownerdrawn menu with colored lines&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="65" href="http://www.kicit.com/freebies/vcpp/menu/Ownerdrawn_menu_with_bitmaps.zip"&gt;Ownerdrawn menu with bitmaps&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="66" href="http://www.kicit.com/freebies/vcpp/menu/Attaching_menu_items_to_the_system_menu.zip"&gt;Attaching menu items to the system menu&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Mouse&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="67" href="http://www.kicit.com/freebies/vcpp/Mouse/Displaying_mouse_coordinates_in_status_bar.zip"&gt;Displaying mouse coordinates in status bar&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="68" href="http://www.kicit.com/freebies/vcpp/Mouse/Memory_game.zip"&gt;Memory game&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="69" href="http://www.kicit.com/freebies/vcpp/Mouse/Tic_Tac_Toe.zip"&gt;Tic Tac Toe&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;OpenGl&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="70" href="http://www.kicit.com/freebies/vcpp/OpenGL/Drawing_simple_shapes.zip"&gt;Drawing simple shapes&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="71" href="http://www.kicit.com/freebies/vcpp/OpenGL/Coloured_cube.zip"&gt;Coloured cube&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="72" href="http://www.kicit.com/freebies/vcpp/OpenGL/Screen_Saver.zip"&gt;Screen Saver&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Palette&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="73" href="http://www.kicit.com/freebies/vcpp/Palette/Palette_demo.zip"&gt;Palette demo&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="74" href="http://www.kicit.com/freebies/vcpp/Palette/Palette_Animation.zip"&gt;Palette Animation&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="75" href="http://www.kicit.com/freebies/vcpp/Palette/How_Windows_Uses_Colors.zip"&gt;How Windows Uses Colors&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Printing&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="76" href="http://www.kicit.com/freebies/vcpp/Printing/A_Sample_Printing_Application.zip"&gt;A Sample Printing Application&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="77" href="http://www.kicit.com/freebies/vcpp/Printing/Printing_a_text_file.zip"&gt;Printing a text file&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Registry&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="78" href="http://www.kicit.com/freebies/vcpp/Registry/A_program_that_runs_only_for_limited_hours.zip"&gt;A program that runs only for limited hours&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="79" href="http://www.kicit.com/freebies/vcpp/Registry/Tip_of_the_day.zip"&gt;Tip Of The Day&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Screen Saver&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="80" href="http://www.kicit.com/freebies/vcpp/Screen%20Saver/Creating_a_simple_screen_saver.zip"&gt;Creating a simple screen saver&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Miscellaneous&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="100" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Balloon_tooltip.zip"&gt;Balloon tooltip&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="101" set="yes" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Hiding_window_button_from_task_bar.zip"&gt;Hiding window button from task bar&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="102" set="yes" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Changing_shape_of_a_window.zip"&gt;Changing shape of a window&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="103" set="yes" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Adding_Splash_Screen_component.zip"&gt;Adding Splash Screen component&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="104" set="yes" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Adding_Multimedia_component.zip"&gt;Adding Multimedia component&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="105" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/MCIWnd.zip"&gt;MCIWnd&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="106" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Rect_Tracker.zip"&gt;Rect Tracker&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="107" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Creating_Control_Panel_Applet.zip"&gt;Creating Control Panel Applet&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="108" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Converting_a_number_to_words.zip"&gt;Converting a number to words&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="109" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Hardware_Information.zip"&gt;Hardware Information&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="110" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Hardware_Information.zip"&gt;Hardware Information&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="111" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/Windows_Hook.zip"&gt;Windows Hook&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="112" href="http://www.kicit.com/freebies/vcpp/Miscellaneous/XOR_Encryptor.zip"&gt;XOR Encryptor&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7786765562054553499?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7786765562054553499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7786765562054553499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7786765562054553499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7786765562054553499'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/visual-c-projects.html' title='Visual C++ Projects'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5039786927230858713</id><published>2008-09-15T05:38:00.000-07:00</published><updated>2008-12-22T21:29:32.545-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dll'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Basic'/><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Dlls - Dynamic link library projects</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;DLL&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="39" href="http://www.kicit.com/freebies/vcpp/DLL/Regular%20DLL.zip"&gt;Regular DLL&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="40" href="http://www.kicit.com/freebies/vcpp/DLL/Extension%20DLL.zip"&gt;Extension DLL&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="41" set="yes" href="http://www.kicit.com/freebies/vcpp/DLL/Implicit_Explici_tlinking.zip"&gt;Implicit/Explicit linking&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="42" href="http://www.kicit.com/freebies/vcpp/DLL/extern_C.zip"&gt;extern "C"&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5039786927230858713?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5039786927230858713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5039786927230858713' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5039786927230858713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5039786927230858713'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/dlls-dynamic-link-library-projects.html' title='Dlls - Dynamic link library projects'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7931838668870190947</id><published>2008-09-15T05:37:00.000-07:00</published><updated>2008-12-22T21:29:32.545-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Nework Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Network programming</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;Network&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="113" set="yes" href="http://www.kicit.com/freebies/vcpp/Network/Enumerating_Network_Resources.zip"&gt;Enumerating Network Resources&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="114" set="yes" href="http://www.kicit.com/freebies/vcpp/Network/Remote_Shutdown.zip"&gt;Remote Shutdown&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7931838668870190947?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7931838668870190947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7931838668870190947' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7931838668870190947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7931838668870190947'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/network-programming.html' title='Network programming'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5464241822021204931</id><published>2008-09-15T05:36:00.002-07:00</published><updated>2008-12-22T21:29:32.546-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sockets'/><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='WinSoc'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Socket Programming</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Socket Programming&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="115" set="yes" href="http://www.kicit.com/freebies/vcpp/Socket%20Programming/Chat_Server_Through_Socket_Programming.zip"&gt;Chat Server Through Socket Programming&lt;/a&gt; (&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="116" set="yes" href="http://www.kicit.com/freebies/vcpp/Socket%20Programming/Multiple_Clients_Chat_Server.zip"&gt;Multiple Clients Chat Server&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5464241822021204931?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5464241822021204931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5464241822021204931' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5464241822021204931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5464241822021204931'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/socket-programming.html' title='Socket Programming'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-6291658148966219750</id><published>2008-09-15T05:36:00.001-07:00</published><updated>2008-12-22T21:29:32.546-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Dialog box</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Dialog&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;p&gt;&lt;a linkindex="37" href="http://www.kicit.com/freebies/vcpp/Dialog/Talking%20Calculator.zip"&gt;Talking Calculator&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-6291658148966219750?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/6291658148966219750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=6291658148966219750' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6291658148966219750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6291658148966219750'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/dialog-box.html' title='Dialog box'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-2840797392929210381</id><published>2008-09-15T05:35:00.001-07:00</published><updated>2008-12-22T21:29:32.547-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><category scheme='http://www.blogger.com/atom/ns#' term='DHTML'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>HTML - DHTML</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;DHTML&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="36" href="http://www.kicit.com/freebies/vcpp/DHTML/Clock.zip"&gt;Clock&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-2840797392929210381?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/2840797392929210381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=2840797392929210381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2840797392929210381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2840797392929210381'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/html-dhtml.html' title='HTML - DHTML'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-3251493487288514847</id><published>2008-09-15T05:34:00.000-07:00</published><updated>2008-12-22T21:29:32.547-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ADO'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Database</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Database&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="33" href="http://www.kicit.com/freebies/vcpp/Database/ODBC%20.zip"&gt;ODBC&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="34" href="http://www.kicit.com/freebies/vcpp/Database/DAO.zip"&gt;DAO&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="35" set="yes" href="http://www.kicit.com/freebies/vcpp/Database/Interacting%20With%20Excel%20Spreadsheet-%20Using%20ODBC.zip"&gt;Interacting With Excel Spreadsheet- Using ODBC&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-3251493487288514847?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/3251493487288514847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=3251493487288514847' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3251493487288514847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3251493487288514847'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/database.html' title='Database'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1256562845817562826</id><published>2008-09-15T05:33:00.000-07:00</published><updated>2008-12-22T21:29:32.548-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Windows Controls</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;Controls&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="23" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Creating%20a%20non-rectangular%20button.zip"&gt;Creating a non-rectangular button&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="24" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Creating%20a%20transparent%20edit%20box.zip"&gt;Creating a transparent edit box&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="25" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Creating_ownerdrawn_combo_box.zip"&gt;Creating ownerdrawn list box&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="26" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Creating_ownerdrawn_combo_box.zip"&gt;Creating ownerdrawn combo box&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="27" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Directory-Tree_control_with_Checkboxes.zip"&gt;Directory-Tree control with Checkboxes&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="28" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Printing_List_View_Control_Contents%20.zip"&gt;Printing List View Control Contents&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="29" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Sorting_List_Control_Items.zip"&gt;Sorting List Control Items&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="30" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/OLE_Drag_And_Drop.zip"&gt;OLE Drag And Drop&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="31" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Implementing_Drag_And_Drop_On_Tree_Items.zip"&gt;Implementing Drag And Drop On Tree Items&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" class="textWithoutIndent" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22"&gt;&lt;a linkindex="32" set="yes" href="http://www.kicit.com/freebies/vcpp/Controls/Displaying_Controls_in_List_Control.zip"&gt;Displaying Controls in List Control&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1256562845817562826?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1256562845817562826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1256562845817562826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1256562845817562826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1256562845817562826'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/windows-controls.html' title='Windows Controls'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5257452066282227428</id><published>2008-09-15T05:32:00.000-07:00</published><updated>2008-12-22T21:29:32.548-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>C++ Projects</title><content type='html'>&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;span class="blueHeading2"&gt;C++&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" bgcolor="#ecf2fc" align="left"&gt;&lt;a linkindex="8" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Elementary_database_management.zip"&gt;Elementary database management&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" bgcolor="#ecf2fc" align="left"&gt;&lt;a linkindex="9" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/The_string_class.zip"&gt;The string class&lt;/a&gt; (&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" bgcolor="#ecf2fc" align="left"&gt;&lt;a linkindex="10" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Tips%20about%20templates.zip"&gt;Tips about templates&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" bgcolor="#ecf2fc" align="left"&gt;&lt;a linkindex="11" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Causes_of_memory_leaks.zip"&gt;Causes of memory leaks&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="12" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Timer_class.zip"&gt;Timer class&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="13" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Customer_Information_System.zip"&gt;Customer Information System&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="14" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Jeeto_Chappar_Phaade_Ke.zip"&gt;Jeeto Chappar Phaade Ke&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="15" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Kaun_Banega_Crorepati.zip"&gt;Kaun Banega Crorepati&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="16" href="http://www.kicit.com/freebies/vcpp/c++/Hangman.zip"&gt;Hangman&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="17" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Calendar_cum_Schedular.zip"&gt;Calendar cum Schedular&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="18" href="http://www.kicit.com/freebies/vcpp/c++/Graphics_Editor.zip"&gt;Graphics Editor&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="19" href="http://www.kicit.com/freebies/vcpp/c++/Bump_Mapping.zip"&gt;Bump Mapping&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="20" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/File_Split_and_Join.zip"&gt;File Split and Join&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="21" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Developing%20GUIs%20in%20C++%20-%20I.zip"&gt;Developing GUIs in C++ - I&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt;&lt;/td&gt;&lt;td class="textWithoutIndent" height="22" bgcolor="#ecf2fc"&gt;&lt;a linkindex="22" set="yes" href="http://www.kicit.com/freebies/vcpp/c++/Developing%20GUIs%20in%20C++%20-%20II.zip"&gt;Developing GUIs in C++ - II&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align="left"&gt;&lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5257452066282227428?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5257452066282227428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5257452066282227428' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5257452066282227428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5257452066282227428'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/c-projects.html' title='C++ Projects'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7551002603069175409</id><published>2008-09-15T05:31:00.000-07:00</published><updated>2008-12-22T21:29:32.548-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ADO'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>ActiveX Data Object</title><content type='html'>&lt;span style="color: rgb(204, 0, 0); font-weight: bold;font-family:Arial;font-size:85%;"&gt;&lt;a href="http://www.kicit.com/freebies/vcpp/Socket%20Programming/Multiple_Clients_Chat_Server.zip"&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;ADO&lt;br /&gt;&lt;table border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle" width="41" height="22" align="center"&gt;&lt;img border="0" width="9" src="http://www.kicit.com/images/bullet.gif" height="11" /&gt; &lt;/td&gt;                       &lt;td width="613" class="textWithoutIndent" height="22"&gt; &lt;a linkindex="7" set="yes" href="http://www.kicit.com/freebies/vcpp/ado/ado.zip"&gt;ActiveX Data Object&lt;/a&gt;&lt;/td&gt;                     &lt;/tr&gt;                     &lt;tr align="left"&gt;                       &lt;td valign="middle" colspan="2" class="blueHeading2" height="22"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style="text-align: -webkit-left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7551002603069175409?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7551002603069175409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7551002603069175409' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7551002603069175409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7551002603069175409'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/09/activex-data-object.html' title='ActiveX Data Object'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-9084556610958976133</id><published>2008-08-24T22:25:00.000-07:00</published><updated>2008-12-22T21:29:32.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Visual C#.Net  Code - Reflection</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/csharp_net_source_code/Reflection/Reflection.zip"&gt;click here to download project&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-9084556610958976133?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/9084556610958976133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=9084556610958976133' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/9084556610958976133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/9084556610958976133'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/visual-cnet-code-reflection.html' title='Visual C#.Net  Code - Reflection'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4213664223515800341</id><published>2008-08-24T22:08:00.001-07:00</published><updated>2008-12-22T21:29:32.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>VC++ Code - Printing text files</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/vcpp/Printing/Printing_a_text_file.zip"&gt;click here to download project&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4213664223515800341?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4213664223515800341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4213664223515800341' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4213664223515800341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4213664223515800341'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/vc-code-printing-text-files.html' title='VC++ Code - Printing text files'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-6092962142489527241</id><published>2008-08-24T22:07:00.001-07:00</published><updated>2008-12-22T21:29:32.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>VC++ code - Dlls - dynamic and static linking</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/vcpp/DLL/Implicit_Explici_tlinking.zip"&gt;click here to download project&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-6092962142489527241?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/6092962142489527241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=6092962142489527241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6092962142489527241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6092962142489527241'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/vc-code-dlls-dynamic-and-static-linking.html' title='VC++ code - Dlls - dynamic and static linking'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-361756915572246178</id><published>2008-08-24T22:06:00.001-07:00</published><updated>2008-12-22T21:29:32.550-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>VC++ Code - Extenstion Dll</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/vcpp/DLL/Extension%20DLL.zip"&gt;click here to download projct&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-361756915572246178?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/361756915572246178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=361756915572246178' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/361756915572246178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/361756915572246178'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/vc-code-extenstion-dll.html' title='VC++ Code - Extenstion Dll'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1864415872607344627</id><published>2008-08-24T22:05:00.000-07:00</published><updated>2008-12-22T21:29:32.550-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>VC++ Code - Regular Dll</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/vcpp/DLL/Regular%20DLL.zip"&gt;click here to download project&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1864415872607344627?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1864415872607344627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1864415872607344627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1864415872607344627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1864415872607344627'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/vc-code-regular-dll.html' title='VC++ Code - Regular Dll'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-905197235112142481</id><published>2008-08-24T22:03:00.000-07:00</published><updated>2008-12-22T21:29:32.551-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><category scheme='http://www.blogger.com/atom/ns#' term='VC++'/><title type='text'>Visual C++ Code - Chat Server using Socket programming</title><content type='html'>&lt;a href="http://www.kicit.com/freebies/vcpp/Socket%20Programming/Chat_Server_Through_Socket_Programming.zip"&gt;Click here to download project&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-905197235112142481?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/905197235112142481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=905197235112142481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/905197235112142481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/905197235112142481'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/visual-c-code-chat-server-using-socket.html' title='Visual C++ Code - Chat Server using Socket programming'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-163033155414623004</id><published>2008-08-05T00:25:00.002-07:00</published><updated>2008-12-22T21:29:32.551-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C source code for 2  Linked List Implementation Of Stack</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????¡ì??????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define TRUE 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;# define FALSE 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct stack_element {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int stack_data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;struct stack_element *next;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}stack_inf;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct stack_element_top{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stack_inf *stack_top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}stack;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;stack *create()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stack *s;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;s=(stack *)malloc(sizeof(stack));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;s-&gt;stack_top=NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return(s);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isempty (stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (s-&gt;stack_top == NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;return TRUE;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;return FALSE;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void push (stack *s,int x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stack_inf *p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p=(stack_inf *)malloc(sizeof(stack_inf));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p-&gt;stack_data=x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p-&gt;next=NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(isempty(s))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;s-&gt;stack_top=p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;p-&gt;next=s-&gt;stack_top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;s-&gt;stack_top=p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int pop(stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stack_inf *p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(isempty(s))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf(“\nStack is empty !\n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;p=s-&gt;stack_top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;x=p-&gt;stack_data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;s-&gt;stack_top=p-&gt;next;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;free(p);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(x);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-163033155414623004?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/163033155414623004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=163033155414623004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/163033155414623004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/163033155414623004'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-source-code-for-2-linked-list.html' title='C source code for 2  Linked List Implementation Of Stack'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5668778196096768365</id><published>2008-08-05T00:25:00.001-07:00</published><updated>2008-12-22T21:29:32.551-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C source code for An array implementation of the operations of a stack ADT </title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????¡ì??????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="margin-left: 157.5pt; text-align: justify; text-indent: -157.5pt;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define MAX&lt;span style=""&gt;  &lt;/span&gt;1000 /* only 1000 elements can be stored in the stack*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;# define TRUE 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;# define FALSE 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef int stack_data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;struct stack_inf{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;int top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;stack_data stack_elements[MAX];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct stack_inf stack;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;stack s;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void create(stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;s-&gt;top=-1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isempty (stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (s-&gt;top == -1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;return(TRUE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;return(FALSE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int&lt;span style=""&gt;  &lt;/span&gt;isfull (stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (s-&gt;top == (MAX -1))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;return(TRUE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;           &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;    &lt;/span&gt;return(FALSE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;stack_data pop (stack *s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int t;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stack_data ret; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if&lt;span style=""&gt;  &lt;/span&gt;(isempty(s)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf(“The stack is empty\n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;t = s-&gt;top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;ret=s-&gt;stack_elements[t];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;s-&gt;top - -;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return(ret);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void push (stack *s, stack_data x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (isfull(s))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;printf(“Stack is FULL ! No&lt;span style=""&gt;  &lt;/span&gt;insertion possible\n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;++s-&gt;top;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;s-&gt;stack_elements[s-&gt;top]=x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5668778196096768365?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5668778196096768365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5668778196096768365' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5668778196096768365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5668778196096768365'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-source-code-for-array-implementation.html' title='C source code for An array implementation of the operations of a stack ADT '/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5959907176504952120</id><published>2008-08-03T23:30:00.001-07:00</published><updated>2008-12-22T21:29:32.552-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for Implementation of queue using Linked Lists</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????¡ì??????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define TRUE 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define FALSE 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;struct queue_element{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;int data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;struct queue_element *next;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct queue_element queue_info;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct qpointer{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;queue_info *front, *rear;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;}queue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;queue *q;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;queue *create()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;queue *p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p=(queue *)malloc(sizeof(queue));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p-&gt;front=NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p-&gt;rear=NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return(p);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isempty(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(q-&gt;front == NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(TRUE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(FALSE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void insert_queue (queue *q,int item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;queue_info *new;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;new=(queue_info *) malloc (sizeof (queue_info));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;new-&gt;next = NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;new-&gt;data = item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (isempty(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;front = new;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;rear = new;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;rear-&gt;next=new;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;           &lt;/span&gt;q-&gt;rear=new;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int delete_queue(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int item;&lt;span style=""&gt;           &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;queue_info *del;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (isempty(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf(“Queue is empty ! \n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(-1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;del=q-&gt;front;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;front=q-&gt;front-&gt;next;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;item=del-&gt;data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;free (del);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(q-&gt;front == NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;q-&gt;rear=NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(item);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5959907176504952120?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5959907176504952120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5959907176504952120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5959907176504952120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5959907176504952120'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-source-code-for-implementation-of_03.html' title='C Source code for Implementation of queue using Linked Lists'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-8381763647999344851</id><published>2008-08-03T23:29:00.000-07:00</published><updated>2008-12-22T21:29:32.552-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for Implementation of queue using Stacks</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????¡ì??????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;# include &lt;stdio.h&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define MAX 5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define TRUE 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define FALSE 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;#define ERROR -1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;struct qinfo{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;int front,rear;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;int noele;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;int qelement[MAX];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;typedef struct qinfo queue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void create(),insert_queue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isfull(),isfull(),delete_queue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void create(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;q-&gt;front=-1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;q-&gt;rear=-1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;q-&gt;noele=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isempty(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(q-&gt;noele == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(TRUE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(FALSE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int isfull(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(q-&gt;noele == MAX)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(TRUE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(FALSE);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;void insert_queue(queue *q,int item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;char stop;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(isfull(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf("Queue is full \n");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(isempty(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;create(q);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;q-&gt;front++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;q-&gt;rear++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;if(q-&gt;rear &lt; (MAX - 1) || q-&gt;rear &lt; (q-&gt;front - 1))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;q-&gt;rear++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;if(q-&gt;rear == (MAX - 1) &amp;amp;&amp;amp; q-&gt;noele &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                            &lt;/span&gt;q-&gt;rear=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;qelement[q-&gt;rear]=item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;noele++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 150%;"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;int delete_queue(queue *q)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if(isempty(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf("Queue is empty!!!\n");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(ERROR);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;data=q-&gt;qelement[q-&gt;front];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(q-&gt;front == (MAX - 1))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;q-&gt;front=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;q-&gt;front++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;q-&gt;noele--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(isempty(q))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;create(q);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return(data);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Century Schoolbook&amp;quot;;" lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-8381763647999344851?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/8381763647999344851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=8381763647999344851' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8381763647999344851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8381763647999344851'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-source-code-for-implementation-of.html' title='C Source code for Implementation of queue using Stacks'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-8929991108643986629</id><published>2008-08-02T20:31:00.000-07:00</published><updated>2008-12-22T21:29:32.552-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Code for Removing duplicate nodes from linked list</title><content type='html'>void RemoveDuplicates ( NODE**head)  {&lt;br /&gt;&lt;br /&gt;         NODE *pCurrent = *head;&lt;br /&gt;        &lt;br /&gt;         if(pCurrent ==NULL)&lt;br /&gt;            return;&lt;br /&gt;        else {&lt;br /&gt;           while(pCurrent -&gt;next !=NULL) {&lt;br /&gt;&lt;br /&gt;              if(pCurrent -&gt;data == pCurrent -&gt;next-&gt;data) {&lt;br /&gt;           &lt;br /&gt;                  NODE *nnext = pCurrent -&gt;next-&gt;next;&lt;br /&gt;                  free(pCurrent -&gt;next);&lt;br /&gt;                  pCurrent -&gt;next = nnext;&lt;br /&gt;               }&lt;br /&gt;              else&lt;br /&gt;                 pCurrent =pCurrent -&gt;next;&lt;br /&gt;          }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-8929991108643986629?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/8929991108643986629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=8929991108643986629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8929991108643986629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8929991108643986629'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-code-for-removing-duplicate-nodes.html' title='C Code for Removing duplicate nodes from linked list'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-2211730736166586658</id><published>2008-08-02T20:28:00.000-07:00</published><updated>2008-12-22T21:29:32.553-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Mirror Image Tree'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Code for Mirror Image Tree</title><content type='html'>void mirror(struct node* node) {&lt;br /&gt;  &lt;br /&gt;       if (node==NULL) {&lt;br /&gt;&lt;br /&gt;         return;&lt;br /&gt;           }&lt;br /&gt;     else { &lt;br /&gt;     &lt;br /&gt;        struct node* temp;  // do the subtrees&lt;br /&gt;        mirror(node-&gt;left);  mirror(node-&gt;right);  // swap the pointers in this node&lt;br /&gt;        temp = node-&gt;left;&lt;br /&gt;       node-&gt;left = node-&gt;right;&lt;br /&gt;       node-&gt;right = temp;&lt;br /&gt;        }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-2211730736166586658?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/2211730736166586658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=2211730736166586658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2211730736166586658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2211730736166586658'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/08/c-code-for-mirror-image-tree.html' title='C Code for Mirror Image Tree'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1708460205667700572</id><published>2008-07-31T22:15:00.000-07:00</published><updated>2008-12-22T21:29:32.553-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Heap Sort'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Code for Heapsort algorithm</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????????¡ì????????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????????¡ì????????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="margin-top: 6pt;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;heapsort(x,n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;int x[],n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int i,data,s,f,ivalue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;/* create initial heap */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;for(i=1;i &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;data=x[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;/* insert_heap (x,i,data); */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;s=i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;f=(s - 1) / 2; /* f is the father of s */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;while(s &gt; 0 &amp;amp;&amp;amp; x[f] &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;x[s]=x[f]; /* move up the tree */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;s=f;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;f=(s - 1) / 2; /* f is the father of s */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}/* end while */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;x[s]=data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}/* end for i.e. a heap has been created */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 40.5pt; text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;/* begin repeatedly removing the maximum element i.e. x[0], */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;           &lt;/span&gt;/*&lt;span style=""&gt;  &lt;/span&gt;place it at the end of the array.*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;/* Convert the remaining part to a heap */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;for(i=n - 1; i &gt; 0;i--)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;/* delete the root */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;ivalue=x[i]; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;x[i]=x[0]; /* the root is placed at the bottom */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;f=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1in; text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;/* begin adjusting the heap by pushing the element x[i] i.e. ivalue */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(i == 1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;s=-1;/* no further processing required */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;s=1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if(i &gt; 2 &amp;amp;&amp;amp; x[2] &gt; x[1])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;s=2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;while(s &gt;=0 &amp;amp;&amp;amp; ivalue &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;/* push ivalue down the heap */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;x[f]=x[s];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;f=s;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;/* s=largeson(f, i-1) */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;s=2*f +1; /* s is the child of f */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;if(s+1 &lt;= i-1 &amp;amp;&amp;amp; x[s] &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 157.5pt;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;s=s+1; /* select the larger of the two children of f i.e. 2j + 1 or 2j + 2 */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 157.5pt;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;if(s &gt; i-1) /* when bounds have been reached &lt;span style=""&gt;                                   &lt;/span&gt;*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;s=-1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}/* end while */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;/* insert ivalue at fth location */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;x[f]=ivalue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}/* end for */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;}/* end heap sort */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1708460205667700572?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1708460205667700572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1708460205667700572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1708460205667700572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1708460205667700572'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-code-for-heapsort-algorithm.html' title='C Code for Heapsort algorithm'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-8501665358995863079</id><published>2008-07-31T22:06:00.001-07:00</published><updated>2008-12-22T21:29:32.553-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Quick Sort'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C code for NONRECURSIVE IMPLEMENTATION OF QUICKSORT</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????????¡ì????????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;# define STACKSIZE 50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;void quicksort(int x[], int n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int i,j;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;struct stack_info{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;int l;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;int u;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;}bounds;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;struct stack_tag{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;int stacktop;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;struct stack_info limits[STACKSIZE];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}STACK;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;STACK.stacktop=-1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;bounds.l=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;bounds.u=n - 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;push(&amp;amp;STACK,&amp;amp;bounds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;while(!empty(&amp;amp;STACK))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;pop(&amp;amp;STACK,&amp;amp;bounds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;while(bounds.u &gt; bounds.l)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;partition(x,bounds.l,bounds.u,&amp;amp;j);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;if((j - bounds.l) &gt; (bounds.u - j))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;i=bounds.u;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.u=j - 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;push(&amp;amp;STACK,&amp;amp;bounds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.l=j + 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.u=i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;i=bounds.l;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.l=j + 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;push(&amp;amp;STACK,&amp;amp;bounds);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.l=i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                                &lt;/span&gt;bounds.u=j - 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;} /* end if */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;} /* end while */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}/* end while */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;} /* end quicksort */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;int emtpy (struct stack_tag * stackptr)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if( stackptr-&gt;stack.top == -1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return (1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;return (0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;} /* end empty*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 81pt; text-align: justify; text-indent: -81pt;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;void pop (struct stack_tag * stackptr,&lt;span style=""&gt;  &lt;/span&gt;struct stack_info * data)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if empty (stackptr)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;printf (“%s\n”, “stack underflow”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;data=&amp;amp;(stackptr-&gt; limits [stackptr-&gt;stacktop]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;-- (stackptr-&gt;stacktop);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;void push (struct stack_tag * stackptr, struct stack_info *data)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;span style=""&gt;          &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;p=++(stackptr-&gt;stacktop);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stackptr-&gt;limits[p].l = data-&gt;l;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;stackptr-&gt;limits [p].u = data-&gt;u;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;} /*end push.; note no checking for stack overflow */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-8501665358995863079?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/8501665358995863079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=8501665358995863079' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8501665358995863079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/8501665358995863079'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-code-for-nonrecursive-implementation.html' title='C code for NONRECURSIVE IMPLEMENTATION OF QUICKSORT'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1803232717136271075</id><published>2008-07-31T22:05:00.000-07:00</published><updated>2008-12-22T21:29:32.554-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Recursive'/><category scheme='http://www.blogger.com/atom/ns#' term='Quick Sort'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C code for A recursive implementation of the quicksort algorithm.</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:???????????????¡ì????????; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Century Schoolbook"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:3 0 0 0 1 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	mso-layout-grid-align:none; 	punctuation-wrap:simple; 	text-autospace:none; 	font-size:12.0pt; 	mso-bidi-font-size:10.0pt; 	font-family:Arial; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;void quicksort(int x[], int l, int u)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int * j; int k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;if (l &gt; =u) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;         &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;partition (x, l,u,&amp;amp;j);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;quicksort (x, l, j -1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                    &lt;/span&gt;quicksort (x, j+1, u);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;         &lt;/span&gt;&lt;span style=""&gt;               &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;}&lt;/span&gt;&lt;/i&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;void partition (int x [], int l, int u,int *j)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;int k, m,n, i, temp, int * j;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;k = x [l];&lt;span style=""&gt;                    &lt;/span&gt;/* k is the element whose final */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;         &lt;/span&gt;n = u;&lt;span style=""&gt;                            &lt;/span&gt;/* position is required */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;         &lt;/span&gt;m =l;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;         &lt;/span&gt;while (m &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;while (x[m] &lt;= k &amp;amp;&amp;amp; m &lt;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;m++ ;&lt;span style=""&gt;                    &lt;/span&gt;/* move the lower index up */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style=""&gt;       &lt;/span&gt;while (x[n] &gt; k)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;n --;&lt;span style=""&gt;                       &lt;/span&gt;/* reduce the upper index */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;if (m &lt;n)&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/n)&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;                       &lt;/span&gt;{&lt;span style=""&gt;          &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;/*interchange x[m] &amp;amp; x[n] */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;temp=x[m];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;x[m]=x[n];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                                    &lt;/span&gt;x[n]=temp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;                        &lt;/span&gt;}&lt;span style=""&gt;          &lt;/span&gt;/* end if */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;} * end while */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;x[l]= x[n];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;x[n]=k;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;* j = n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;&lt;span style=""&gt;            &lt;/span&gt;return;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;i style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:13;"   lang="EN-GB"&gt;} &lt;span style=""&gt;                      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1803232717136271075?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1803232717136271075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1803232717136271075' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1803232717136271075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1803232717136271075'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-code-for-recursive-implementation-of.html' title='C code for A recursive implementation of the quicksort algorithm.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-3836591555552589892</id><published>2008-07-30T01:11:00.000-07:00</published><updated>2008-12-22T21:29:32.554-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STL'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C++ Source code for using STL unary_functions.</title><content type='html'>#include "stdafx.h"&lt;br /&gt;&lt;br /&gt;#include &lt;string&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;functional&gt;&lt;br /&gt;#include &lt;algorithm&gt; // for remove_if&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;#include &lt;limits&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;template &lt;class&gt;&lt;br /&gt;class is_vowel : public unary_function&lt;string,bool&gt; {&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;   bool operator ()(T t) const&lt;br /&gt;   {&lt;br /&gt;   if ((t=='a')||(t=='e')||(t=='i')||(t=='o')||(t=='u'))&lt;br /&gt;   return true; //t is a vowel&lt;br /&gt;   return false; // t is not a vowel&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;bool greaterthan(int x) {&lt;br /&gt;&lt;br /&gt;   return x&gt;6;&lt;br /&gt;}&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;string original;&lt;br /&gt;cout &lt;&lt; "Type string to remove vowels." &lt;&lt;&gt;&gt; original;&lt;br /&gt;//…&lt;br /&gt;&lt;br /&gt;string::iterator it= remove_if(original.begin(),&lt;br /&gt;                               original.end(),&lt;br /&gt;                               is_vowel&lt;char&gt;());&lt;br /&gt;&lt;br /&gt;// create new string from original using previous iterator&lt;br /&gt;string no_vowels(original.begin(),it);&lt;br /&gt;cout &lt;&lt;endl&gt;&lt;&lt;&gt;&lt;&lt; "Remove all numbers greater than 6" &lt;&lt;endl; vector=""&gt;&lt;int&gt; v1;&lt;br /&gt;v1.push_back(7);&lt;br /&gt;v1.push_back(1);&lt;br /&gt;v1.push_back(9);&lt;br /&gt;v1.push_back(2);&lt;br /&gt;v1.push_back(0);&lt;br /&gt;v1.push_back(7);&lt;br /&gt;v1.push_back(7);&lt;br /&gt;v1.push_back(3);&lt;br /&gt;v1.push_back(4);&lt;br /&gt;v1.push_back(6);&lt;br /&gt;v1.push_back(8);&lt;br /&gt;v1.push_back(5);&lt;br /&gt;v1.push_back(7);&lt;br /&gt;v1.push_back(7);&lt;br /&gt;&lt;br /&gt;for(vector&lt;int&gt;::iterator itr_prn = v1.begin() ;itr_prn!= v1.end(); itr_prn++)&lt;br /&gt;    cout&lt;&lt;" "&lt;&lt; *itr_prn ;  cout &lt;&lt;endl; vector=""&gt;&lt;int&gt;::iterator itre = remove_if(v1.begin(),v1.end(),greaterthan);&lt;br /&gt;vector&lt;int&gt;::iterator itrb = v1.begin();&lt;br /&gt;&lt;br /&gt;for(;itrb != itre; itrb++)&lt;br /&gt;    cout &lt;&lt; " " &lt;&lt; *itrb;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/int&gt;&lt;/int&gt;&lt;/endl;&gt;&lt;/int&gt;&lt;/int&gt;&lt;/endl;&gt;&lt;/endl&gt;&lt;/endl&gt;&lt;/char&gt;&lt;/string,bool&gt;&lt;/class&gt;&lt;/limits&gt;&lt;/vector&gt;&lt;/algorithm&gt;&lt;/functional&gt;&lt;/iostream&gt;&lt;/string&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-3836591555552589892?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/3836591555552589892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=3836591555552589892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3836591555552589892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3836591555552589892'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-using-stl.html' title='C++ Source code for using STL unary_functions.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-6095648095592422614</id><published>2008-07-30T00:57:00.001-07:00</published><updated>2008-12-22T21:29:32.555-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for reversing a singly linked list.</title><content type='html'>void reverse(node **head) {&lt;br /&gt;&lt;br /&gt;   node *current = *head;&lt;br /&gt;   node *result = 0;&lt;br /&gt;   node *next;&lt;br /&gt;   while (current != 0) {&lt;br /&gt;&lt;br /&gt;           next = current-&gt;next;&lt;br /&gt;           current-&gt;next = result;&lt;br /&gt;           result = current;&lt;br /&gt;&lt;br /&gt;           current = next;&lt;br /&gt;       }&lt;br /&gt;   *head = result;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-6095648095592422614?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/6095648095592422614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=6095648095592422614' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6095648095592422614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/6095648095592422614'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-reversing-singly.html' title='C Source code for reversing a singly linked list.'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-2396958236889947386</id><published>2008-07-30T00:40:00.000-07:00</published><updated>2008-12-22T21:29:32.555-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for checking if a number is power of 2</title><content type='html'>void root( int &amp;amp; nn) {&lt;br /&gt;nn = nn/2;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int PowerOf2() {&lt;br /&gt;&lt;br /&gt;int n ;&lt;br /&gt;char ch='q';&lt;br /&gt;&lt;br /&gt;do  {&lt;br /&gt;&lt;br /&gt; printf("\nEnter No: ");&lt;br /&gt; scanf("%d",&amp;amp;n);&lt;br /&gt; if((n &amp;amp; n-1) == 0) {&lt;br /&gt;&lt;br /&gt;  int temp =n;&lt;br /&gt;  while(temp &gt;0 &amp;amp;&amp;amp; temp%2 ==0 ) {&lt;br /&gt;  &lt;br /&gt;   printf(" %d *", temp);&lt;br /&gt;    root(temp);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;&lt;br /&gt;  printf("\n No is not a power of 2.");&lt;br /&gt; }&lt;br /&gt; printf("\nDo you want to continue.... :");&lt;br /&gt;    scanf("%c", &amp;amp;ch);&lt;br /&gt;}while(ch!='q');&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-2396958236889947386?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/2396958236889947386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=2396958236889947386' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2396958236889947386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/2396958236889947386'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-checking-if-number-is.html' title='C Source code for checking if a number is power of 2'/><author><name>Siebel Expert</name><uri>http://www.blogger.com/profile/11533458660230230361</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1945983441360922775</id><published>2008-07-28T22:00:00.001-07:00</published><updated>2008-12-22T21:29:32.555-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C source code for converting an integer to binary.</title><content type='html'>char *int2bin(int a)&lt;br /&gt;{&lt;br /&gt; char *str,*tmp;&lt;br /&gt; int cnt = 31;&lt;br /&gt; str = (char *) malloc(33); /*32 + 1 , becoz its a 32 bit bin number*/&lt;br /&gt; tmp = str;&lt;br /&gt; while ( cnt &gt; -1 ){&lt;br /&gt;      str[cnt]= '0';&lt;br /&gt;      cnt --;&lt;br /&gt; }&lt;br /&gt; cnt = 31; printf("\n");&lt;br /&gt; while (a &gt; 0){&lt;br /&gt;   &lt;br /&gt;       if (a%2==1){&lt;br /&gt;           str[cnt] = '1';&lt;br /&gt;           printf(" 1");&lt;br /&gt;        }&lt;br /&gt;       else&lt;br /&gt;           printf(" 0");&lt;br /&gt;      cnt--;&lt;br /&gt;        a = a/2 ;&lt;br /&gt; }&lt;br /&gt; return tmp;  &lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1945983441360922775?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1945983441360922775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1945983441360922775' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1945983441360922775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1945983441360922775'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-converting-integer-to.html' title='C source code for converting an integer to binary.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7405343384035394279</id><published>2008-07-28T21:59:00.000-07:00</published><updated>2008-12-22T21:29:32.556-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Macro for verifying MSB</title><content type='html'>#define zero_most_significant(h) \&lt;br /&gt;(h&amp;amp;=(h&gt;&gt;1)|(h&gt;&gt;2), \&lt;br /&gt;h|=(h&gt;&gt;2), \&lt;br /&gt;h|=(h&gt;&gt;4), \&lt;br /&gt;h|=(h&gt;&gt;8), \&lt;br /&gt;h|=(h&gt;&gt;16))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7405343384035394279?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7405343384035394279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7405343384035394279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7405343384035394279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7405343384035394279'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-macro-for-verifying-msb.html' title='C Macro for verifying MSB'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-3154091706490576199</id><published>2008-07-28T21:56:00.000-07:00</published><updated>2008-12-22T21:29:32.556-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Macro Source Code for verifying if a number is power of two.</title><content type='html'>#define power_of_two(x) ((x)&amp;amp;&amp;amp;(~(x&amp;amp;(x-1))))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-3154091706490576199?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/3154091706490576199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=3154091706490576199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3154091706490576199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3154091706490576199'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-macro-source-code-for-verifying-if.html' title='C Macro Source Code for verifying if a number is power of two.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1598350794313128516</id><published>2008-07-28T05:23:00.001-07:00</published><updated>2008-12-22T21:29:32.556-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for palindrome problem.</title><content type='html'>struct ppair {&lt;br /&gt;  char c;&lt;br /&gt;  int first;&lt;br /&gt;  int last;&lt;br /&gt;  int num_inner_pairs;&lt;br /&gt;  ppair ** inner_pairs;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void add_to_inner( ppair * outer,  ppair * inner) {&lt;br /&gt;&lt;br /&gt;  ppair ** temp;&lt;br /&gt;  int i;&lt;br /&gt;&lt;br /&gt;  temp = ( ppair * *)malloc((outer-&gt;num_inner_pairs + 1) * sizeof( ppair *));&lt;br /&gt;  for(i = 0; i &lt;&gt;num_inner_pairs; i++) {&lt;br /&gt;    temp[i] = outer-&gt;inner_pairs[i];&lt;br /&gt;  }&lt;br /&gt;  if (outer-&gt;num_inner_pairs &gt; 0) {&lt;br /&gt;    free(outer-&gt;inner_pairs);&lt;br /&gt;  }&lt;br /&gt;  temp[outer-&gt;num_inner_pairs++] = inner;&lt;br /&gt;  outer-&gt;inner_pairs = temp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void print_palendromes(const  ppair * p, char * pre) {&lt;br /&gt;  int i;&lt;br /&gt;&lt;br /&gt;  printf("%s", pre); putc(p-&gt;c, stdout);&lt;br /&gt;  if (p-&gt;first &lt;&gt;last) {&lt;br /&gt;    putc(p-&gt;c, stdout);&lt;br /&gt;  }&lt;br /&gt;  for(i = strlen(pre); i &gt; 0; i--) putc(pre[i-1], stdout);&lt;br /&gt;  printf("\n");&lt;br /&gt;&lt;br /&gt;  pre[strlen(pre)] = p-&gt;c;&lt;br /&gt;  for(i = 0; i &lt;&gt;num_inner_pairs; i++) {&lt;br /&gt;    print_palendromes(p-&gt;inner_pairs[i], pre);&lt;br /&gt;  }&lt;br /&gt;  pre[strlen(pre) - 1] = 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int pallindrome(int argc, const char ** argv) {&lt;br /&gt;  int i, j, k;&lt;br /&gt;  ppair g, * p;&lt;br /&gt;  char * buf;&lt;br /&gt;&lt;br /&gt;  if (argc != 2) {&lt;br /&gt;    fprintf(stderr, "usage: %s string\n", argv[0]);&lt;br /&gt;    return -1;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  g.first = -1;&lt;br /&gt;  g.last = strlen(argv[1]);&lt;br /&gt;  g.num_inner_pairs = 0;&lt;br /&gt;&lt;br /&gt;  for(i = 0; i &lt; strlen(argv[1]); i++) {&lt;br /&gt;    for(j = i; j &lt; strlen(argv[1]); j++) {&lt;br /&gt;      if (argv[1][i] == argv[1][j]) {&lt;br /&gt;         ppair * p = ( ppair *)malloc(sizeof( ppair));&lt;br /&gt;        p-&gt;c = argv[1][i];&lt;br /&gt;        p-&gt;first = i;&lt;br /&gt;        p-&gt;last = j;&lt;br /&gt;        p-&gt;num_inner_pairs = 0;&lt;br /&gt;        for(k = 0; k &lt; g.num_inner_pairs; k++) {&lt;br /&gt;          if (g.inner_pairs[k]-&gt;first &lt;&gt;last) {&lt;br /&gt;            add_to_inner(g.inner_pairs[k], p);&lt;br /&gt;          }&lt;br /&gt;        }&lt;br /&gt;        add_to_inner(&amp;amp;g, p);&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  buf = (char *)malloc(strlen(argv[1]) + 1);&lt;br /&gt;  memset(buf, 0, strlen(argv[1]) + 1);&lt;br /&gt;&lt;br /&gt;  for(k = 0; k &lt; g.num_inner_pairs; k++) {&lt;br /&gt;    if (g.inner_pairs[k]-&gt;first &lt;&gt;last) {&lt;br /&gt;      print_palendromes(g.inner_pairs[k], buf);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for(k = 0; k &lt; g.num_inner_pairs; k++) {&lt;br /&gt;    if (g.inner_pairs[k]-&gt;num_inner_pairs &gt; 0) {&lt;br /&gt;      free(g.inner_pairs[k]-&gt;inner_pairs);&lt;br /&gt;    }&lt;br /&gt;    free(g.inner_pairs[k]);&lt;br /&gt;  }&lt;br /&gt;  free(g.inner_pairs);&lt;br /&gt;  free(buf);&lt;br /&gt;&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1598350794313128516?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1598350794313128516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1598350794313128516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1598350794313128516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1598350794313128516'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-palindrome-problem.html' title='C Source code for palindrome problem.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-7581788651524019954</id><published>2008-07-28T05:22:00.001-07:00</published><updated>2008-12-22T21:29:32.557-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for multiplying two numbers without using multiplication operator.</title><content type='html'>int multiply( int num, int num1) {&lt;br /&gt;  &lt;br /&gt;      num = (num &lt;&lt; 3) - num;&lt;br /&gt;     return num;&lt;br /&gt;   }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-7581788651524019954?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/7581788651524019954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=7581788651524019954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7581788651524019954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/7581788651524019954'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-multiplying-two.html' title='C Source code for multiplying two numbers without using multiplication operator.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-5526456352384005160</id><published>2008-07-28T05:21:00.001-07:00</published><updated>2008-12-22T21:29:32.557-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for counting 1's in a number.</title><content type='html'>int bitcount (unsigned int n) &lt;br /&gt;   {&lt;br /&gt;      int count=0;&lt;br /&gt;      int counter =0;&lt;br /&gt;      while (n)&lt;br /&gt;      {&lt;br /&gt;         count += n &amp;amp; 0x1u ;&lt;br /&gt;         n &gt;&gt;= 1 ;&lt;br /&gt;         counter++;&lt;br /&gt;      }&lt;br /&gt;      return count ;&lt;br /&gt;   }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-5526456352384005160?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/5526456352384005160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=5526456352384005160' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5526456352384005160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/5526456352384005160'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-counting-1s-in-number.html' title='C Source code for counting 1&apos;s in a number.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-741236793216925001</id><published>2008-07-28T05:18:00.000-07:00</published><updated>2008-12-22T21:29:32.557-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for converting from Integer to String - itoa implementation.</title><content type='html'>void IntToStr( int num) {&lt;br /&gt;&lt;br /&gt;    bool bNegative =false;&lt;br /&gt;    if( num &lt; 0)&lt;br /&gt;        bNegative =true;&lt;br /&gt;    char * str = new char[11];&lt;br /&gt;    int i =0;&lt;br /&gt;    while( num != 0) {&lt;br /&gt;   &lt;br /&gt;        str[i++] = num % 10 + '0';&lt;br /&gt;        num /=10;&lt;br /&gt;    }&lt;br /&gt;    i--; int j =0;&lt;br /&gt;    while( j &lt;i) {&lt;br /&gt;       &lt;br /&gt;        char ch = str[j];&lt;br /&gt;        str[j] = str[i];&lt;br /&gt;        str[i] = ch;&lt;br /&gt;        j++; i--;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-741236793216925001?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/741236793216925001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=741236793216925001' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/741236793216925001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/741236793216925001'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-converting-from.html' title='C Source code for converting from Integer to String - itoa implementation.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4424170476492679593</id><published>2008-07-28T05:17:00.000-07:00</published><updated>2008-12-22T21:29:32.558-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source Code for reversing a string.</title><content type='html'>void ReverseString( char str[]) {&lt;br /&gt;&lt;br /&gt;    int start =0 ;int end = strlen(str)-1;&lt;br /&gt;    while(start &lt; end) {&lt;br /&gt;       &lt;br /&gt;        char ch = str[start];&lt;br /&gt;        str[start] = str[end];&lt;br /&gt;        str[end] = ch;&lt;br /&gt;       &lt;br /&gt;        start++; end--;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4424170476492679593?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4424170476492679593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4424170476492679593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4424170476492679593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4424170476492679593'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-reversing-string.html' title='C Source Code for reversing a string.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-4314764210069092881</id><published>2008-07-28T05:16:00.000-07:00</published><updated>2008-12-22T21:29:32.558-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for Converting from string to integer - atoi implementation</title><content type='html'>int StrToInt( char str[])  {&lt;br /&gt;&lt;br /&gt;   bool bFlagNeative =false;&lt;br /&gt;   if( str[0] == '-') {&lt;br /&gt; &lt;br /&gt;       bFlagNeative =true;&lt;br /&gt;   }&lt;br /&gt;   int i=0;&lt;br /&gt;   int num =0;&lt;br /&gt;   while(str[i] != '\0') {&lt;br /&gt; &lt;br /&gt;       num *=10;&lt;br /&gt;       num+= (str[i++] - '0');&lt;br /&gt;   }&lt;br /&gt;   if(bFlagNeative)&lt;br /&gt;       num *= -1;&lt;br /&gt;   return num;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-4314764210069092881?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/4314764210069092881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=4314764210069092881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4314764210069092881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/4314764210069092881'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-converting-from_28.html' title='C Source code for Converting from string to integer - atoi implementation'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-3758430788231196504</id><published>2008-07-28T05:15:00.000-07:00</published><updated>2008-12-22T21:29:32.558-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>C Source code for reversing words in a string.</title><content type='html'>bool reverseWords( char str[] ){&lt;br /&gt;    char *buffer;&lt;br /&gt;    int tokenReadPos, wordReadPos, wordEnd, writePos = 0;&lt;br /&gt;&lt;br /&gt;    /* Position of the last character is length - 1 */&lt;br /&gt;    tokenReadPos = strlen(str) - 1;&lt;br /&gt;&lt;br /&gt;    buffer = (char *) malloc(tokenReadPos + 2);&lt;br /&gt;    if( !buffer )&lt;br /&gt;        return false; /* reverseWords failed */&lt;br /&gt;&lt;br /&gt;    while( tokenReadPos &gt;= 0 ){&lt;br /&gt;&lt;br /&gt;        if( str[tokenReadPos] == ' ' ){ /* Non-word characters */&lt;br /&gt;            /* Write character */&lt;br /&gt;            buffer[writePos++] = str[tokenReadPos--];&lt;br /&gt;&lt;br /&gt;        } else {  /* Word characters */&lt;br /&gt;            /* Store position of end of word */&lt;br /&gt;            wordEnd = tokenReadPos;&lt;br /&gt;&lt;br /&gt;            /* Scan to next non-word character */&lt;br /&gt;            while( tokenReadPos &gt;= 0 &amp;amp;&amp;amp; str[tokenReadPos] != ' ' )&lt;br /&gt;                tokenReadPos--;&lt;br /&gt;&lt;br /&gt;            /* tokenReadPos went past the start of the word */&lt;br /&gt;            wordReadPos = tokenReadPos + 1;&lt;br /&gt;&lt;br /&gt;           /* Copy the characters of the word */&lt;br /&gt;           while( wordReadPos &lt;= wordEnd ){&lt;br /&gt;               buffer[writePos++] = str[wordReadPos++];&lt;br /&gt;           }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    /* null terminate buffer and copy over str */&lt;br /&gt;    buffer[writePos] = '\0';&lt;br /&gt;    strcpy(str, buffer);&lt;br /&gt;&lt;br /&gt;    free(buffer);&lt;br /&gt;&lt;br /&gt;    return true; /* ReverseWords successful */&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-3758430788231196504?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/3758430788231196504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=3758430788231196504' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3758430788231196504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/3758430788231196504'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/c-source-code-for-reversing-words-in.html' title='C Source code for reversing words in a string.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-315839245763730934</id><published>2008-07-28T05:13:00.001-07:00</published><updated>2008-12-22T21:29:32.559-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='VB'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Basic'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Visual Basic Source code for AES Algorithm</title><content type='html'>Private Const BlkLenMax = 32        ' maximum block length in bytes&lt;br /&gt;Private Const KeyLenMax = 32        ' maximum block length in bytes&lt;br /&gt;Private Const KeySchLenMax = 128    ' maximum key schedule length in bytes&lt;br /&gt;Private BlkLen As Integer           ' actual block length&lt;br /&gt;Private KeyLen As Integer           ' actual key length&lt;br /&gt;&lt;br /&gt;Private Type AESctx     ' Type to hold the AES context data&lt;br /&gt;  Ekey(0 To KeySchLenMax - 1) As Long&lt;br /&gt;  Nrnd As Long&lt;br /&gt;  Ncol As Long&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Private Type KeyBlk     ' Type to hold user key data&lt;br /&gt; K(0 To KeyLenMax - 1) As Byte&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Private Type IoBlk      ' Type to hold cipher input and output blocks&lt;br /&gt; IO(0 To BlkLenMax - 1) As Byte&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Rem Change "d:\dll_pth" in the following lines to the directory path where the AES DLL is located&lt;br /&gt;Private Declare Function AesBlkLen Lib "d:\dll_path\aes.dll" Alias "_aes_blk_len@8" (ByVal N As Long, C As AESctx) As Integer&lt;br /&gt;Private Declare Function AesEncKey Lib "d:\dll_path\aes.dll" Alias "_aes_enc_key@12" (K As KeyBlk, ByVal N As Long, C As AESctx) As Integer&lt;br /&gt;Private Declare Function AesDecKey Lib "d:\dll_path\aes.dll" Alias "_aes_dec_key@12" (K As KeyBlk, ByVal N As Long, C As AESctx) As Integer&lt;br /&gt;Private Declare Function AesEncBlk Lib "d:\dll_path\aes.dll" Alias "_aes_enc_blk@12" (Ib As IoBlk, Ob As IoBlk, C As AESctx) As Integer&lt;br /&gt;Private Declare Function AesDecBlk Lib "d:\dll_path\aes.dll" Alias "_aes_dec_blk@12" (Ib As IoBlk, Ob As IoBlk, C As AESctx) As Integer&lt;br /&gt;&lt;br /&gt;Private Sub Hex(X As Byte)  ' Output a byte in hexadecimal format&lt;br /&gt;Dim H As Byte&lt;br /&gt;H = Int(X / 16)&lt;br /&gt;If H &lt; 10 Then&lt;br /&gt;    Debug.Print Chr(48 + H);&lt;br /&gt;Else&lt;br /&gt;    Debug.Print Chr(87 + H);&lt;br /&gt;End If&lt;br /&gt;H = Int(X Mod 16)&lt;br /&gt;If H &lt; 10 Then&lt;br /&gt;    Debug.Print Chr(48 + H);&lt;br /&gt;Else&lt;br /&gt;    Debug.Print Chr(87 + H);&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub OutKey(S As String, B As KeyBlk)    ' Display a key value&lt;br /&gt;Debug.Print: Debug.Print S;&lt;br /&gt;For i = 0 To KeyLen - 1&lt;br /&gt;   Hex B.K(i)&lt;br /&gt;Next i&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub OutBlock(S As String, B As IoBlk)   ' Display an input/output block&lt;br /&gt;Debug.Print: Debug.Print S;&lt;br /&gt;For i = 0 To BlkLen - 1&lt;br /&gt;   Hex B.IO(i)&lt;br /&gt;Next i&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Rem The following Main routine should output the following in the immediate window:&lt;br /&gt;Rem Key =            00000000000000000000000000000000&lt;br /&gt;Rem Input =          00000000000000000000000000000000&lt;br /&gt;Rem Encrypted Text = 66e94bd4ef8a2c3b884cfa59ca342b2e&lt;br /&gt;Rem Decrypted Text = 00000000000000000000000000000000&lt;br /&gt;&lt;br /&gt;Sub Main()&lt;br /&gt;Dim Key As KeyBlk   ' These variables are automatically&lt;br /&gt;Dim Ib As IoBlk, Ob As IoBlk, Rb As IoBlk&lt;br /&gt;Dim Cx As AESctx    ' initialised to zero values in VBA&lt;br /&gt;Dim RetVal As Integer&lt;br /&gt;&lt;br /&gt;BlkLen = 16: KeyLen = 16&lt;br /&gt;&lt;br /&gt;Rem RetVal = AesBlkLen(BlkLen, Cx)          ' include if the cipher block size is variable&lt;br /&gt;&lt;br /&gt;OutKey "Key =            ", Key&lt;br /&gt;OutBlock "Input =          ", Ib&lt;br /&gt;&lt;br /&gt;RetVal = AesEncKey(Key, KeyLen, Cx)     ' set an all zero encryption key&lt;br /&gt;RetVal = AesEncBlk(Ib, Ob, Cx)          ' encrypt Ib to Ob&lt;br /&gt;OutBlock "Encrypted Text = ", Ob&lt;br /&gt;&lt;br /&gt;RetVal = AesDecKey(Key, KeyLen, Cx)     ' set an all zero decryption key&lt;br /&gt;RetVal = AesDecBlk(Ob, Rb, Cx)          ' decrypt Ob to Rb&lt;br /&gt;OutBlock "Decrypted Text = ", Rb&lt;br /&gt;Debug.Print&lt;br /&gt;&lt;br /&gt;End Sub&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-315839245763730934?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/315839245763730934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=315839245763730934' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/315839245763730934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/315839245763730934'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/visual-basic-source-code-for-aes.html' title='Visual Basic Source code for AES Algorithm'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-722618417950535887.post-1386301126479194265</id><published>2008-07-28T05:10:00.000-07:00</published><updated>2008-12-22T21:29:32.559-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VB'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Basic'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='Source Code'/><title type='text'>Visual Basic for Applications code to illustrate the use of the AES Dynamic Link Library.</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:documentproperties&gt;   &lt;o:author&gt;support&lt;/o:Author&gt;   &lt;o:version&gt;11.9999&lt;/o:Version&gt;  &lt;/o:DocumentProperties&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:usefelayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:SimSun; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:??¡§??; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;} @font-face 	{font-family:"Lucida Console"; 	panose-1:2 11 6 9 4 5 4 2 2 4; 	mso-font-charset:0; 	mso-generic-font-family:modern; 	mso-font-pitch:fixed; 	mso-font-signature:-2147482993 6144 0 0 31 0;} @font-face 	{font-family:"\@SimSun"; 	panose-1:2 1 6 0 3 1 1 1 1 1; 	mso-font-alt:"\@Arial Unicode MS"; 	mso-font-charset:134; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:3 135135232 16 0 262145 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-ansi-language:EN-GB; 	mso-fareast-language:EN-GB;} @page Section1 	{size:841.9pt 595.3pt; 	mso-page-orientation:landscape; 	margin:89.85pt 1.0in 89.85pt 1.0in; 	mso-header-margin:35.45pt; 	mso-footer-margin:35.45pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 11pt;" lang="EN-GB"&gt;Visual Basic for Applications code to illustrate the use of the AES Dynamic Link Library.&lt;span style=""&gt;  &lt;/span&gt;Very similar code should also work in Visual Basic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Const BlkLenMax = 32&lt;span style=""&gt;        &lt;/span&gt;' maximum block length in bytes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Const KeyLenMax = 32&lt;span style=""&gt;        &lt;/span&gt;' maximum block length in bytes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Const KeySchLenMax = 128&lt;span style=""&gt;    &lt;/span&gt;' maximum key schedule length in bytes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private BlkLen As Integer&lt;span style=""&gt;           &lt;/span&gt;' actual block length&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private KeyLen As Integer&lt;span style=""&gt;           &lt;/span&gt;' actual key length&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Type AESctx&lt;span style=""&gt;     &lt;/span&gt;' Type to hold the AES context data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;  &lt;/span&gt;Ekey(0 To KeySchLenMax - 1) As Long&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;  &lt;/span&gt;Nrnd As Long&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;  &lt;/span&gt;Ncol As Long&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Type KeyBlk&lt;span style=""&gt;     &lt;/span&gt;' Type to hold user key data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;K(0 To KeyLenMax - 1) As Byte&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Type IoBlk&lt;span style=""&gt;      &lt;/span&gt;' Type to hold cipher input and output blocks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt; &lt;/span&gt;IO(0 To BlkLenMax - 1) As Byte&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem Change "d:\dll_pth" in the following lines to the directory path where the AES DLL is located&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Declare Function AesBlkLen Lib "d:\dll_path\aes.dll" Alias "_aes_blk_len@8" (ByVal N As Long, C As AESctx) As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Declare Function AesEncKey Lib "d:\dll_path\aes.dll" Alias "_aes_enc_key@12" (K As KeyBlk, ByVal N As Long, C As AESctx) As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Declare Function AesDecKey Lib "d:\dll_path\aes.dll" Alias "_aes_dec_key@12" (K As KeyBlk, ByVal N As Long, C As AESctx) As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Declare Function AesEncBlk Lib "d:\dll_path\aes.dll" Alias "_aes_enc_blk@12" (Ib As IoBlk, Ob As IoBlk, C As AESctx) As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Declare Function AesDecBlk Lib "d:\dll_path\aes.dll" Alias "_aes_dec_blk@12" (Ib As IoBlk, Ob As IoBlk, C As AESctx) As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Sub Hex(X As Byte)&lt;span style=""&gt;  &lt;/span&gt;' Output a byte in hexadecimal format&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Dim H As Byte&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;H = Int(X / 16)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;If H &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;    &lt;/span&gt;Debug.Print Chr(48 + H);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;    &lt;/span&gt;Debug.Print Chr(87 + H);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;H = Int(X Mod 16)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;If H &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;    &lt;/span&gt;Debug.Print Chr(48 + H);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;    &lt;/span&gt;Debug.Print Chr(87 + H);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Sub OutKey(S As String, B As KeyBlk)&lt;span style=""&gt;    &lt;/span&gt;' Display a key value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Debug.Print: Debug.Print S;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;For i = 0 To KeyLen - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;   &lt;/span&gt;Hex B.K(i)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Next i&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Private Sub OutBlock(S As String, B As IoBlk)&lt;span style=""&gt;   &lt;/span&gt;' Display an input/output block&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Debug.Print: Debug.Print S;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;For i = 0 To BlkLen - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;span style=""&gt;   &lt;/span&gt;Hex B.IO(i)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Next i&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem The following Main routine should output the following in the immediate window:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem Key =&lt;span style=""&gt;            &lt;/span&gt;00000000000000000000000000000000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem Input =&lt;span style=""&gt;          &lt;/span&gt;00000000000000000000000000000000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem Encrypted Text = 66e94bd4ef8a2c3b884cfa59ca342b2e&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem Decrypted Text = 00000000000000000000000000000000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Sub &lt;st1:place st="on"&gt;Main&lt;/st1:place&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Dim Key As KeyBlk&lt;span style=""&gt;   &lt;/span&gt;' These variables are automatically&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Dim Ib As IoBlk, &lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt; As IoBlk, Rb As IoBlk&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Dim Cx As AESctx&lt;span style=""&gt;    &lt;/span&gt;' initialised to zero values in VBA&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Dim RetVal As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;BlkLen = 16: KeyLen = 16&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Rem RetVal = AesBlkLen(BlkLen, Cx)&lt;span style=""&gt;     &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;' include if the cipher block size is variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;OutKey "Key =&lt;span style=""&gt;            &lt;/span&gt;", Key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;OutBlock "Input =&lt;span style=""&gt;          &lt;/span&gt;", Ib&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;RetVal = AesEncKey(Key, KeyLen, Cx)&lt;span style=""&gt;     &lt;/span&gt;' set an all zero encryption key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;RetVal = AesEncBlk(Ib, &lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt;, Cx)&lt;span style=""&gt;          &lt;/span&gt;' encrypt Ib to &lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;OutBlock "Encrypted Text = ", &lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;RetVal = AesDecKey(Key, KeyLen, Cx)&lt;span style=""&gt;     &lt;/span&gt;' set an all zero decryption key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;RetVal = AesDecBlk(&lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt;, Rb, Cx)&lt;span style=""&gt;          &lt;/span&gt;' decrypt &lt;st1:place st="on"&gt;Ob&lt;/st1:place&gt; to Rb&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;OutBlock "Decrypted Text = ", Rb&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;Debug.Print&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Lucida Console&amp;quot;;" lang="EN-GB"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/722618417950535887-1386301126479194265?l=examplesourcecode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://examplesourcecode.blogspot.com/feeds/1386301126479194265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=722618417950535887&amp;postID=1386301126479194265' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1386301126479194265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/722618417950535887/posts/default/1386301126479194265'/><link rel='alternate' type='text/html' href='http://examplesourcecode.blogspot.com/2008/07/visual-basic-for-applications-code-to.html' title='Visual Basic for Applications code to illustrate the use of the AES Dynamic Link Library.'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
