...

Tuesday 30 December 2014

Why Array Index Starts from Zero?

It starts at 0 because the index value tells the computer how far it needs to move away from the starting point in the array. In some programming languages, if you use an array (without giving an index number in brackets), you are really only referring to the memory address of the starting point of the array. When you reference a specific value in the array, you are telling the programming language to start at the memory address of the beginning of the array and then move up the memory address as needed. So lets say a program allocates space in the memory between address numbers 1024 and 2048 and it starts at 1024 and each item in the array is 8 bytes long. Then saying arrayName[0] is the same as telling it to look at the data stored at the memory address of (1024 + (0 * 8)), or 1024. If you want the value stored at arrayName[1], then it looks at the value held at (1024 + (1*8)), which is 1032. If you wanted the value held at arrayName[10], then it would look at the data stored in the memory address of 1024 + (10 * 8), which is 1104.This is how things work with older languages and some languages that work with more memory manipulations.

Monday 29 December 2014

Operator Precedence and Associativity

Note: Operators are shown in decreasing order of precedence from top to bottom in the table.
Operator Type Associativity
: : binary scope resolution left to right
: : unary scope resolution left to right
( ) parentheses left to right
[ ] array subscript left to right
. member selection via object left to right
-> member selection via pointer left to right
+ + unary postfix increment left to right
- - unary postfix decrement left to right
typeid runtime type information left to right
dynamic_cast <type> runtime type-checked cast left to right
static_cast <type> compile-time type-checked cast left to right
reinterpret_cast <type> cast for nonstandard conversions left to right
const_cast <type> cast away const-ness left to right
+ + unary prefix increment right to left
- - unary prefix decrement right to left
+ unary plus right to left
- unary minus right to left
! unary logical negation right to left
~ unary bitwise complement right to left
sizeof determine size in bytes right to left
& address right to left
* dereference right to left
new dynamic memory allocation right to left
new[ ] dynamic array allocation right to left
delete dynamic memory deallocation right to left
delete[ ] dynamic array deallocation right to left
( type ) C-style unary cast right to left
.* pointer to member via object left to right
->* pointer to member via pointer left to right
* multiplication left to right
/ division left to right
% modulus left to right
+ addition left to right
- subtraction left to right
<< bitwise left shift left to right
>> bitwise right shift left to right
< relational less than left to right
<= relational less than or equal to left to right
> relational greater than left to right
>= relational greater than or equal to left to right
= = relational is equal to left to right
!= relational is not equal to left to right
& bitwise AND left to right
^ bitwise exclusive OR left to right
| bitwise inclusive OR left to right
&& logical AND left to right
| | logical OR left to right
?: ternary conditional right to left
= assignment right to left
+= addition assignment right to left
- = subtraction assignment right to left
* = multiplication assignment right to left
/= division assignment right to left
%= modulus assignment right to left
&= bitwise AND assignment right to left
^= bitwise exclusive OR assignment right to left
|= bitwise inclusive OR assignment right to left
<<= bitwise left-shift assignment right to left
>>= bitwise right-shift assignment right to left
, comma left to right

Friday 26 December 2014

Introduction to the Standard Template Library (STL)

The C++ standard committee added the Standard Template Library (STL) to the C++ Standard Library due to the importance of the software reuse benefits. The STL defines powerful, template-based, reusable components that implement many common data structures and algorithms used to process those data structures. The STL offers proof of concept for generic programming with templates. It is very important to keep in mind that in industry, the features presented are often referred to as the Standard Template Library or STL. However, these terms are not used in the C++ standard document, because these features are simply considered to be part of the C++ Standard Library.
The STL was developed by Alexander Stepanov and Meng Lee at Hewlett-Packard (hp) and is based on their research in the field of generic programming, with significant contributions from David Musser. The STL was conceived and designed for performance and flexibility. In this article, the main three components of STL (containers, iterators and algorithms) will be discussed. STL containers, iterators and algorithms are shown in the tables given below.

Standard Library Containers
Standard Library Container Class
Description
Sequence containers
vector
Rapid insertions and deletions at back. Direct access to any element.
deque
Rapid insertions and deletions at front or back. Direct access to any element.
list
Doubly linked list, rapid insertion and deletion anywhere.
Associative containers
set
Rapid lookup, no duplicates allowed.
multiset
Rapid lookup, duplicates allowed.
map
One-to-one mapping, no duplicates allowed, rapid key-based lookup.
multimap
One-to-one mapping, duplicates allowed, rapid key-based lookup.
Container adapters
stack
Last-in, first-out (LIFO).
queue
First-in, first-out (FIFO).
priority_queue
Highest-priority element is always the first element out.

Standard Library Common Member Functions
Member Function Description
default constructor A constructor to create an empty container. Normally, each container has several constructors that provide different initialization methods for the container.
copy constructor A constructor that initializes the container to be a copy of an existing container of the same type.
destructor Destructor function for cleanup after a container is no longer needed.
empty Returns true if there are no elements in the container, otherwise, returns false.
insert Inserts an item in the container.
size Returns the number of elements currently in the container.
operator= Assigns one container to another.
operator< Returns true if the first container is less than the second one, otherwise, returns false.
operator<= Returns true if the first container is less than or equal to the second one, otherwise, returns false.
operator> Returns true if the first container is greater than the second one, otherwise, returns false.
operator>= Returns true if the first container is greater than or equal to the second one, otherwise, returns false.
operator== Returns true if the first container is equal to the second one, otherwise, returns false.
operator!= Returns true if the first container is not equal to the second one, otherwise, returns false.
swap Swap the elements of the two containers.
max_size Returns the maximum number of elements for a container.
begin The two versions of this function return either an iterator or a const_iterator that refers to the first element of the container.
end The two versions of this function return either an iterator or a const_iterator that refers to the next position after the end of the container.
rbegin The two versions of this function return either a reverse_iterator or a const_reverse_iterator that refers to the last element of the container.
rend The two versions of this function return either a reverse_iterator or a const_reverse_iterator that refers to the next position after the last element of the reversed container.
erase Erases one or more elements from the container.
clear Erases all the elements from the container.

