Programming and Data Types in C programming

In C programming we have different kinds of data types in C language and this is in continuation with previous discussion.

Integers signed and unsigned:

Sample code for syntax for unsigned inter is :

nsigned int num_students ;

With this declaration, the range of permissible integer values (for a 16-bit OS) will shift from the range -32768 to +32767 to the range 0 to 65535. Thus, declaring an integer as unsigned almost doubles the size of the largest possible value that it can otherwise take.

It happens because on declaring the integer as unsigned, the left-most bit is now free and is not used to store the sign of the number.

Unsigned integer still occupies two bytes.

It can be declared as : unsigned int i ; unsigned i ;

There also exists a short unsigned int and a long unsigned int. By default a short int is a signed short int and a long int is a signed long int in C programming.

Chars, signed and unsigned

Signed and unsigned chars, both occupying one byte each, but having different ranges. Consider the statement

char ch = 'A' ;

Here what gets stored in ch is the binary equivalent of the ASCII value of ‘A’ (i.e. binary of 65). And if 65’s binary can be stored, then -54’s binary can also be stored (in a signed char).

A signed char is same as an ordinary char and has a range from -128 to +127; whereas, an unsigned char has a range from 0 to 255.

Floats and Doubles

A float occupies four bytes in memory and can range from -3.4e38 to +3.4e38. If this is insufficient then C offers a double data type that occupies 8 bytes in memory and has a range from -1.7e308 to +1.7e308.

A variable of type double can be declared as,

double a, population ;

If the situation demands usage of real numbers that lie even beyond the range offered by double data type, then there exists a long double that can range from -1.7e4932 to +1.7e4932.

A long double occupies 10 bytes in memory in c programming and it is used rarely.

Related Posts

BDC

OOPS ABAPALE

INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM


Programming and Data Types

Primary data types of programming could be of three varieties—char, int, and float. We can derive many data types from these three types.

A char could be an unsigned char or a signed char. Or an int could be a short int or a long int.

Integers, long and short We had seen earlier that the range of an Integer constant depends upon the compiler.

For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767.
For a 32-bit compiler the range would be –2147483648 to +2147483647.

16-bit compiler means that when it compiles a C program it generates machine language code that is targeted towards working on a 16-bit microprocessor like Intel 8086/8088.

A 32-bit compiler like VC++ generates machine language code that is targeted towards a 32-bit microprocessor like Intel Pentium.
A program compiled using Turbo C would not work on 32-bit processor. It would run successfully but at that time the 32-bit processor would work as if it were a 16-bit processor.

This happens because a 32-bit processor provides support for programs compiled using 16-bit compilers. If this backward compatibility support is not provided the 16-bit program would not run on it.

Out of the two or four bytes used to store an integer, the highest bit (16th/32nd bit) is used to store the sign of the integer. This bit is 1 if the number is negative, and 0 if the number is positive.

C offers a variation of the integer data type that provides what are called short and long integer values.

Short and long integers would usually occupy two and four bytes respectively. Each compiler can decide appropriate sizes depending on the operating system and hardware for which it is being written, subject to the following rules:
  • shorts are at least 2 bytes big
  • longs are at least 4 bytes big
  • shorts are never bigger than ints
  • ints are never bigger than longs
long variables which hold long integers are declared using the keyword long.

Long integers cause the program to run a bit slower, but the range of values that we can use is expanded tremendously. The value of a long integer typically can vary from -2147483648 to +2147483647.

Integers that need less space in memory and thus help speed up program execution.

Short integer variables are declared as,

short int j ;
short int height ;

C allows the abbreviation of short int to short and of long int to long. So the declarations made above can be written as,

long i ;
long abc ;
short j ;
short height ;

OTHER PROGRAMMING COURSES:

INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions

Programming C Functions Coding

Programming with C language and using Functions is done in our previous discussions. Now we are going to deal with advanced concepts of using functions in c programming.

Function Declaration and Prototypes :

Any C function by default returns an int value. Whenever a call is made to a function, the compiler assumes that this function would return a value of the type int. If a function should return a value other than an int, then it is necessary to explicitly mention so in the calling function as well as in the called function.

The following program segment illustrates how to make square( ) capable of returning a float value.

main( )
{
float square ( float ) ;
float a, b ;
printf ( "\nEnter any number " ) ;
scanf ( "%f", &a ) ;
b = square ( a ) ;
printf ( "\nSquare of %f is %f", a, b ) ;
}
float square ( float x )
{
float y ;
y = x * x ;
return ( y ) ;
}

And here is the output

Enter any number 1.5 Square of 1.5 is 2.250000
Enter any number 2.5 Square of 2.5 is 6.250000

