Category Archives: Programming

Combining strings in Python

Result: Boris Dimitrov

www.ece.nu

Hello World! in Python

First of all you need to install python if it is not already installed. Python download page: https://www.python.org/downloads/

Python installation path should be added as an system variable in Windows:

  • Open System Properties by typing sysdm.cpl in Command Prompt window
  • Go to the Advanced tab and click the Environment Variables
  • In System variables find the Path variable and click Edit
  • Add the path where Python is installed

In Windows you can open a command prompt and type the following command:

or just type py and press Enter. You must see Python start up:

If you are using Visual Studio Code do one of the following:

  • Right click anywhere in the editor window > Run Python file in Terminal
  • Main menu > View > Command Palette… > Python: Start REPL > Type the lines of code and press Enter
  • Select the Lines of code > right click > Run Selection/Line in Python Terminal

www.ece.nu

Kelvin to Celsius Conversion Table in C

%.2f means print as a floating point with 2 decimals.

The output is:
Kelvin to Celsius Conversion Table in C

REFERENCES

[1] Brian W. Kernighan, Dennis M. Ritchie, The C Programming Language (Second Edition), Prentice Hall Inc., Greek Edition, page. 28

www.ece.nu

Hello World! in Java

The above code can be run in NetBeans IDE.

www.ece.nu

How to build a simple “Hello World!” Cocoa OS X Application in Swift

Start Xcode (Version 6.1.1). Xcode is an Integrated Development Environment for mac OS.

Main Menu > File > New Project

Under “OS X” choose “Application” and then “Cocoa Application” (this template creates a Cocoa application for the OS X platform).

Enter the “Product Name” and choose the Swift Programming Language.

Go to the “Project Navigator” area and select the “Main.storyboard”.

Search for a “Label” in the Object Library:

Xcode, Object Library, Label

Figure: Xcode, Object Library

Drag & Drop a Label from the Library to the Window.

You can use the so called Inspector, located right above the Library, in order to change the name of the window and the name of the Label to “Hello World!”.

If you click on the window the Inspector will show the attributes of the window.

Xcode, Attributes Inspector, Window

Figure: Xcode, Inspector, attributes of a window

If you click on the label the Inspector will show the attributes of the label.

Xcode, Attributes Inspector, Label

Figure: Xcode, Inspector, attributes of a label

Xcode, Main.storyboard

Figure: Xcode, Main.storyboard

Run the application: Main Menu > Product > Run

The output is:

Xcode, Window, Hello World!

 

www.ece.nu

The sizeof Operator in C

The sizeof operator is used to determine the number of bytes required to store a value of a specific data type.

The output is :

The sizeof operator in C

IDE: Xcode Version 6.1.1

Compiler: Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)

Operating system: OS X Yosemite Version 10.10.1 (64-bit kernel)

Processor: Intel Core 2 Duo (64-bit processor).

www.ece.nu

What is Ajax?

Ajax

  • is not a programming language.
  • is an approach to web interaction. This approach involves transmitting only a small amount of information to and from the server in order to give the user the most responsive experience possible, [1].
  • is an approach for developing dynamic Web sites, [2].
  • is not an acronym but in literature it can be in found also as AJAX, meaning Asynchronous JavaScript And XML.
  • enables us to pass information between a Web browser and a Web server without refreshing the entire Web page, [2].

Ajax is a group of technologies working together:

For presentation:

  • HyperText Markup Language (HTML) – content representation language.

  • Cascading Style Sheets (CSS) – provides stylistic formatting to XHTML.

For data display and interaction:

  • Document Object Model (DOM) – necessary to change portions of an XHTML page without reloading it.

For data interchange:

  • Extensible Markup Language (XML) – protocol used to transfer data back and forth betwen client and server.

  • JavaScript Object Notation (JSON)

For asynchronous communication:

  • XMLHttpRequest Object (XHR)

Other technologies:

  • Extensible HyperText Markup Language (XHTML) – content representation language.
  • JavaScript – scripting language used to program an Ajax engine.
  • Extensible Stylesheet Language Transformation (XSLT) – transforms XML into XHTML (with CSS linked to it).
  • RSS
  • Atom.

Two different styles of Ajax, [2]:

  • Partial-page rendering
  • JSON service

Ajax Frameworks:

  • ASP.NET is Microsoft’s Ajax Framework. ASP stands for Active Server Pages.
  • Jboss RichFaces is a Framework for integrating Ajax capabilities into applications using JavaServer Faces (JSF).

Ajax example:

Google Suggest – as we type, Google Suggest requests suggestions from the server, showing us a drop-down list of search terms that we may be interested in.

REFERENCES

[1] Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett, Professional Ajax, Second Edition, Wiley Publishing Inc.

[2] www.youtube.com, Telerik Academy, ASP.NET Ajax

www.ece.nu

Pre-increment and post-increment operators in C

a++ post increment (it increments the value of a after the operation is over)

++b  pre increment (it increments the value of b before the operation)

The output is:

Pre-increment and post-increment operators in C

www.ece.nu

Computing and displaying the cubes and the sums of cubes of the first 10 integers in C

The above program computes and displays cubes and sums of cubes of the first 10 integers. This program also illustrates the use of while loop.
running_sum=running_sum+CUBE(i1)
e.g. for i1=1 the running_sum=0+1=1, for i2=2 the running_sum=1+8=9

The output is:

Computing and displaying cubes and sums of cubes of the first 10 integers in C

www.ece.nu