Standard Library Container Header Files
Header File Description
<vector>
<list>
<deque>
<queue> Contains both queue and priority_queue. 
<stack>
<map> Contains both map and multimap. 
<set> Contains both set and multiset. 
<valarray>
<bitset>

typedefs Found in First-Class Containers
typedef Description
allocator_type The type of the object used to allocate the container’s memory.
value_type The type of the element stored in the container.
reference A reference to the type of element stored in the container.
const_reference A constant reference to the type of element stored in the container. Such a reference can be used only for reading elements in the container and for performing const operations.
pointer A pointer to the type of element stored in the container.
const_pointer A pointer to a constant of the container’s element type.
iterator An iterator that points to an element of the container’s element type.
const_iterator A constant iterator that points to the type of element stored in the container and can be used only to read elements. 
reverse_iterator A reverse iterator that points to the type of element stored in the container. This type of iterator is for iterating through a container in reverse.
const_reverse_iterator A constant reverse iterator that points to the type of element stored in the container and can be used only to read elements. This type of iterator is for iterating through a container in reverse.
difference_type The type of the result of subtracting two iterators that refer to the same container (operator - is not defined for iterators of lists and associative containers).
size_type The type used to count items in a container and index through a sequence container (cannot index through a list).

STL Iterator Categories
Iterator Category Description
input Used to read an element from a container. An input iterator can move only in the forward direction (i.e., from the beginning of the container to the end) one element at a time. Input iterators support only one-pass algorithms - the same input iterator cannot be used to pass through a sequence twice. 
output Used to write an element to a container. An output iterator can move only in the forward direction one element at a time. Output iterators support only one-pass algorithms - the same output iterator cannot be used to pass through a sequence twice.
forward Combines the capabilities of input and output iterators and retains their position in the container (as state information).
bidirectional Combines the capabilities of a forward iterator with the ability to move in the backward direction (i.e., from the end of the container towards the beginning). Bidirectional iterators support multipass algorithms.
random access Combines the capabilities of a bidirectional iterator with the ability to directly access any element of the container (i.e., to jump forward or backward by an arbitrary number of elements).

Iterator Category Hierarchy
iterator_categoty_hierarchy

Iterator Type Supported by each Container
Container Type of Iterator Supported
Sequence containers (first class)
vector
random access
deque
random access
list bidirectional
Associative containers (first class)
set bidirectional
multiset bidirectional
map bidirectional
multimap bidirectional
Container adapters
stack no iterators supported
queue no iterators supported
priority_queue no iterators supported

Iterator typedefs
Predefined typedefs for iterator types Direction of ++ Capability
iterator
forward
read / write
const_iterator
forward
read
reverse_iterator
backward
read / write
const_reverse_iterator
backward
read

Iterator Operation for each Type of Iterator
Iterator Operation Description
All iterators
++p Pre-increment an iterator.
p++ Post-increment an iterator.
Input iterators
*p Dereference an iterator.
p = p1 Assign one iterator to another.
p == p1 Compare iterators for equality.
p != p1 Compare iterators for inequality.
Output iterators
*p Dereference an iterator.
p = p1 Assign one iterator to another.
Forward iterators Forward iterators provide all the functionality of both input iterators and output iterators.
Bidirectional iterators
--p Pre-decrement an iterator.
p-- Post-decrement an iterator.
Random access iterators
p += i Increment the iterator p by i positions.
p -= i Decrement the iterator p by i positions.
p + i or i + p Expression value is an iterator positioned at p incremented by i positions.
p - i Expression value is an iterator positioned at p decremented by i positions.
p - p1 Expression value is an integer representing the distance between two elements in the same container.
p[ i ] Return a reference to the element offset from p by i positions.
p < p1 Return true if iterator p is less than iterator p1 (i.e., iterator p is after iterator p1 in the container); otherwise, return false.
p <= p1 Return true if iterator p is less than or equal to iterator p1 (i.e., iterator p is before iterator p1 or at the same location as iterator p1 in the container); otherwise, return false.
p > p1 Return true if iterator p is greater than iterator p1 (i.e., iterator p is after iterator p1 in the container); otherwise, return false.
p >= p1 Return true if iterator p is greater than or equal to iterator p1 (i.e., iterator p is after iterator p1 or at the same location as iterator p1 in the container); otherwise, return false.

Mutating-Sequence Algorithms
copy partition replace_copy stable_partition
copy_backward random_shuffle replace_copy_if swap
fill remove replace_if swap_ranges
fill_n remove_copy reverse transform
generate remove_copy_if reverse_copy unique
generate_n remove_if rotate unique_copy
iter_swap replace rotate_copy

Non-Modifying Sequence Algorithms
adjacent_find equal find_end mismatch
count find find_first_of search
count_if find_each find_if search_n

Numerical Algorithms from Header File <numeric>
accumulate partial_sum
inner_product adjacent_difference