The function square( ) must be declared in main( ) as float square ( float ) ;

This statement is often called the prototype declaration of the square( ) function. What it means is square( ) is a function that receives a float and returns a float.

Call by Value and Call by Reference

Whenever a function is called and passed something to it we have always passed the ‘values’ of variables to the called function. Such function calls are called ‘calls by value’. On calling a function we are passing values of variables to it.

Call by reference is done with pointers in C programming.

Pointer Notation Consider the declaration, int i = 3 ;

This declaration tells the C compiler to

1. Reserve space in memory to hold the integer value.
2.Associate the name i with this memory location.
3. Store the value 3 at this location.

The computer has selected memory location 65524 as the place to store the value 3. The location number 65524 is not a number to be relied upon, because some other time the computer may choose a different location for storing the value 3. The important point is, i’s address in memory is a number.

TO print this address number

main( )
{
int i = 3 ;
printf ( "\nAddress of i = %u", &i ) ;
printf ( "\nValue of i = %d", i ) ;
}

The output of the above program would be: Address of i = 65524 Value of i = 3

‘&’ used in this statement is C’s ‘address of’ operator. The expression &i returns the address of the variable i, which in this case happens to be 65524. Since 65524 represents an address, there is no question of a sign being associated with it.

Hence it is printed out using %u, which is a format specifier for printing an unsigned integer.

OTHER PROGRAMMING COURSES:


Programming with C and C Sharp
INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions


Programming Functions in C part two

Previously we had discussed regarding the usage functions in C programming and this is a continuation for it.

Use of Functions in C programming

Writing functions avoids rewriting the same code over and over.

Explanation : Suppose we have a section of code in your program that calculates area of a triangle. If later in the program we want to calculate the area of a different triangle, we nee d not write the entire code once again and we would prefer to jump to a ‘section of code’ that calculates area and then jump back to the place from where you left off. This section of code is nothing but a function.

Using functions it becomes easier to write programs and keep track of what they are doing. If the operation of a program can be divided into separate activities, and each activity placed in a different function, then each could be written and checked more or less independently. Separating the code into modular functions also makes the program easier to design and understand.

We have to break a program into small units and write functions for each of isolated sub divisions. We can even write functions that are called only once and these functions perform some logically isolated task.

How to Pass Values between Functions ?

The mechanism used to convey information to the function is the ‘argument’. We use the arguments in the printf( ) and scanf( ) functions; the format string and the list of variables used inside the parentheses in these functions are arguments. The arguments are sometimes also called ‘parameters’.

Sending and receiving values between functions Example

Consider the following program where, in main( ) we receive the values of a, b and c through the keyboard and then output the sum of a, b and c.

The calculation of sum is done in a different function called calsum( ). If sum is to be calculated in calsum( ) and values of a, b and c are received in main( ), then we must pass on these values to calsum( ), and once calsum( ) calculates the sum we must return it from calsum( ) back to main( ).

main( )

{

int a, b, c, sum ;

printf ( "\nEnter any three numbers " ) ;

scanf ( "%d %d %d", &a, &b, &c ) ;

sum = calsum ( a, b, c ) ;

printf ( "\nSum = %d", sum ) ;

}

calsum ( x, y, z )

int x, y, z ;

{

int d ;

d = x + y + z ;

return ( d ) ;

}


And here is the output... Enter any three numbers 10 20 30 Sum = 60

Explanation

1.In this program, from the function main( ) the values of a, b and c are passed on to the function calsum( ), by making a call to the function calsum( ) and mentioning a, b and c in the parentheses: sum = calsum ( a, b, c ) ; In the calsum( ) function these values get collected in three variables x, y and z:

calsum ( x, y, z )

int x, y, z ;

2.The variables a, b and c are called ‘actual arguments’, whereas the variables x, y and z are called ‘formal arguments’. Any number of arguments can be passed to a function being called. The type, order and number of the actual and formal arguments must always be same.

3.The return statement serves two purposes:
1. On executing the return statement it immediately transfers the control back to the calling program.
2. It returns the value present in the parentheses after return, to th3e calling program.

4.There is no restriction on the number of return statements that may be present in a function. Also, the return statement need not always be present at the end of the called function.

5.Whenever the control returns from a function some value is definitely returned. If a meaningful value is returned then it should be accepted in the calling program by equating the called function to some variable.

6.If we want that a called function should not return any value, we must mention so by using the keyword void .

