Thursday, October 16, 2014


Programming Tools 


A programming tool or software development tool is a computer program that software developers use to create, debug, maintain, or otherwise support other programs and applications. The term usually refers to relatively simple programs, that can be combined together to accomplish a task, much as one might use multiple hand tools to fix a physical object. The ability to use a variety of tools productively is one hallmark of a skilled software engineer.

The most basic tools are a source code editor and a compiler or interpreter, which are used ubiquitously and continuously. Other tools are used more or less depending on the language, development methodology, and individual engineer, and are often used for a discrete task, like a debugger or profiler. Tools may be discrete programs, executed separately – often from the command line – or may be parts of a single large program, called an integrated development environment (IDE). In many cases, particularly for simpler use, simple ad hoc techniques are used instead of a tool, such as print debugging instead of using a debugger, manual timing (of overall program or section of code) instead of a profiler, or tracking bugs in a text file or spreadsheet instead of a bug tracking system.

The distinction between tools and applications is murky. For example, developers use simple databases (such as a file containing a list of important values) all the time as tools.[dubious – discuss] However a full-blown database is usually thought of as an application or software in its own right. For many years, computer-assisted software engineering (CASE) tools were sought after. Successful tools have proven elusive.[citation needed] In one sense, CASE tools emphasized design and architecture support, such as for UML. But the most successful of these tools are IDEs.

List of Programming Tools


RANDOM & COOL

  1. Tracelytics – Full stack application tracing. Cloud APM.
  2. TaskMissile – Makes getting client feedback fast, easy and exact.
  3. Kera – Activate more users with in-app tutorials.
  4. Flowdock – Team inbox with chat. Collaboration web app for technical teams.
  5. Modulus – Host, scale and gain insights into Node.js applications.
  6. Cloud Assault – Load testing without the aeronautics degree.
  7. Metricfire – Powerful application metrics made easy.
  8. Interstate – Turn potential tire-kickers into loyal users. Open project management.
  9. codenow – Developer collaboration. Easily share and discover code.
  10. Lingohub – Start localizing your software for better market adoption.
  11. TranslateKarate – Simple online translation and localization toolkit.
  12. Kickfolio – The simplest way to market your apps.
  13. Snippets – Don’t reinvent your code. Code snippets manager.

LEARN TO CODE

  1. Treehouse – Learn to design and develop for the web and iOS.
  2. Codecademy – Interactive, fun way to learn to code with friends.
  3. Code School – Where web professionals learn by doing.
  4. Udacity – Learn by solving challenging problems from world-renowned instructors.
  5. Coursera – Lots of computer science classes–for free.
  6. RubyMonk – Interactive ruby tutorials.
  7. Khan Academy – Free world-class education on a variety of programming topics.
  8. School of Webcraft – The peer-powered way to learn web development.
  9. Google Code University – Tutorials, introductions and courses.
  10. Orientation to Android Training – Official Android classes.
  11. phpacademy – Free PHP video tutorials.



SOURCE CONTROL


  1. GitHub – Social coding.
  2. Pixelapse – Visual version control. Get a time-lapse view of your designs.
  3. Bitbucket – Free source code hosting.
  4. Versions – Subversion Mac client.
  5. SourceTree – A free Mac client for Git and Mercurial version control systems.
  6. OFFSCALE – Get your database under control. DB version management.
  7. Tower – Git client for Mac.
DEVELOPMENT PLATFORMS
  1. Heroku – Cloud application platform. Deploy and scale powerful apps.
  2. Compilr – Develop and learn code all from the comfort of your web browser.
  3. Kinvey – Mobile cloud backend as a service.
  4. Firebase – A scalable real-time backend for your website.
  5. Cloud9 – Online IDE.
  6. Parse – The complete mobile app platform.
  7. CloudMine – The backend as a service for mobile and web apps.
  8. Koding – Browser-based IDE. A new way for developers to get work done.
  9. AppHarbor – .NET cloud platform as a service.
  10. dotCloud – Deploy, manage and scale any web app.
  11. BrainEngine – Cloud-based Force.com development platform.
  12. StackMob – Powering mobile applications.
  13. PHP Fog – Rock solid cloud platform for PHP.
  14. Backrest – Easy creation of Saas data backends.
  15. Codeanywhere – Online code editor.
  16. NeptuneIDE – Full-featured, cloud-based IDE for PHP.
  17. Fusegrid – ColdFusion in the cloud.
  18. Cloud IDE – Code and deploy in the cloud.
  19. FriendCode – A social network revolving around an online code editor.
  20. ToolsCloud – Development environment in the cloud.