Some STL Exception Types
STL Exception Types Description
out_of_range
Indicates when subscript is out of range - e.g., when an invalid subscript is specified to vector member function at.
invalid_argument
Indicates an invalid argument was passed to a function.
length_error
Indicates an attempt to create too long a container, string, etc..
bad_alloc
Indicates that an attempt to allocate memory with new (or with an allocator) failed because not enough memory was available.

Other Standard Template Library Algorithms
Algorithm Description
inner_product Calculate the sum of the products of two sequences by taking corresponding elements in each sequence, multiplying those elements and adding the result to a total.
adjacent_difference Beginning with the second element in a sequence, calculate the difference (using operator -) between the current and previous elements and store the result. The first two input iterators arguments indicate the range of elements in the container  and the third indicates where the results should be stored. A second version of this algorithm takes as a fourth argument a binary function to perform a calculation between the current element and the previous element.
partial_sum Calculate a running total (using operator -) of the values in a sequence. The first two input iterators arguments indicate the range of elements in the container and the third indicates where the results should be stored. A second version of this algorithm takes as a fourth argument a binary function that performs a calculation between the current value in the sequence and the running total.
nth_element Use three random-access iterators to partition a range of elements. The first and last arguments represent the range of elements. The second argument is the partitioning element’s location. After this algorithm executes, all elements before the partitioning element are less than that element and all elements after the partitioning element are greater than or equal to that element. A second version of this algorithm takes as a fourth argument a binary comparison function.
partition This algorithm is similar to nth_element, but requires less powerful bidirectional iterators, making it more flexible. It requires two bidirectional iterators indicating the range of elements to partition. The third argument is a unary predicate function that helps partition the elements so that all elements for which the predicate is true are to the left (toward the beginning of the sequence) of those for which the predicate is false. A bidirectional iterator is returned indicating the first element in the sequence for which the predicate returns false.
stable_partition Similar to partition except that this algorithm guarantees that equivalent elements will be maintained in their original order.
next_permutation Next lexicographical permutation of a sequence.
prev_permutation Previous lexicographical permutation of a sequence.
rotate Use three forward iterator arguments to rotate the sequence indicated by the first and last argument by the number of positions indicated by subtracting the first argument from the second argument. e.g., the sequence 1,2,3,4,5 rotated by two positions would be 4,5,1,2,3.
rotate_copy This algorithm is identical to rotate except that the results are stored in a separate sequence indicated by the fourth argument - an output iterator. The two sequences must have the same number of elements.
adjacent_find This algorithm returns an input iterator indicating the first of two identical adjacent elements in a sequence. If there are no identical adjacent elements, the iterator is positioned at the end of the sequence.
search This algorithm searches for a subsequence of elements within a sequence of elements and, if such a subsequence is found, returns a forward iterator that indicates the first element of that subsequence. If there are no matches, the iterator is positioned at the end of the sequence to be searched.
search_n This algorithm searches a sequence of elements looking for a subsequence in which the values of a specified number of elements have a particular value and, if such a subsequence is found, returns a forward iterator that indicates the first element of that subsequence. If there are no matches, the iterator is positioned at the end of the sequence to be searched.
partial_sort Use three random-access iterators to sort part of a sequence. The first and last arguments indicate the sequence of elements. The second argument indicates the ending location for the sorted part of the sequence. By default, elements are ordered using operator < (a binary predicate function can also be supplied). The elements from the second argument iterator to the end of the sequence are in an undefined order.
partial_sort_copy Use two input iterators and two random-access iterators to sort part of a sequence indicated by the two input iterator arguments. The results are stored in the sequence indicated by the two random-access iterator arguments. By default, elements are ordered using operator < (a binary predicate function can also be supplied). The number of elements sorted is the smallest of the number of elements in the result and the number of elements in the original sequence.
stable_sort The algorithm is similar to sort except that all equivalent elements are maintained in their original order. This sort is O(n log n) if enough memory is available; otherwise, it’s O(n(log n)2).

Function Objects in Standard Library
STL Function Objects Type STL Function Objects Type
divides< T > arithmetic logical_or< T > logical
equal_to< T > relational minus< T > arithmetic
greater< T > relational modulus< T > arithmetic
greater_equal< T > relational negate< T > arithmetic
less< T > relational not_equal_to< T > relational
less_equal< T > relational plus< T > arithmetic
logical_and< T > logical multiplies< T > arithmetic
logical_not< T > logical

Tuesday 23 December 2014

Why Linux is Free?