void display( )
{
printf ( "\nHeads I win..." ) ;
printf ( "\nTails you lose" ) ;

7.A function can return only one value at a time.

OTHER PROGRAMMING COURSES:
INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions


Software Testing Process Overview

The testing and development processes are in a feedback loop. The testing process feeds identified failures back into the development process.

Failure reports provide a set of symptoms that a developer uses to identify the exact location of a fault or error. The development process feeds new and revised designs and implementations into the testing process.

Testing of development products will help identify defective test cases when testers determine that "failures" result from problems with test cases themselves or the drivers that execute them, and not the software under test.

The form and content of development products affect the testing process. When developers select methods and tools, they establish constraints on the testing process. The testing perspective must be considered, preferably by the presence of professional testers, when development methods and tools are selected.

The form and quality of a requirements specification also affects the process. Product requirements comprise the source of test cases in system and acceptance testing. System testers should participate in the gathering and validation of the requirements in order to have a sufficient understanding of them to assess risks and testability.

Three-step approach for each type of testing performed on a project.

  1. Analysis:The product to be tested is examined to identify any special features that must receive particular attention and to determine the test cases that should be constructed. We will present a number of analysis techniques.

  2. Construction: In this phase the artifacts that are needed for testing are created. The test cases identified during analysis are translated into programming languages and scripting languages, or they are entered in a tool-specific language.

  3. Execution and Evaluation: This is the most visible and often the only recognized part of the test effort; however, it is also typically the quickest part of the test effort. The test cases that were identified during analysis and then constructed are executed. The results are examined to determine whether the software passed the test suite or failed it.

Test Cases and Test Suites

The basic component of testing is a test case. Test case is a pair (input, expected result), in which input is a description of an input to the software under test and expected result is a description of the output that the software should exhibit for the associated input.

Inputs and expected results are not necessarily simple data values, such as strings or integer values, but they can be complex.

Inputs often incorporate system state information as well as user commands and data values to be processed. Expected result includes not only perceivable things, such as printed reports, audible sounds, or changes in a display screen, but changes to the software system itself.

A test case execution is a running of the software that provides the inputs specified in the test case and observes the results and compares them to those specified by the test case. If the actual result varies from the expected result, then a failure has been detected and we say the software under test "fails the test case."

If the actual result is the expected result for a test case, then we say the software "passes the test case."

Test cases are organized into a test suite. Most test suites have some sort of organization based on the kinds of test cases. If software passes all the test cases in a test suite, then we say that the software "passes the test suite."


Software testing other interesting topics:

SOFTWARE TESTING AND EFFECTING FACTORS
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT



Java Arrays Programming for beginners

Java arrays are objects.

In arrays we can store multiple variables of same type that are referred by a common name.
An array is always an object,even if the array is declared to hold object references or primitives .

In array variables are placed in indexed order.These variables are called elements of an array. So in java arrays we can access the elements or values through the index.Every element in an array is just a variable.

Now we have to know how to declare the array ,creation of array and accessing the elements from array.

Declaration of arrays are in two forms:

form1: type arrayname[]; Type followed by name of the array,followed by Square bracket .

ex: int abc[];

form2: type[] arrayname; Type followed by bracket,followed by name of the array.

ex: float[] abc;

form2 is the recommended way,because name is clearly separated from the type.

At the time of declaration, we should not enter the size of an array.violation leads to compile time exception.

for example int[5] a; it gives compile time exception.

After declaration of an array ,we can't put any other data type except the declared array type.
but implicitly promoted data types we can use, means less than the declared array type.for
example int[] x, the allowed data types are byte,short,char,int.

After creation of java arrays,once you fix the size of an array,we can't change the size of an array.But you can change an individual array element. If it is need to change the array size frequently while the program is running then we should go for another concept, known as Arraylist.

In java arrays are work differently than they do in c,c++.

creation of java arrays:

After declaring an array,we need to put it into memory.arrays must be declared in the memory before they are used.

Java arrays are creating only using new keyword .

array type[] array name=new array type[size];

Ex: int[] x=new int[50];

Array type is int , the allowed data types are byte/short/char/int.
This statement sets up an array that can hold 50 integers means 0 to 49 ,not 1 to 50 .

At the time of creation we must specify the size, otherwise compile time exception occurs.Even
we can give zero number also.but we can't specify the size with negative number we will get Run time Exception(RTE).we have to use integer to specify the size violation leads to compile time exception.

for example:

int[] x = new int[55]; It is OK

int[] x = new int[0]; It is OK

int[] x = new int[]; it gives compile time exception.

int[] x = new int[-5]; RTE, Negative Array Size Exception

int[] x = new int[9.5]; CTE,Possible loss of precission

we can write declaration and creation separately like this,

int[] x;

x=new int[8];

If you want to find the number of elements of an array, use arrayName.length.

For example :

for (int i = 0; i < style="font-weight: bold; color: rgb(51, 51, 255);">

Initialization of Arrays:

Once an array is created,all the elements will assign with default values based on declared data type.

For example : for int default value is zero.
for string default value is null.
for Boolean default value is false.

java arrays are created starting with a subscript of zero and ends with a value one lessthan the size declared.

In java arrays the declaration,creation and initialization in a single line is possible.
for this syntax, specify the declaration and size,later we can give the values at run time.

int a[];

a=new int[5];

a[0]=10;
a[1]=20;
a[2]=30;
a[3]=40;
a[4]=50;

Instead of above declaration,creation and initialization we can write like this,

int[] a={10,20,30,40,50};

But for this syntax, at the time of declaration we must know the array size and initialization values,can't give the values at run time.

It is possible to convert an array object to another array,but the array types must same.

int[] x={10,20,30};

int[] y;

y=x;

Accessing array elements:

int[] a=new int[5];

a[5]=60 it leads RTE, "Array Index Out Of Bound Exception".

a[4.0]=50;

If you are accessing array element with unmatched data type then it gives compile time exception, "Incorrect Syntax".

a[-4]=50 ; it leads RTE,"Array Index Out Of Bound Exception".

a[2.5] =50; it leads CTE, "Possible Loss of precision"

Either Float/Double/Long data type indexes should not use to accessing the array elements,violation leads to compile time exception.

Array element assignment is possible , when the class object is the subtype of element type.That means if an array is declared as object reference array ,we are allowed to assign the objects of either declared type or it's child classes.


ex 1: Number[] a = new Integer[5]; // Length 10, element type Integer

Double f = new Double(3.14); // Type Double, class Double

Integer i = new Integer(115); // Integer, class Integer

Number n = i; // Type Number, class Integer

a[0] = i; // OK, Integer is subtype of Integer

a[1] = n; // OK, Integer is subtype of Integer

a[2] = f; // No, Double not subtype of Integer

The above program successfully compile,but at run time a[2] =f throws "Array Store Exception", because the class of the object bound to f is not a subtype of a's element type (that is, Integer).

ex 2: String[] s = new String[5];

s[0] = "A"; it is OK

s[1]= new Integer[12]; CTE

Integer is not a child class of String,but expected thing is String or child class of String class .

ex 3: Object ob = new Object[8];

ob[0] = "X";

ob[1]= new Thread();

ob[2] = new Exception();

ob[3] = new Number();

ob[4] = new Integer(15);

the above program compile and run successfully, because all are subclasses of declared array type.
How do we Assignment of Array variables :

In general, we are allowed to place int variable in the place of double variable, because implicitly int will be promoted to double.but it is not possible to place int array in the place of double array. Like this , a character element can be assigned in the place of int element.But the char array can't be assigned in the place of int array.It gives compile time exception.


example : int[] a= {1,3,6,8};

char[] c={'a','b','c','d','e'};

int[] b = c; CTE, Incompatible Type


In the case of Object arrays ,we are allowed to place child class arrays in the place of parent class array.

example 1: wheels[] w= new wheels[8];
CLASSES AND OBJECTS IN JAVA

JAVA PROGRAMMING ENVIRONMENT

JAVA EXECUTION

JAVA CONSTRUCTORS

FIELD DECLARATIONS IN CLASS OF JAVA

EXCEPTIONS IN JAVA

EXCEPTIONS IN JAVA PART TWO

VARIABLE PARAMETERS IN JAVA

COMMENTS TYPES AND VARIABLES

JAVA JDBC AND ODBC

INTERFACE IN JAVA

OPERATORS IN JAVA



Programming Development Process Overview

A process is a continuous series of activities that convey you to an end.Main activities in a software development process are
  1. analysis— which focuses on understanding the problem and defining the requirements for the software portions of a system

  2. design— which focuses on solving the problem in software

  3. implementation— which focuses on translating the design into executable code

  4. testing— which focuses on ensuring that inputs produce the desired results as specified by the requirements

Maintenance begins after deployment with a focus on bug repairs and enhancements. Maintenance usually involves further analysis, design, implementation, and testing. Among the testing activities during maintenance is regression testing, which ensures that successful test results after changes are the same as those before changes.

Under an incremental development process, a system is developed as a sequence of increments. An increment is a deliverable, including models, documentation, and code, which provides some of the functionality required for the system.

The products developed in one increment feed into the development of the next increment. Successive increments add (and sometimes change) system functionality. The final increment delivers a deployable system that meets all requirements. Increments can be developed in sequence or one or more can be developed concurrently.

To build each increment, developers analyze, design, code, and test as needed. They typically have to perform these activities repeatedly in building an increment because they find errors in previous work. As development progresses, they gain new insights into the problem and the solution. We prefer to acknowledge this iterative aspect of incremental development and make it part of the process.

In planning each increment, we include explicit steps for repeating various activities. Among these are steps for systematically reviewing current models, identifying errors based on experiences in later tasks, and modifying the models (or code) that have already been produced—not just those that will be produced in the future.


Object-oriented development is particularly well suited to evolutionary development because object-oriented analysis, design, and implementation entail the successive refinement of a single model. This is the case both within an increment and among increments.

In object-oriented analysis, we understand a problem by modeling it in terms of objects and classes of objects, their relationships and responsibilities. In object-oriented design, we solve the problem by manipulating those same objects and relationships identified in analysis and introducing solution-specific classes, objects, relationships, and responsibilities.

Implementation is straightforward from a well-specified set of design products. Thus, the entire development process involves a refinement of a model. Design products are primarily an extension of analysis products and implementation products are coded expressions of design products. The products of one increment are extended and refined in the next increment.

The incremental development of products requires the incremental testing of those products. Products can change from increment to increment in both planned and unplanned ways. Test suites must change in concert. Regression tests must be run between increments and within iterations to ensure that changes do not adversely affect correctly working code.

A process in which work on one increment overlaps work on another adds to the complexity of development and testing. Coordination is required to sequence the development of interacting increments so that objects that are associated with, but assigned to different increments, can be tested in a timely fashion.

Software testing other interesting topics:

Programming c language introduction
CLASSES AND OBJECTS IN JAVA

JAVA PROGRAMMING ENVIRONMENT

JAVA EXECUTION

JAVA CONSTRUCTORS

FIELD DECLARATIONS IN CLASS OF JAVA

EXCEPTIONS IN JAVA

EXCEPTIONS IN JAVA PART TWO

VARIABLE PARAMETERS IN JAVA

COMMENTS TYPES AND VARIABLES

JAVA JDBC AND ODBC

INTERFACE IN JAVA

OPERATORS IN JAVA

Programming C Language Introduction

C programming language is said to be a middle level language because it combines the best elements of high-level languages with the control and flexibility of assembly language .

As a middle-level language, C allows the manipulation of bits, bytes, and addresses the basic elements with which the computer functions and C code is also very portable.Portability means that it is easy to adapt software written for one type of computer or operating system to another type.

All high level programming languages support the concept of data types. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common data types are integer, character, and floating-point. Although C has several built in data types, it is not a strongly typed language, as are Pascal and Ada. C permits almost all type conversions.

C specifies almost no run time error checking. For example, no check is performed to ensure that array boundaries are not overrun. and these types of checks are the responsibility of the programmer.

C does not demand strict type compatibility between a parameter and an argument.C allows an argument to be of any type so long as it can be reasonably converted into the type of the parameter and C provides all of the automatic conversions to accomplish this.

C allows the direct manipulation of bits, bytes, words, and pointers. This makes it well suited for system-level programming, where these operations are common.

C has only a small number of keywords, which are the commands that make up the C language. For example, C89 defined 32 keywords, and C99 adds only 5 more. High-level languages typically have many more keywords.

C is a structured language. The distinguishing feature of a structured language is compartmentalization of code and data. This is the ability of a language to section off and hide from the rest of the program all information and instructions necessary to perform a specific task. One way that you achieve compartmentalization is by using subroutines that employ local (temporary) variables.

By using local variables, you can write subroutines so that the events that occur within them cause no side effects in other parts of the program. This capability makes it very easy for your C programs to share sections of code. If you develop compartmentalized functions, you need to know only what a function does, not how it does it.

Structured languages typically support several loop constructs, such as while, do-while, and for. In a structured language, the use of goto is either prohibited or discouraged and is not the common form of program control . A structured language allows you to place statements anywhere on a line and does not require a strict field concept.

In C, functions are the building blocks in which all program activity occurs. They allow you to define and code individually the separate tasks in a program, thus allowing your programs to be modular.

After you have created a function, you can rely on it to work properly in various situations without creating side effects in other parts of the program. Being able to create stand alone functions is extremely important in larger projects where one programmer's code must not accidentally affect another's.

Related posts

Software testing prospective
INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions

SoftwareTesting Perspective

The testing perspective is a way of looking at any development product and questioning its validity. The person examining work products from this perspective utilizes a thorough investigation of the software and all its representations to identify faults. The search for faults is guided by both systematic thinking and intuitive insights.

It is a perspective that makes reviews and inspections just as powerful a tool as execution-based testing. A review will almost never find something that is missing—that is, a review typically only seeks to validate what exists and does not systematically search to determine if all things that should be in the software actually are in it.

The testing perspective requires that a piece of software demonstrate that it not only performs according to its specification, but performs only to that specification. Thus, a product is tested to determine that it will do what it is supposed to do, and it is also tested to ensure that it does not do what it is not supposed to do.

Software testing is typically accomplished by a combination of inspections, reviews, and test executions. The purpose of these activities is to observe failures.

An inspection is an examination of software based on a checklist of typical problems. Most items on a checklist are based on programming language semantics and/or coding conventions—for example, ensuring that each program variable is initialized before its first use and that pointers or references have been set to reasonable values before they are used. Modern compilers for object-oriented programming languages can detect many of the problems called out on traditional inspection checklists.

A review is an examination of software with the purpose of finding errors and faults even before the software is executed. Reviews are made in the context of the system being developed and have a deeper interest in the software than do inspections.

A review delves into the meaning of each part of a program and whether it is appropriate for meeting some or all of the application's requirements. A review is intended to uncover errors such as missed or misunderstood requirements or faults in a program's logic. Some reviews examine programming details such as whether variable names are well chosen and whether algorithms are as efficient as they could be.

Test execution is testing software in the context of a running program. Through executing the software, a tester tries to determine whether it has the required behavior by giving the program some input and verifying that the resulting output is correct. Among the challenges to testers are identifying suitable inputs, determining correct outputs, and determining how to observe the outputs.

The testing perspective is

Skeptical: Wants proof of quality.
Objective: Makes no assumptions.
Thorough: Doesn't miss important areas.
Systematic: Searches are reproducible.

Functions in c programming
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT

Function in C Programming

A computer program (except for the simplest one) cannot handle all the tasks by itself. Instead, it requests other program like entities—called ‘functions’ in C—to get its tasks done.

A function is a self-contained block of statements that perform a coherent task of some kind.

Example

main( )

{

message( ) ;

printf ( "\nCry!" ) ;

}

message( )

{ printf ( "\nSmile" ) ;

}

And here’s the output...

Smile...

Cry

Here, main( ) itself is a function and through it we are calling the function message( ). Main( ) ‘calls’ the function message( ) and it mean that the control passes to the function message( ).

The activity of main( ) is temporarily suspended; it falls asleep while the message( ) function wakes up and goes to work. When the message( ) function runs out of statements to execute, the control returns to main( ), which comes to life again and begins executing its code at the exact point where it left off. Thus, main( ) becomes the ‘calling’ function, whereas message( ) becomes the ‘called’ function.

Important points about Function

Any C program contains at least one function.

If a program contains only one function, it must be main( ).

If a C program contains more than one function, then one (and only one) of these functions must be main( ), because program execution always begins with main( ).

There is no limit on the number of functions that might be present in a C program.

Each function in a program is called in the sequence specified by the function calls in main( ).

After each function has done its thing, control returns to main( ).

When main( ) runs out of function calls, the program ends. The program execution always begins with main( ). Except for this all C functions enjoy a state of perfect equality. No precedence, no priorities.

One function can call another function it has already called but has in the meantime left temporarily in order to call a third function which will sometime later call the function that has called it.

Other C programming Related topics are

Switch statement in c programming
INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions

Switch in C Programming

The control statement that allows us to make a decision from the number of choices is called a switch, or more correctly a switch-case-default, since these three keywords go together to make up the control statement.

The syntax for this is


switch ( integer expression )
{
case constant 1 :
do this ;
case constant 2 :
do this ;
case constant 3 :
do this ;
default : do this ;
}

The integer expression following the keyword switch is any C expression that will yield an integer value. It could be an integer constant like 1, 2 or 3, or an expression that evaluates to an integer. The keyword case is followed by an integer or a character constant. Each constant in each case must be different from all the others. The “do this” lines in the above form of switch represent any valid C statement.

How it functions ?

First, the integer expression following the keyword switch is evaluated. The value it gives is then matched, one by one, against the constant values that follow the case statements. When a match is found, the program executes the statements following that case, and all subsequent case and default statements as well. If no match is found with any of the case statements, only the statements following the default are executed.

Example with only Switch

main( )
{
int i = 2 ;
switch ( i )
{
case 1 :
printf ( "I am in case 1 \n" ) ;
case 2 : printf ( "I am in case 2 \n" ) ;
case 3 : printf ( "I am in case 3 \n" ) ;
default : printf ( "I am in default \n" ) ;
}
}

The output of this program would be:

I am in case 2
I am in case 3
I am in default

The switch executes the case where a match is found and all the subsequent cases and the default as well.

If you want that only case 2 should get executed, it is upto you to get out of the switch then and there by using a break statement.There is no need for a break statement after the default, since the control comes out of the switch anyway.

Example with Break statement and Switch

main( )
{
int i = 2 ;
switch ( i )
{
case 1 : printf ( "I am in case 1 \n" ) ;
break ;
case 2 : printf ( "I am in case 2 \n" ) ;
break ;
case 3 : printf ( "I am in case 3 \n" ) ;
break ;
default : printf ( "I am in default \n" ) ;
}
}

The output of this program would be:

I am in case 2

Other C programming Related topics are

INTRODUCTION TO C PROGRAMMING

Programming with C an introduction part two

Data types for C programming


C PROGRAMMING CHARACTER SET

CONSTANTS IN C PROGRAMMING

PROGRAMMING C VARIABLES

C PROGRAM INSTRUCTIONS

COMPILATION AND EXECUTION OF C PROGRAM

C PROGRAMMING RULES PART ONE

C PROGRAMMING RULES PART TWO

COMPILATION AND EXECUTION OF C PROGRAM

INSTRUCTIONS TO WRITE C PROGRAM

ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM

CONVERSION OF CONSTANTS IN C PROGRAM

PRIORITY OF AR THEMATIC OPERATIONS IN C

OPERATORS ASSOCIATIVITY IN C

IF STATEMENT

MULTIPLE STATEMENTS IN IF

IF AND ELSE

NESTED IF AND ELSE


BREAK

CONTINUE AND DO WHILE IN C LANGUAGE

SWITCH IN C PROGRAMMING

FUNCTIONS IN C PROGRAMMING


Functions and usage in C part two

Coding in C functions

Software testing spiral model

Software Testing Spiral Model

The spiral model is based on the need to iterate. It contains as many iterations as are necessary to bring a product to fruition. Each iteration requires that the participants plan, define their life-cycle, prototype, analyze risks, write requirements, build models, detailed designs, code, unit, and system tests, and install.

Advantages :

  1. It is flexible and allows for multiple iterations.
  2. It employs prototyping extensively.
  3. It allows for the coexistence of other models .
  4. It makes risk evaluation explicit.
  5. It acknowledges the need to validate requirements and design.
  6. It was originally designed with a particular need to accommodate COTS, and is therefore more amenable to software reuse.
Disadvantages :
  1. It is less easy to allocate phases to groups and responsibilities than other models.
  2. It requires that staff are well-versed in software engineering.
  3. It requires much team self-discipline in the capture of emerging requirements.
  4. It does not acknowledge the need to have test input from the start of the project.
  5. It allocates particular phases to requirements definition and high- and low-level design.
  6. It doesn’t make the baselines explicit.
  7. It doesn’t allow for process decomposition
  8. Much prototype code may eventually be used in the final version.
  9. It must be very tool-supported to work or it will either decay or become enmeshed in the
    bureaucracy it was intended to minimize.
Implications :
  1. • The status of emerging requirements must be constantly reviewed.
  2. • The team is committed to validating both the requirements and the design.
  3. • Any use of prototype code in the production version will require much more rigorous unit testing than is normal.
Software testing stage gate process model
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT


Software Testing Stage Gate Process Model

Cooper’s stage gate model is a variant of the water fall. It splits the life-cycle into six stages separated by “gates.” Each gate is a decision point. It differs from the waterfall in that the activities in each stage may be simultaneous.

The different stages of this model are explained below.

Discovery stage: a product manager thinks of a new idea for a product.
Idea screen: the idea is presented to potential stakeholders for their buy-in.

Scoping stage: the market for the product is assessed and key features are identified.
Second screen: the idea is re-presented to potential stakeholders for their buy-in, but with more-rigorous requirements and other information.

The business case stage: in which the product, market, organization, project management and environment, competitors, budget, RoI, and legal issues are defined.
Go to development is the moment at which the organization can commit to the large budget required for development.

The development stage includes requirements refining, design, code, and build. Its output is a product ready for beta testing.
Go to testing is the moment when the testing budget and the marketing and operational plans must be committed to. It is based on the continued existence of a market opportunity.

Testing is system and acceptance testing at internal and friendly customer sites. It generates a
product fit for launch.
Go to launch: is the moment when marketing and training plans become operative and we can launch the product.

Problems with this model are

1• Half the activities are oriented to the development of a business case. Since this is likely to occupy between 5–10% of the total manpower, more detail on the other 90–95% of the manpower’s activities would be useful.

2• No allowance has been made for the requirements changes.

3• Testing is relegated to the penultimate activity. The possibility that the requirements are deeply flawed will thus tend to be hidden. Similarly the testers will not learn how to use the product until too late causing considerable delay. The tests they prepare may thus need much rewriting.

4• That a decision can be taken on the marketability of a product which has yet to enter beta testing requires enormous faith in the ability of developers. The amount of iteration between the development and testing groups is not shown, and the delays can be considerable.

To overcome all these problems

1• Focus on the earliest access to the requirements as they are assembled.
2• Get early access to prototype versions so they can prepare tests.
3• Provide review and possibly modeling feedback to management such that inconsistent or missing requirements be identified asap.

Related :

Software testing water fall model
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT


Waterfall Model

The waterfall model consists of 5 phases:

1. Requirements (in which the customer requirements are written).
2. Design (in which the high and low-level design documents are written).
3. Code (in which the code is written and (hopefully) unit tested).
4. System test (which is where we come in).
5. Installation and cut over.


Disadvantages of waterfall model
  1. Bureaucrats believe such phases are finite and cannot be iterated upon.
  2. It doesn’t allow for parallel activities such as prototyping or the development of user interface.
  3. specifications or for safety-critical system issues such as the development of a safety case.
  4. It makes no mention of contract preparation, project management, reviews, or audits.
  5. It implies that system testing starts only when coding is finished.
  6. It says nothing about software reuse.
Advantages of waterfall model
  1. Each phase generates some baseline deliverable.
  2. It is well-known.
  3. It has been used for many years.
  4. It is very adaptable.
  5. Each process can be decomposed into others.
  6. You can add any process you want.
Here
  1. Each phase may have to be repeated (as requirements change, as prototypes evolve).
  2. It needs to be seen in parallel with a number of other life-cycles with which it must stay synchronized.
  3. It can be modified for prototypes and software reuse.
  4. Testing input begins at least as early as requirements definition .
  5. Any change to requirements, design, or code must be manually reflected through all levels of documentation to ensure all documents are consistent . then it is perfectly usable.
Related :

Managing risk in software testing
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT


Managing Risk in Software Project

Plan how to manage the project’s risks: The Risk Management Plan documents how risks will be managed. It is a subset of the project plan and is written before the project begins.
Identify risks: One simple approach is to get representatives of all the affected groups in a room and have a workshop. Circulate a provisional list to excite attention. Get their ideas down onto large sheets of paper you can blu-tack to the walls. Circulate a revised list after the meeting.

Repeat the process half-way through the project, and identify how many have not occurred, and how many unforeseen ones had occurred.

Risk Alerts are the triggers used to identify when a risk is imminent. Typical test-related triggers are:
  1. Reduction in the number of lines of code per bug found.
  2. Finding an unacceptably-high number of priority-1 and -2 bugs in a build.
  3. Finding an unacceptably-high number of bugs in a component.
  4. Late arrival of signed-off specifications for use as a baseline.
  5. Failure of performance tests to achieve targets.
  6. Growing code complexity.
  7. Growing code turmoil.
Monitoring such risks is easier when an alerting system is in place. The existence of a risk log allows the test team to identify priorities and provides a good basis for deciding the mix of tests to be planned.

Risks can be grouped by sources and by kinds and a risk kind is for example that something doesn’t work, that it works too late, too slowly, at the wrong time, or that it has unintended side-effects. These groups are sensitive to risk drivers in that a driver can change a whole group of risks.

The failure of the project to use an appropriate development method was having a knock-on effect throughout the whole of the project. It was a source of risks and a major driver. Here are some more are
  1. Use of an inappropriate (unrelated to the risk) method or process.
  2. Lack of customer involvement:Apart from the obvious need for a sufficient set of requirements
  3. There is the need for feedback to users of (fragments of) the proposed solution.
  4. Dissimilarity to previous projects: If “we’ve never done anything as (big/complex/different) as this before” is an issue, then beware.
  5. Project complexity: This is relative to the experience of an organization. What might exhaust some organizations will be run-of-the-mill to others.
  6. • Requirements volatility:If such changes aren’t allowed for, the project will soon deteriorate.(56)
Related :

How do we test a software ?
SOFTWARE QUALITY ASSURANCE AND CONTROL

SOFTWARE QUALITY AND COST ASPECT

STABLE PROCESS OF SOFTWARE TESTING

STABLE PROCESS OF SOFTWARE TESTING PART TWO


DEFECTS IN SOFTWARE TESTING

REDUCTION OF DEFECTS IN SOFTWARE TESTING

SOFTWARE TESTING AND EFFECTING FACTORS

SCOPE OF SOFTWARE TESTING

TESTING LIFE CYCLE PART ONE

TESTING LIFE CYCLE PART TWO

TESTING LIFE CYCLE PART THREE

SOFTWARE TESTING AND CONSTRAINTS WITH IN IT