CONTINUOUS INTEGRATION & DEPLOYMENT

  1. TestPilot – Continuous software delivery and integration, simplified.
  2. CircleCi – Continuous integration for web apps. Easy, fast, automated testing.
  3. Railsonfire – Continuous integration and deployment for Ruby.
  4. Wercker – Continuous deployment made easy.
  5. hostedci – Hosted continuous integration for iOS and Mac.


BUG TRACKING, FEEDBACK & MONITORING

  1. Crashlytics – Powerful and lightweight crash reporting for iOS and Android.
  2. Usersnap – A screenshot paints a thousand words.
  3. Crittercism – Stop worrying and start building. Mobile app performance monitoring.
  4. Rollbar – Fix errors faster. Realtime error reporting and tracking.
  5. New Relic – Web application performance management (APM).
  6. Exceptional – Tracks errors in web apps and reports them in realtime.
  7. BugSense – Mobile app insights and crash reporting.
  8. Bugzilla – Server software to help you manage software development.
  9. Bugify – Simple PHP issue tracking for small teams.
  10. BugHerd – Simple bug tracker. Capture feedback effortlessly.
  11. Snowy Evening – Bug and issue tracking with Github integration.

APIS

  1. Twilio – APIs for voice, VoIP and text messaging.
  2. Veritable – The predictive database.
  3. Stripe – Payments for developers.
  4. Factual – Structured data APIs.
  5. Filepicker.io – Simplify user content handling.
  6. PubNub – Blazingly fast cloud-hosted messaging service for real-time apps.
  7. Mailgun – Email for developers. Send, receive, track and store email.
  8. Context.IO – The missing email API. Leverage email data in applications.
  9. Semantics3 – APIs for product data.
  10. Qubulus – Indoor positioning service provider.
  11. Sent.ly – SMS HTTP API using your own Android phone.
  12. Cloudeo – Live video and voice for developers.
  13. Embedly – Convert standard URLs into embedded videos, images and more.
  14. Scaled Recognition – Make images actionable.

    GAME DEVELOPMENT

  1. Viximo – Global social game distribution platform.
  2. XNA – Game development tools from Microsoft.
  3. Scoreloop – Cross-platform mobile gaming SDK. Virtual currency and more.
  4. Yodo1 – Mobilize your games in China.
  5. Game Closure – Offer a JavaScript game SDK. Runs on mobile/tablet devices.
  6. scoreoid – The ultimate server platform for game developers.
  7. FTW – Universal gaming identity. Sync saves, scores, friends across devices.
  8. Storybricks – Create your own MMO experience.

MOBILE DEVELOPMENT

  1. Codiqa – Insanely fast mobile prototyping.
  2. AppCooker – Advanced iOS mockup generator for mobile applications.
  3. Apptentive – Easy in-app feedback for iPhone application developers.
  4. AppCod.es – iOS app store SEO and marketing.
  5. Chupa Mobile – The marketplace for mobile app components.
  6. Appboy – User engagement, CRM, analytics and more.
  7. Flurry – Analytics, traffic acquisition and monetization.
  8. Octopod – Mobile development platform.
  9. Little Eye – Battery profiler tool for Android apps.