Linux is freeware. Freeware is a software written by somebody and the author doesn’t forbid the free distribution and usage of the software. Linux is a computer operating system, like Microsoft Windows or Apple Mac OS. Unlike those two, however, Linux is built with a collaborative development model. The operating system and most of its software are created by volunteers and employees of companies, governments and organizations from all over the world. The operating system is free to use and everyone has the freedom to contribute to its development. This co-operative development model means that everyone can benefit. Because of this, we like to call it Free Software, or Socially Responsible Software. Closely related is the concept of Open Source Software. Together, Free and Open Source Software is collectively abbreviated as FOSS.
Benefits of Linux:
Linux has many other benefits, including speed, security and stability. It is renowned for its ability to run well on more modest hardware. Linux comes from the venerable UNIX family of operating systems, and so has been built from the ground-up with Internet-style networking and security in mind. Hence, viruses, worms, spyware and adware are basically a non-issue on Linux. Most Linux distributions support dozens of programming languages.
How Linux is Free?
It can cost time and resources to produce good software, which are not synonymous with money. Many FOSS (Free and Open Source Software) developers develop for fun; many others are paid for their time. Because the code is open, it is actively worked on by all sorts of individuals and organizations. Since development is shared, it can cost relatively little to work with FOSS. The savings made can be invested into creating better customization or into improving integration with existing systems and processes. When access to the source code is available, there are essentially no limitations to what can be achieved. Free Software is so named because of the freedom granted to the user.
The word "free" has two quite different meanings in the English language, and it sometimes leads to misconceptions about the free nature of Linux. These two meanings follow the Latin adjective "liber" and the adverb "gratis," and they are often illustrated with the phrases "free speech" and "free (of charge) beer." Most Linux software is free in both senses, but it is only the first sense which is essential to Linux.
Many quantitative studies of free / open source software focus on topics including market share and reliability, with numerous studies specifically examining Linux. The Linux market is growing rapidly, and the revenue of servers, desktops, and packaged software running Linux was expected to exceed $35.7 billion by 2008.
IDC's (International Data Corporation) 2007 report indicated that Linux held 12.7% of the overall server market at that time. This estimate was based on the number of Linux servers sold by various companies, and did not include server hardware purchased separately which had Linux installed on it later. In September 2008 Microsoft CEO Steve Ballmer admitted that 60% of web-servers run Linux versus 40% that run Windows Server.
Primarily based on web server statistics, various companies estimated that the desktop market share of Linux range from less than 1% to 4.8%. In comparison, Microsoft operating systems hold more than 85%. Analysts and proponents attribute the relative success of Linux to its security, reliability, low cost, and freedom.
As everyone can use Linux for being freeware software so many individuals and organizations also donate and invest for Linux’s betterment and customization. Companies have their shares in developing Linux. The market value of Linux is rising so companies invest to get their share. It is also freeware to improve its market value. In the beginning software companies launch freeware software and later on users have to pay for getting the software. Similar is the case with the Linux being freeware. In the long run, investors will get too many benefits.







Monday 22 December 2014

Android & iOS App Store Summary

When it comes to major apps, the line between Android and iOS is starting to blur rapidly. Choosing a smartphone or tablet platform should be a well-considered decision because switching from iOS to Android or vice versa will require you to buy apps again in the Google Play (or Apple app) store. Android is now the world’s most commonly used smartphone platform and is used by many different phone manufacturers. iOS is only used on Apple devices, such as the iPhone.
iOS and Android both use touch interfaces that have a lot in common - swiping, tapping and pinch-and-zoom. Both operating systems boot to a home screen, which is similar to a computer desktop. While an iOS home screen only contains rows of app icons, Android allows the use of widgets, which display auto-updating information such as weather and email. The iOS user interface features a dock where users can pin their most frequently used applications. A status bar runs across the top on both iOS and Android, offering information such the time, Wi-Fi or cell signal, and battery life; on Android the status bar also shows the number of newly received emails or messages.
The bottom line when comparing Google and Apple's app stores is that most popular apps are available for both platforms. But for tablets, there are more apps designed specifically for the iPad while Android tablet apps are often scaled up versions of Android smartphone apps. Developers at startups often focus on one platform (usually iOS) when they first launch their smartphone app because they do not have resources to serve multiple platforms from the get go. For example, the popular Instagram app started with iOS and their Android app came much later.

Saturday 20 December 2014

Quiz -- Computers Languages, Internet and World Wide Web

  1. The company that popularized personal computing was ____________.
  2. The computer that made personal computing legitimate in business and industry was the ____________.
  3. Computers process data under the control of sets of instructions called computer ____________.
  4. The six key logical units of the computer are the __________, __________, ___________, __________, __________ and the __________.
  5. The three types of computer languages are __________, __________ and ____________.
  6. The programs that translate high-level language programs into machine language are called ____________.
  7. C is widely known as the development language of the ____________ operating system.
  8. The ____________ language was developed by Writh for teaching structured programming.
  9. The Department of Defense developed the Ada language with a compatibility called ____________, which allows programmers to specify activities that can proceed in parallel.
  10. ____________ or labeling content, is another key part of the collaborative theme of Web 2.0.
  11. With Internet applications, the desktop evolves to the ____________.
  12. ____________ involves reworking code to make it clearer and easier to maintain while preserving its functionality.
  13. With ____________ development, individuals and companies contribute their efforts in developing, maintaining and evolving software in exchange for the right to use that software for their own purposes, typically at no change.
  14. ____________ are used to match specific character patterns in text. They can be used to validate data to ensure that it’s in a particular format, to replace parts of one string with another, or to split a string.
  15. C++ programs are normally typed into a computer using a(n) ____________ program.



Answer Key
(1) Apple (2) IBM Personal Computer (3) programs (4) input unit, output unit, memory unit, arithmetic and logic unit (ALU), central processing unit (CPU), secondary storage unit (5) machine languages, assembly languages, high-level languages (6) compilers (7) UNIX (8) Pascal (9) multitasking (10) Tagging (11) webtop (12) Refactoring (13) open source (14) Regular expressions (15) editor

Thursday 18 December 2014

How to Install Android SDK? (for Linux)

This tutorial will prepare you to install and configure Android on your Ubuntu Linux system. You must have Oracle Java JDK or OpenJDK on your system before installing Android SDK. OpenJDK (aka Open Java Development Kit) is a free and open source implementation of the Java programming language. You can download Oracle Java JDK from here. Now, follow these 6 steps to install Android SDK on Linux operating system.

Step 1

  • First, boot up Ubuntu Linux,make sure you have an implementation of the Java JDK installed on your system, whether it is OpenJDK or Oracle Java JDK, which lays the foundation for the Android SDK. You have choice between installing Open JDK or installing Oracle Java. I recommend installing Oracle Java because it is usually the most well maintained and up to date version of Java. Type this command "sudo apt-get install openjdk-7-jre". This command installs OpenJDK JRE( Java Runtime Environment ) on your system.
  • If you are running a 64-bit distribution of Android SDK on your machine, you need to install the ia32-libs. The command (sudo apt-get install ia32-lib) will install additional libraries needed for development with the Android SDK and the command (javac -version) will check the Java JDK on your system. The Java JDK command must respond back with java 1.7.0 or something similar to this. The command (java -version) will check the Java JRE ( Java Runtine Environment ) on your system.

Step 2 

  • Make sure you have the Eclipse Integrated Development Environment (IDE) installed on your system. For example, select Eclipse Classic and download the version for your system architecture such as 32bit or 64 bit version for Linux. If your computer system has 4GB or more of memory most likely it is a 64 bit computer.
  • The command (file /sbin/init) will download the Eclipse IDE into your /home/"your_user_name"/Downloads. Select the correct bit version for your corresponding system architecture. For example, if you are on 32-bit Ubuntu Linux select 32-bit Eclipse IDE and if you are on 64-bit Ubuntu Linux select 64-bit Eclipse IDE.
  • This is an example of a 64-bit Eclipse IDE setup on 64-bit Ubuntu Linux operating system. The command (cd /home/"your_user_name"/Downloads) will change you in your Downloads directory. The command (sudo -s cp -r eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz /usr/local) will copy the Eclipse IDE to the /usr/local directory. The command (cd /usr/local) will change you into the eclipse directory. Then, the command (sudo -s chmod a+x eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz) will make the eclipse binaries executable for all on the system. Now, the command (sudo -s tar xvzf eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz) will unpack your Eclipse IDE compressed binaries and the command (exit) will take you out of root user.
  • Open up a terminal and enter the command (cd /home/"your_user_name"/Desktop) which will
    change you into your user Desktop, make sure you are not root. Now the command (ln -s /usr/local/eclipse/eclipse) and (chown "your_user_name" eclipse) will make the Eclipse symbolic link located on your desktop belong to the user. It is very important to make sure that you are not root when you create this symbolic link from your Eclipse IDE /usr/local/eclipse directory to your Desktop /home/"your_user_name"/Desktop

Step 3

  • Download the Android SDK, click on the Linux tarball, android-sdk_r22-linux.tgz and save it to your /home/"your_user_name"/Downloads directory. Now, open up a terminal and the command (cd /home/"your_user_name"/Downloads) will change you into your Downloads directory. The command (sudo cp -r android-sdk_r22-linux.tgz /opt) will copy the android sdk to /opt. The command (cd /opt) will change you into the Android working directory. Now, the command (sudo tar xvzf android-sdk_r22-linux.tgz) will unpack your Android SDK and the command (sudo -s chmod -R 755 /opt/android-sdk-linux) will make the /opt directory and the Android SDK writable and executable for all users on the system. When these steps are complete you will have Android SDK located at: /opt/android-sdk-linux on your Ubuntu Linux system.
  • Open up a terminal and add Android SDK to your system wide PATH on Linux. Type the command (sudo nano /etc/profile) or (sudo gedit /etc/profile). Now add the following lines below to the end of the system PATH file.
    • export PATH=${PATH}: /opt/android-sdk-linux/tools
    • export PATH=${PATH}: /opt/android-sdk-linux/platform-tools
    • Save the /etc/profile file and exit.
  • Now, reload your system PATH /etc/profile by using the command (. /etc/profile). This command informs the Linux system of the location of the Android SDK development tools.