MISCELLANEOUS

  1. Binpress – Source-code marketplace: components, packages, classes, scripts.
  2. UploadCare – Handles uploads and storage so you can focus on other things.
  3. Eden – PHP library designed for rapid prototyping and less code.
  4. appbackr – Crowdfunding marketplace for mobile apps.
  5. Modkit – Programming for any thing.
  6. TechScratch – Focus on what you are good at and get help with the rest.
  7. Storyteller – Build great websites with content from anywhere.
  8. Feed.Us – CMS for web apps.
  9. Hosted Graphite – Simple, hosted graphite as a service.
  10. Divshot – The interface builder for web apps. Rapid HTML5 prototyping.
  11. CSS Piffle – No more photo editing software for web design.
  12. FlyWithMonkey – Tools for HTML5 app developers.
  13. Expanz – Build better business apps. One server, any device.
  14. Zapstreak – Airplay for Android.
  15. RepoDrop – Private Git repository hosting.
  16. CodeWars – Train and test your skills or battle other developers.
  17. Architexa – Understand/document complex Java code bases in Eclipse.
  18. UserMetrics – Analytics to help you understand how users use your software.
  19. Setapp – Share and discover insanely great tools.
  20. Coder Bounty – Place bounties on code issues.
  21. Last5 – Productivity and time tracking for developers.
  22. XtGem – Visual mobile site building.
  23. uTest – End to end application testing.
Follow link below for more resources
http://dailytekk.com/2012/09/24/100-terrific-tools-for-coders-developers/

Posted on Thursday, October 16, 2014 by Unknown

No comments



Information Processing Language



Information Processing Language (IPL) is a programming language created by Allen Newell, Cliff Shaw, and Herbert A. Simon at RAND Corporation and the Carnegie Institute of Technology at about 1956. Newell had the job of language specifier-application programmer, Shaw was the system programmer, and Simon took the job of application programmer-user.

The language includes features intended to help with programs that perform simple problem solving actions such as lists, dynamic memory allocation, data types, recursion, functions as arguments, generators, and cooperative multitasking. IPL invented the concept of list processing, albeit in an assembly-language style.

Sample Programming Problems

JAVA:

Top Ten Errors Java Programmers Make

(How to spot them. How to fix/prevent them.)

By David Reilly
Whether you program regularly in Java, and know it like the back of your hand, or whether you're new to the language or a casual programmer, you'll make mistakes. It's natural, it's human, and guess what? You'll more than likely make the same mistakes that others do, over and over again. Here's my top ten list of errors that we all seem to make at one time or another,  how to spot them, and how to fix them.

10. Accessing non-static member variables from static methods (such as main)

Many programmers, particularly when first introduced to Java, have problems with accessing member variables from their main method. The method signature for main is marked static - meaning that we don't need to create an instance of the class to invoke the main method. For example, a Java Virtual Machine (JVM) could call the class MyApplication like this :-
MyApplication.main ( command_line_args );
This means, however, that there isn't an instance of MyApplication - it doesn't have any member variables to access! Take for example the following application, which will generate a compiler error message.
public class StaticDemo
{
        public String my_member_variable = "somedata";
        public static void main (String args[])
        {
  // Access a non-static member from static method
                System.out.println ("This generates a compiler error" +
   my_member_variable );
        }
}
If you want to access its member variables from a non-static method (like main), you must create an instance of the object. Here's a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.
public class NonStaticDemo
{
        public String my_member_variable = "somedata";

        public static void main (String args[])
        {
                NonStaticDemo demo = new NonStaticDemo();

  // Access member variable of demo
                System.out.println ("This WON'T generate an error" +
                        demo.my_member_variable );
        }
}

9. Mistyping the name of a method when overriding

Overriding allows programmers to replace a method's implementation with new code. Overriding is a handy feature, and most OO programmers make heavy use of it. If you use the AWT 1.1 event handling model, you'll often override listener implementations to provide custom functionality. One easy trap to fall into with overriding, is to mistype the method name. If you mistype the name, you're no longer overriding a method - you're creating an entirely new method, but with the same parameter and return type.
public class MyWindowListener extends WindowAdapter {
 // This should be WindowClosed
 public void WindowClose(WindowEvent e) {
  // Exit when user closes window
  System.exit(0);
 }
});
Compilers won't pick up on this one, and the problem can be quite frustrating to detect. In the past, I've looked at a method, believed that it was being called, and taken ages to spot the problem. The symptom of this error will be that your code isn't being called, or you think the method has skipped over its code. The only way to ever be certain is to add a println statement, to record a message in a log file, or to use good trace debugger (like Visual J++ or Borland JBuilder) and step through line by line. If your method still isn't being called, then it's likely you've mistyped the name.

8. Comparison assignment (  = rather than == )

This is an easy error to make. If you're used other languages before, such as Pascal, you'll realize just how poor a choice this was by the language's designers. In Pascal, for example, we use the := operator for assignment, and leave = for comparison. This looks like a throwback to C/C++, from which Java draws its roots.
Fortunately, even if you don't spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : "Can't convert xxx to boolean", where xxx is a Java type that you're assigning instead of comparing.

7. Comparing two objects ( == instead of .equals)

When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object.
Here's the correct way to compare two strings.
String abc = "abc"; String def = "def";

// Bad way
if ( (abc + def) == "abcdef" )
{
    ......
}
// Good way
if ( (abc + def).equals("abcdef") )
{
   .....
}

6. Confusion over passing by value, and passing by reference

This can be a frustrating problem to diagnose, because when you look at the code, you might be sure that its passing by reference, but find that its actually being passed by value. Java uses both, so you need to understand when you're passing by value, and when you're passing by reference.
When you pass a primitive data type, such as a char, int, float, or double, to a function then you are passing by value. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only. Once the function finishes, and control is returned to the returning function, the "real" variable will be untouched, and no changes will have been saved. If you need to modify a primitive data type, make it a return value for a function, or wrap it inside an object.
When you pass a Java object, such as an array, a vector, or a string, to a function then you are passing by reference. Yes - a String is actually an object, not a primitive data type.  So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object's member variables will be permanent - which can be either good or bad, depending on whether this was what you intended.
On a side note, since String contains no methods to modify its contents, you might as well be passing by value.

5. Writing blank exception handlers

I know it's very tempting to write blank exception handlers, and to just ignore errors. But if you run into problems, and haven't written any error messages, it becomes almost impossible to find out the cause of the error. Even the simplest exception handler can be of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY type of exception, and print out the message. You don't need to write a custom handler for every exception (though this is still good programming practice). Don't ever leave it blank, or you won't know what's happening.
For example
public static void main(String args[])
{
    try {
 // Your code goes here..
    }
    catch (Exception e)
    {
 System.out.println ("Err - " + e );
    }
}

4. Forgetting that Java is zero-indexed

If you've come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element's index is actually 0. Confused? Let's look at a quick example.
// Create an array of three strings
String[] strArray = new String[3];

// First element's index is actually 0
strArray[0] = "First string";

// Second element's index is actually 1
strArray[1] = "Second string";

// Final element's index is actually 2
strArray[2] = "Third and final string";
In this example, we have an array of three strings, but to access elements of the array we actually subtract one. Now, if we were to try and access strArray[3], we'd be accessing the fourth element. This will case an ArrayOutOfBoundsException to be thrown - the most obvious sign of forgetting the zero-indexing rule.
Other areas where zero-indexing can get you into trouble is with strings. Suppose you wanted to get a character at a particular offset within a string. Using the String.charAt(int) function you can look this information up - but under Java, the String class is also zero-indexed. That means than the first character is at offset 0, and second at offset 1. You can run into some very frustrating problems unless you are aware of this - particularly if you write applications with heavy string processing. You can be working on the wrong character, and also throw exceptions at run-time. Just like the ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds of a String will cause a StringIndexOutOfBoundsException to be thrown, as demonstrated by this example.
public class StrDemo
{
 public static void main (String args[])
 {
        String abc = "abc";

        System.out.println ("Char at offset 0 : " + abc.charAt(0) );
        System.out.println ("Char at offset 1 : " + abc.charAt(1) );
        System.out.println ("Char at offset 2 : " + abc.charAt(2) );

 // This line should throw a StringIndexOutOfBoundsException
        System.out.println ("Char at offset 3 : " + abc.charAt(3) );
 }
}
Note too, that zero-indexing doesn't just apply to arrays, or to Strings. Other parts of Java are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar classes start their months with 0, but days start normally with 1. This problem is demonstrated by the following application.
import java.util.Date;
import java.util.Calendar;