Step 4

  • In order to install the Android Development Tool (ADT), you will have to install the Android ADT tool for the Eclipse IDE as root. The command (sudo -s /usr/local/eclipse/eclipse) will install the ADT plugin tool for all users on the system.
  • Install the ADT Plugin for Eclipse, the ADT is a plugin for the Eclipse IDE. Before you can install or use ADT, you must have a compatible version of Eclipse installed on your system. Start Eclipse, then select Help and Install New Software. Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the URL (https://dl-ssl.google.com/android/eclipse/) for the Location. Now, click OK. If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  • In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded and Click Next. Read and accept the license agreements, then click Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  • When the installation completes, restart the Eclipse. Configuring the ADT Plugin, after you've successfully downloaded the ADT as described above.
  • Now, modify your ADT preferences in Eclipse to point to the Android SDK directory as given below:
    • Select Window > Preferences... to open the Preferences panel.
  • Select Android from the left panel. You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed.
  • For the SDK Location in the main panel, click Browse and locate your downloaded SDK directory, which should be /opt/android-sdk-linux. Click Apply, then OK.

Step 5

  • Adding Platforms and other components, in setting up your SDK is using the Android SDK and AVD Manager (a tool included in the SDK starter package) to download essential SDK components into your development environment. The SDK starter package, which you've already downloaded, includes only a single component: the latest version of the SDK Tools. To develop an Android application, you also need to download at least one Android platform and the associated platform tools. You can add other components and platforms as well, which is highly recommended.
  • Open Eclipse and click Window->Android SDK and AVD Manager->Installed packages and click update all. Simply click Install to accept the recommended set of components and install them.
  • On Linux, open a terminal and navigate to the /opt/android-sdk-linux/tools directory in the Android SDK. Type the command (sudo -s) and (cd /opt/android-sdk-linux/tools) to change you into the android sdk tools directory. The command (./android) will run the Android graphical user interface. In most cases you will have to be root user in order for the Android SDK to download updated components to the opt/android-sdk-linux directory. To download components, use the GUI (Graphical User Interface) of the Android SDK and AVD Manager to browse the SDK repository and select the new or updated components. The Android SDK and AVD Manager installs the selected components in your SDK environment.

Step 6 

  • Once all the components for Android have been updated you will need to create an Android Virtual Device.
  • Click on Window->Android SDK and AVD Manager->Virtual Devices in order to create a Android Virtual Device ( emulator ).
  • Click on Window->Android SDK and AVD Manager->Virtual Devices in order to create a Android Virtual Device ( emulator ).
  • Now, click on the box that says target and use the arrow button and scroll down and select appropriate Android version you want to develop with such as, Android 3.2-API Level 13.
  • Now, scroll down to the box that says Skin and Click on Resolution, enter the numbers 420x580 and select Create AVD, this will create your Android Virtual Device ( emulator ), for program testing.

Wednesday 17 December 2014

Quiz -- C++ Data Types

1. How would you declare an integer called num and initialize it to 10?
A. double num = 10;
B. int num = 10;
C. int num == 10;
D. int num 10;

2. What is the correct way to write a comment in C++ ?
A. /this is comment/
B. \\this is a comment
C. //this is a comment
D. None of the above.

3. How would you declare a double called sum and initialize it to 15?
A. double add 15;
B. add double = 15;
C. double add 15
D. double add = 15;

4. What do double data types hold?
A. two integers
B. decimals
C. one integer
D. whole numbers

5. What is the correct way to print integer add to the screen?
A. cout<<add<<endl;
B. cout<<"add"<<endl;
C. cout add;
D. cout>>add>>endl;
 
6. Which is the correct way to declare multiple integers?
A. int sum; num; age;
B. int sum, int num, int age;
C. int sum, num, age;
D. All of the above.

7. What is the correct way to input in a double called sum?
A. cout>>sum;
B. cin<<"sum";
C. cin>>sum
D. cin>>sum;


8. What is wrong with "int long = 9200000?
A. Out of range value
B. Invalid data type
C. Invalid name for variable
D. All of the above

9. How much memory a character takes to store the value?
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes

10. How much memory an integer takes to store the value?
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes







   







ANSWER KEY

1. (B)   2. (C)   3. (D)   4. (B)   5. (A)   6. (C)   7. (D)   8. (C)   9. (A)   10. (B)

Tuesday 16 December 2014

Windows 8 Keyboard Shortcuts

Knowing at least some of the Windows 8 keyboard shortcuts helps you to make your Windows 8 experience much more enjoyable. Try to memorize these top Windows 8 keyboard shortcut keys.
  • Press the Windows key to open the Start screen or switch to the Desktop (if open).
  • Press the Windows key + D opens the Windows Desktop.
  • Press the Windows key + . to pin and unpin Windows apps on the side of the screen.
  • Press the Windows key + X to open the power user menu, which gives you access to many of the features most power users would want (e.g. Device Manager and Command Prompt).
  • Press the Windows key + C to open the Charms.
  • Press the Windows key + I to open the Settings, which is the same Settings found in Charms.
  • Press and hold the Windows key + Tab to show open apps.
  • Press the Windows key + Print screen to create a screen shot, which is automatically saved into your My Pictures folder.
  • Press the Windows key‌+PgUp to move the Start screen and apps to the monitor on the left (Apps in the desktop won’t change monitors).
  • Press the Windows key‌+PgDown to move the Start screen and apps to the monitor on the right (Apps in the desktop won’t change monitors).
  • Press the Ctrl+plus (+) or Ctrl+minus (-) to Zoom in or out of a large number of items, like apps pinned to the Start screen.
  • Press the Windows key‌+O to Lock the screen orientation (portrait or landscape).
  • Press the Windows key‌+Tab to Cycle through recently used apps (except desktop apps).
  • Press the Windows key‌+Ctrl+Tab to Cycle through recently used apps (except desktop apps).
  • Press the Windows key‌+Shift+Tab to Cycle through recently used apps (except desktop apps) in reverse order.
  • Press the Alt+Tab to Switch between open apps (except desktop apps).
  • Press the Windows key‌+Shift+period (.) to Snap an app to the left.
  • Press the Windows key‌+period (.) to Cycle through open apps.
  • Press the Esc to Stop or exit the current task.
  • Press the Ctrl+Shift+N to Create a new folder.


Source: CS SLATER

Monday 15 December 2014

How to Install Android SDK? (for Windows)

The Android Developer Kit, simply named as Android SDK is what all the advance users of Android should have installed on Windows running computers. In fact this tool stands behind each developer who is working in developing and testing new apps for improving, updating or unchaining different version of the Android OS. Basically, you are dealing with some codes that will be inserted in the command prompt window and through which you will be able to interact and access the system and in built programs from your handset. Eclipse is being the language in which the codes are written. Before beginning the proper operations there should be applied some pre-requisites.
  • The Android SDK has some basic system requirement; before going any further check them by using the link from here.
  • Also, on your computer you will have to download JDK, the Java Development Kit; use the link from here.
  • Now, if you are looking forward in developing new apps for the Android OS, then, you need to download the Eclipse IDE (use the link from here) and the ADT plug-in which can be downloaded from here.
  • Install Eclipse on your PC, run the same and then go to “Window -> Android SDK -> AVD Manager”. By completing this you will be able to stay up to date with all the platforms.
  • If you don’t want to use Android SDK for developing and testing apps, you can skip the Eclipse IDE section.
You can start the installation procedure now. But, remember that this tutorial is posted only for those who have a Windows running computer. Now follow the given steps and install the Android SDK for Windows.
  1. Download the Android SDK from here and save the file on the desktop.
  2. Extract the file and place it to the root of the C driver. You should get something like “C:\ android-sdk-windows”.
  3. Go to the mentioned folder (C:\ android-sdk-windows) and open SDK manager.
  4. From there select “Android SDK Platform-tools, revision 6” along with anything else you want and start the installation procedure.
  5. Then, go to path “Available Packages -> Third party Add-ons -> Google Inc. add-ons -> check Google USB Driver package, revision 4 and install this too.
  6. You can close the manager now.
  7. Up next, on your computer click on “Start / Windows button -> Control Panel -> System proprieties”.
  8. Choose “Advance System settings” followed by “Environment Variables”.
  9. Now we will set down the variables; in order to do so, scroll down until you see “Path” – click on the same.
  10. Into the Value field, on the end of the line add the following “;C:\android-sdk-windows\platform-tools;C:\android-sdk-windows\tools”.
  11. Click “OK” and exit.
  12. Now, take your Android based device and enable the USB debugging option on it: “Settings-> Applications-> Development”.
  13. Connect your handset with the computer by using its USB cable.
  14. Install the proper drivers for your phone / tablet.
  15. Open command prompt on your computer (“Start > Run > cmd”).
  16. On the cmd window type “adb devices”.
  17. Your device should now be listed in cmd meaning that you are done.
In case you are not getting the expected outputs, then something might went wrong. Anyway, try to do the following steps to resolve the issues:
  • Right click on the “My computer” icon and then open the Device manager.
  • A yellow exclamation mark should be near the Unknown Device group.
  • Right click on ADB and select “Update Driver Software > Browse > Let me pick”.
  • Click on “Have disk > browse”.
  • Head to path “C:\android-sdk-windows\extras\google\usb_driver and choose android_winusb.inf.” and click on the Android ADB Interface.
  • Ignore the warnings if such is displayed.
  • When the installation procedure is over, re-open the cmd on your computer, type “adb devices” once more; this time everything should be working perfectly.
Now you've learned how to install Android SDK / ADB on Windows running computer. You can now install a custom ROM on your device, root or unlock its boot-loader, or why not you can even develop a new app for the Android OS.

Thursday 4 December 2014

Quiz -- C++ Basics

1. What is the correct value to return to the operating system upon the successful completion of a program?
A. -1
B. 1
C. 0
D. Programs do not return a value.

2. What is the only function all C++ programs must contain?
A. start()
B. system()
C. main()
D. program()

3. What punctuation is used to signal the beginning and end of code blocks?
A. { }
B. -> and <-
C. BEGIN and END
D. ( and )

4. What punctuation ends most lines of C++ code?
A. .
B. ;
C. :
D. '

5. Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }

6. Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double

7. Which of the following is the correct operator to compare two variables?
A. :=
B. =
C. equal
D. ==


8. Which of the following statement is correct?
A. C++ enables to define functions that take constants as an argument.
B. We cannot change the argument of the function that that are declared as constant.
C. Both A and B.
D. We cannot use the constant while defining the function.

9. How much memory an integer, double, float and character takes to store the value?
A. 4 bytes, 8 bytes, 4 bytes and 1 byte
B. 4 bytes, 4 bytes, 8 bytes and 2 bytes
C. 2 bytes, 8 bytes, 8 bytes and 4 byte
D. 2 or 4 bytes, 8 bytes, 8 bytes and 1 byte


10. What will be the output?
   


#include<iostream>
using namespace std;
int main()
{
    int a;
    cout<<a;
    return 0;
}



A. Unidentified Integer Error
B. Compile Error
C. Run-time Error
D. Garbage Value



















ANSWER KEY

1. (C)   2. (C)   3. (A)   4. (B)   5. (C)   6. (B)   7. (D)   8. (C)   9. (A)   10. (D)

Wednesday 3 December 2014

Introduction to Android Developing

What is Android?

Android is the world's most popular operating system for mobile devices and tablets. It is an open source operating system, created by Google, and available to all kinds of developers with various expertise levels, ranging from rookie to professional.
(The term 'open source' sounds pretty familiar, doesn't it? Well, open-source means software with source available for modification and bound to an open source license agreement. More about open source terminology can be found here).
From a developer's perspective, Android is a Linux-based operating system for smartphones and tablets. It includes a touch screen user interface, widgets, camera, network data monitoring and all the other features that enable a cell phone to be called a smartphone. Android is a platform that supports various applications, available through the Android Play Store. The Android platform also allows end users to develop, install and use their own applications on top of the Android framework. The Android framework is licensed under the Apache License, with Android application developers holding the right to distribute their applications under their customized license.
Android is the operating system that powers more than one billion smartphones and tablets. Since these devices make our lives so sweet, each Android version is named after a dessert. Whether it's getting directions or even slicing virtual fruit, each Android release makes something new possible. Like most software, Android is released in versions. Google has also assigned names to its versions. Below are all the versions of Android released to date:

Version       Name   Device
1.0  Android Beta    Phone
1.1  Android    Phone
1.5  Cupcake    Phone
1.6  Donut    Phone
2.0/2.1   Eclair    Phone
2.2.x  Froyo    Phone
2.3.x  Gingerbread    Phone
3.0/3.1/3.2  Honeycomb    Tablet
4.0.x  Ice Cream Sandwich    Phone / Tablet
4.1/4.2/4.3  Jelly Bean    Phone / Tablet





4.4                Kit Kat                         Phone / Tablet
5.0                Lollipop                        Phone / Tablet

As we can see in the table above, various versions of Android are supported on phones and tablets. There are umpteen Android devices available in the market from manufacturers like Samsung, HTC, Motorola and others. Google itself also has phones made in conjunction with OEMs, branded as the Nexus series.

Understanding Android:

To begin development on Android even at the application level, I think it is paramount to understand the basic internal architecture. Knowing how things are arranged inside helps us understand the application framework better, so we can can design the application in a better way.
Android is an OS based on Linux. Hence, deep inside, Android is pretty similar to Linux. To begin our dive into the Android internals, let us look at an architectural diagram.

http://www.android-app-market.com/wp-content/uploads/2012/02/Android-architecture.jpg
Android Architecture Diagram
 The above diagram illustrates the Android architecture. As you can see, it is a software stack above the hardware that is provided by the OEMs. Let's start with the topmost layer, i.e., the applications.

Applications:

The diagram shows four basic apps (Home, Contacts, Phone and Browser), just to give the idea that there can be multiple apps sitting on top of Android. These apps are like any user interface you use on Android; for example, when you use a music player, the GUI on which there are buttons to play, pause, seek, etc is an application. Similarly, is an app for making calls, a camera app, and so on. All these apps are not necessarily from Google. Anyone can develop an app and make it available to everyone through Google Play Store. These apps are developed in Java, and are installed directly, without the need to integrate with Android OS.

Application Framework:

Scratching further below the applications, we reach the application framework, which application developers can leverage in developing Android applications. The framework offers a huge set of APIs used by developers for various standard purposes, so that they don't have to code every basic task.The framework consists of certain entities; major ones are:
  • Activity Manager
    This manages the activities that govern the application life cycle and has several states. An application may have multiple activities, which have their own life cycles. However, there is one main activity that starts when the application is launched. Generally, each activity in an application is given a window that has its own layout and user interface. An activity is stopped when another starts, and gets back to the window that initiated it through an activity callback.
  • Notification ManagerThis manager enables the applications to create customized alerts
  • Views
    Views are used to create layouts, including components such as grids, lists, buttons, etc.
  • Resource ManagersApplications do require external resources, such as graphics, external strings, etc. All these resources are managed by the resource manager, which makes them available in a standardized way.
  • Content Provider
    Applications also share data. From time to time, one application may need some data from another application. For example, an international calling application will need to access the user's address book. This access to another application's data is enabled by the content providers.

Libraries:

This layer holds the Android native libraries. These libraries are written in C/C++ and offer capabilities similar to the above layer, while sitting on top of the kernel. A few of the major native libraries include
  • Surface Manager: Manages the display and composting window-ing manager. - Media framework: Supports various audio and video formats and codecs including their playback and recording.
  • System C Libraries: Standard C library like libc targeted for ARM or embedded devices.
  • OpenGL ES Libraries : These are the graphics libraries for rendering 2D and 3D graphics.
  • SQLite : A database engine for Android.

Android Run-time:

The Android run-time consists of the Dalvik Virtual Machine. It is basically a virtual machine for embedded devices, which like any other virtual machine is a byte-code interpreter. When we say it is for embedded devices, it means it is low on memory, comparatively slower and runs on battery power. Besides the Dalvik Virtual Machine, it also consists of the core libraries, which are Java libraries and are available for all devices.

Kernel:

The Android OS is derived from Linux Kernel 2.6 and is actually created from Linux source, compiled for mobile devices. The memory management, process management etc. are mostly similar. The kernel acts as a Hardware Abstraction Layer between hardware and the Android software stack.

Android SDK:

As already mentioned, Android is open source and hence the source code is available for all developers. In totality it is called the Android SDK. You can download, build and work on Android in a number of different ways--it all depends on what you want to do. If your goal is to develop an Android application, you don't necessarily need to download all the source. Google recommends the Eclipse IDE, for which there is an available Android Developer Tools (ADT) plugin, through which you can install the specific SDK, create projects, launch emulators, debug, etc. To see more details of Eclipse and ADT through Android's official website for developers click here.

Why Study Computer Science?

The most important aspect of computer science is problem solving, an essential skill for life. Students study the design, development and analysis of software and hardware used to solve problems in a variety of business, scientific and social contexts. Because computers solve problems to serve people, there is a significant human side to computer science as well.

Top Ten Reasons to Study Computer Science

The Association of Computing Machinery is an international organization for computer scientists. The ACM has developed the following list of top ten reasons to study computer science which we quote from their web site.
  1. Computing is part of everything we do! 
  2. Expertise in computing enables you to solve complex, challenging problems.
  3. Computing enables you to make a positive difference in the world. 
  4. Computing offers many types of lucrative careers. 
  5. Computing jobs are here to stay, regardless of where you are located. 
  6. Expertise in computing helps even if your primary career is something else. 
  7. Computing offers great opportunities for true creativity and innovativeness.  
  8. Computing is an essential part of well-rounded academic preparation. 
  9. Computing has space for both collaborative work and individual effort.  
  10. Future opportunities in computing are without boundaries.



CS Slater

Twitter Delicious Facebook Digg Favorites More

 
Design by MA Technologies | Bloggerized by Computer Science Prevails