public class ZeroIndexedDate
{
        public static void main (String args[])
        {
                // Get today's date
                Date today = new Date();
 
  // Print return value of getMonth
  System.out.println ("Date.getMonth() returns : " +
    today.getMonth());

  // Get today's date using a Calendar
  Calendar rightNow = Calendar.getInstance();

  // Print return value of get ( Calendar.MONTH )
  System.out.println ("Calendar.get (month) returns : " +
   rightNow.get ( Calendar.MONTH ));
        }
}
Zero-indexing is only a problem if you don't realize that its occurring. If you think you're running into a problem, always consult your API documentation.

3. Preventing concurrent access to shared variables by threads

When writing multi-threaded applications, many programmers (myself included) often cut corners, and leave their applications and applets vulnerable to thread conflicts. When two or more threads access the same data concurrently, there exists the possibility (and Murphy's law holding, the probability) that two threads will access or modify the same data at the same time. Don't be fooled into thinking that such problems won't occur on single-threaded processors. While accessing some data (performing a read), your thread may be suspended, and another thread scheduled. It writes its data, which is then overwritten when the first thread makes its changes.
Such problems are not just limited to multi-threaded applications or applets. If you write Java APIs, or JavaBeans, then your code may not be thread-safe. Even if you never write a single application that uses threads, people that use your code WILL. For the sanity of others, if not yourself, you should always take precautions to prevent concurrent access to shared data.
How can this problem be solved? The simplest method is to make your variables private (but you do that already,  right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.
public class MyCounter
{
 private int count = 0; // count starts at zero

 public synchronized void setCount(int amount)
 { 
  count = amount;
 }
 
 public synchronized int getCount()
 {
  return count;
 }
}

2. Capitalization errors

This is one of the most frequent errors that we all make. It's so simple to do, and sometimes one can look at an uncapitalized variable or method and still not spot the problem. I myself have often been puzzled by these errors, because I recognize that the method or variable does exist, but don't spot the lack of capitalization.
While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :-
  • all methods and member variables in the Java API begin with lowercase letters
  • all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()
If you use this pattern for all of your member variables and classes, and then make a conscious effort to get it right, you can gradually reduce the number of mistakes you'll make. It may take a while, but it can save some serious head scratching in the future.

(drum roll)

And the number one error that Java programmers make !!!!!


1. Null pointers!

Null pointers are one of the most common errors that Java programmers make. Compilers can't check this one for you - it will only surface at runtime, and if you don't discover it, your users certainly will.
When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven't initialized an object, or you haven't checked the return value of a function.
Many functions return null to indicate an error condition - but unless you check your return values, you'll never know what's happening. Since the cause is an error condition, normal testing may not pick it up - which means that your users will end up discovering the problem for you. If the API function indicates that null may be returned, be sure to check this before using the object reference!
Another cause is where your initialization has been sloppy, or where it is conditional. For example, examine the following code, and see if you can spot the problem.
public static void main(String args[])
{
 // Accept up to 3 parameters
 String[] list = new String[3];

 int index = 0;

 while ( (index < args.length) && ( index < 3 ) )
 {
  list[index++] = args[index];
 }

 // Check all the parameters 
 for (int i = 0; i < list.length; i++)
 {
  if (list[i].equals "-help")
  {
   // .........
  }
  else
  if (list[i].equals "-cp")
  {
   // .........
  }
  // else .....
 } 
}
This code (while a contrived example), shows a common mistake. Under some circumstances, where the user enters three or more parameters, the code will run fine. If no parameters are entered, you'll get a NullPointerException at runtime. Sometimes your variables (the array of strings) will be initialized, and other times they won't. One easy solution is to check BEFORE you attempt to access a variable in an array that it is not equal to null.

Summary

These errors represent but some of the many that we all make. Though it is impossible to completely eliminate errors from the coding process, with care and practice you can avoid repeating the same ones. Rest assured, however, that all Java programmers encounter the same sorts of problems. It's comforting to know, that while you work late into the night tracking down an error, someone, somewhere, sometime, will make the same mistake!

Follow the link below for more reference
http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html

Elements of the C Language


The C Character Set

C uses the uppercase English alphabets A to Z, the lowercase letters a to z, the digits 0 to 9, and certain special characters as building blocks to form basic program elements viz. constants, variables, operators, expressions and statements.


Identifiers and Keywords

Identifiers are names given to various items in the program, such as variables, functions and arrays. An identifier consists of letters and digits, in any order, except that the first character must be a letter. Both upper and lowercase letters are permitted. Upper and lowercase letters are however not interchangeable (i.e., an uppercase letter is not equivalent to the corresponding lowercase letter). The underscore character (_) can also be included, and it is treated as a letter. Keywords like ifelseintfloat, etc., have special meaning and they cannot be used as identifier names.
The following are examples of valid identifier names: A, ab123, velocity, stud_name, circumference, Average, TOTAL

Data Types and Sizes

There are only few basic data types in C. These are listed in the table below:
Data typeDescriptionSizeRange
charsingle character1 byte0 - 255
intinteger number4 bytes-2147483648 to 2147483647
floatsingle precision floating point number (number containing fraction & or an exponent)4 bytes3.4E-38 to 3.4E+38
doubledouble precision floating point number8 bytes1.7E-308 to 1.7E+308
The list of data types can be increased by using the data type qualifiers such as - short, long, and unsigned. For example, an integer quantity can be defined as long, short, signed or unsigned integer. The memory requirement of an integer data varies depending on the compilers used. The qualified basic data types and their sizes are shown in table below.

Data typeSizeRange
short int2 bytes-32768 to 32767
long int4 bytes-2147483648 to 2147483647
unsigned short int2 bytes0 to 65535
unsigned int4 bytes0 to 4294967295
unsigned long int4 bytes0 to 4294967295
long double (extended precision)8 bytes1.7E-308 to1.7E+308

Note that the qualifier unsigned can be used along with the qualifiers short and long. The unsigned int occupies the same memory space as an ordinary int but differs on the possible content of the left-most bit. In case of an ordinary int it is reserved for sign (sign bit), but all the bits in an unsigned int are used for determining the magnitude of the integer quantity.
The char type is used to represent individual characters, and occupies one byte of memory. Each character has an equivalent integer representation (since each stores internally the ASCII value for the corresponding character). So charvariables or constants can be used as integer data in arithmetic expressions.
The data objects to be manipulated in a C program are classified as variables and constants. The type of all the variables to be used in the program must be declared before they can be used. The operations that can be performed on the data objects are specified by a set of operators. Expressions used in a program combine the variables, constants and operators to produce new values.


Constants

The constants in C can be classified into four categories namely integer constants, floating point constants, character constants and string constants.
A character constant is written as for example - 'A' (always enclosed in single quotes).
Examples of string constants are - "Jamshedpur", "A", etc. Note that a string constant is always enclosed within double quotes.
A normal integer constant is written as 1234.
long int is recognized by the presence of L (uppercase or lowercase) at the end of the constant, e.g. 2748723L.
The suffix u or U signifies the int to be an unsigned one.
The UL or ul at the end indicates the int quantity is of unsigned long type
Floating point constants contain a decimal point (167.903) or an exponent (1e-2) or both. Their type is double unless suffixed. The suffix of f or F indicates float; 1 or L indicates long double.
C also supports octal and hexadecimal data. The value of an integer data can be specified in either octal or hexadecimal form. A hexadecimal constant must begin with 0x or 0X, a leading 0 indicates the octal representation. Octal and hexadecimal constants may also be followed by U to indicate unsigned or L to determine long.
The number 0x2A5 is an example of a hexadecimal number. Internally the number is represented by the following bit patterns,
0x2A5 = 0010 1010 0101 = 2 * 162 + 10 * 161 + 5 * 160 = 677
        ---- ---- ----
          2    A   5
The number 677 is the decimal equivalent of the number 0x2A5.

Example of an octal number can be 0347. To represent each digit of an octal number in the form of binary, we need maximum of three bits since the last digit in the octal number system is 7.
0347 = 011 100 111 = 3 * 82 + 4 * 81 + 7 * 80 = 231 (in decimal)
       --- --- ---
        3   4   7

In numeric constants e.g. integer or floating point constants, blanks and any non-numeric characters cannot be included. The range of these constants will be limited by the maximum and minimum bounds (usually machine dependent).
A character constant is a single character enclosed in apostrophes such as 'A'. Such a constant is internally treated as an integer e.g. 'A' corresponds to the integer 65 (also known as its ASCII value). The ASCII value of 'a' (small) is 97. Hence character constants can participate in a numeric calculation just like any other integer, moreover, they also can be used for comparing with other character constants. Some character constants are of non-printing type which can be expressed by a combination of a back-slash (\) and a character. They are known as escape sequences. Each of them represents a single character even though they are written in terms of two or more characters.
Commonly used escape sequences are listed below:
CharacterEscape SequenceASCII Value
Bell\a007
Backspace\b008
Null\0000
Newline\n010
Carriage return\r013
Vertical tab\v011
Horizontal tab\t009
Form feed\f012

Exercises:
Identify which of the following numerical values are valid constants. If a constant is valid, specify whether it is integer or real. Also, specify the base for each valid integer constant.
(a)0.7b)39,634c)16.3e18d)16.3e-18
(e)123456789f)123456789lg)0.3E+0.4h)0.3E4
(i)0412j)018ACFk)0xABCDEl)0x97e334

Which of the following are valid character constants?
(a)'a'(b)'/n'(c)'F'(d)'\0492'
(e)'x'(f)'\\'(g)'\0'(h)'\n'
(i)'\b'(j)'\x-y-'

Which of the following are valid string constants?
(a)'9:25 A.M.'
(b)"Blue, Green and Indigo"
(c)"Name:
(d)"Section 4 (Next \'d')"
(e)"1.6e-18"
(f)"JAMSHEDPUR BR 831 001"
(g)"The Station master announced, "Down Geetanjali express is running late"

Symbolic Constants

Constants which play crucial roles in a program can be made more meaningful by assigning them appropriate names to make the program more readable and easily changeable. These constants are called symbolic constants and are defined as follows.
Examples:
#define PI 3.141593
#define TRUE 1
#define PROMPT "Enter Your Name :"
PI, TRUE and PROMPT are symbolic constants, so they do not appear in the declaration. #define is a preprocessor directive like #include. The salient feature of a symbolic constant is that the value assigned to a symbolic constant cannot be changed (unlike variables) subsequently in the program.
Exercise:
Write an appropriate definition for each of the following symbolic constants, as it would appear within a C program:
ConstantText
(a)AMOUNT-75
(b)EPSILON0.00001
(c)BIGIN{
END}
(d)FIRSTNAME"Sanjay"
(e)ENDOLIN'\n'
(f)COST"Rs. 125.75"

Variable Declaration in C

In a C program all variables must be declared before they are used. A declaration determines the type of the data, and contains a list of one or more variables having the same type.
Example:
intcount, index;
charflag, text[80];
short inta,b;
unsigned intp;
doubled;

A variable can be initialized with values at the time of declaration.
Example:
intc = 5;
charreply = 'Y';
doubled = 4.64386237445675;
charstate[] = "ANDHRA PRADESH";
floateps = 1.0e-5;

Exercises:
Write appropriate declaration for each group of variables and character array (strings):
(a)Integer variables: x, y
(b)Integer variable: count
Unsigned integer variable: employee no
Double-precision variables: net sales, tax, profit
(c)Character variables: first name, last name
(d)70 element character array: message

Write appropriate declaration and assign the given initial values to each group of variables and array:
(a)Floating-point variables: x = -9.5, y = 1.0004
Integer variables: a = 734, b = 49, c = -63
Character variables: c1 = 'a', c2 = '$'
(b)Double-precision variable: d1 = 3.94 * 10-12, d2 = -9.89 * 107
Integer variable: i = 437 (octal), h = 6AFF (hexadecimal)
(c)Long integer variable: large = 123456789
Double-precision variables: d = 0.6666666
Character variable: eol = newline character
(d)One-dimensional character array: message = "OVERFLOW"



Posted on Thursday, October 16, 2014 by Unknown

No comments