answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

List the 4 characteristics of annelids?

they eat many things they can be scavengers, blood suckers , eat bacteria and they can eat decaying matter.

Annelids are worms that get their name from the Latin word meaning "ring" because their bodies are generally segmented,or divided into rings.There are about 9,000 species in there main grouping,

The annelids include earthworms, polychaete worms, and leeches. All members of the group are to some extent segmented, in other words, made up of segments that are formed by subdivisions that partially transect the body cavity. Segmentation is also called metamerism. Segments each contain elements of such body systems as circulatory, nervous, and excretory tracts. Metamerism increases the efficiency of body movement by allowing the effect of muscle contraction to be extremely localized, and it makes possible the development of greater complexity in general body organization.

Besides being segmented, the body wall of annelids is characterized by being made up of both circular and longitudinal muscle fibers surrounded by a moist, acellular cuticle that is secreted by an epidermal epithelium. All annelids except leeches also have chitonous hair-like structures, called setae, projecting from their cuticle. Sometimes the setae are located on paddle-like appendages called parapodia.

Earthworms include mainly ground-living burrowing worms.They help to make the soil fit for plants to grow in.They make burrows which keep the top layer of soil loose and fresh,and swallow soil which passes through their bodies and returns again to the soil in a form which can be easily absorbed by the roots of plants(see earthworm).The group also includes a freshwater types such as bright red bloodworms that live in mud and are used to feed aquarium fish.

Marine worms are a smaller group that live mainly in the sea.Either they swim or shimmy around rocks and feed on small animals(see Ragworm),or else they in tubes and extend their tentacles to catch plankton,or filter small animals from mud or sand.The worm casts found low down on sandy Atlantic beaches are formed by the lugworm.

Leeches make up the third group of segmented worms.There are only 300 known species.All feed on blood.

What is Double Linked List?

The singly link list is nothing but the group of memory location in the computer memory (RAM) connected with each other using the pointer. The pointer is nothing but the location in the memory address space . The single data in list is called as nodes. Every nodes contain data and the pointer to the next data. Means one pointer in the node gives location of the next data. Suppose i have following data Memory location Data 1000 A 2000 B 3000 C since the my data A,B,C is stored in different memory locations , i can group it using singly linklist . Means my first node contain data A ,second B, & third C . The first node which contain data A will give the information about the next data or node (which is B) using the pointer. Means the pointer of A store the memory location of B (which is 2000).Like these the link will continued , at last node since there is no next node or data . Hence the pointer contain NULL value means there is (dead end).When computer encounters NULL it stop travelling through the list. & there is a special pointer called START pointer which gives the mem location of first node. In about example the node which contain data C contain NULL value in pointer field.

Binary search in array in c?

// answer in C-style pseudo-code

// all division should be rounded up

// search will return the index of the number found, or -1 if it was not found

// nums is the array of numbers we're searching through

// num is the specific number we want to find in nums

// current is the index we are currently inspecting

// start is the first index of nums (typically 0)

// end is the last index of nums (typically the length - 1)

// preconditions: nums must be sorted or function is nondeterministic

int search( int[] nums, int num, int current, int start, int end ) {

if( nums[current] end ) { // target not in list

return -1;

}else if( nums[current] > num ) { // search to the left

return search( nums, num, current - ((current - start)/2), start, current );

}else if( nums[current] < num ) { // search to the right

return search( nums, num, current + ((end - current)/2), current, end );

}

}

// convenience function to start the search

int search( int[] nums, int num ) {

return search(nums, num, (nums.length/2), 0, nums.length - 1);

}

What is Abstraction in C?

C is not an object-oriented programming language and therefore has no concept of abstract classes.

In C++, however, an abstract class is a base class that declares one or more pure-virtual functions. An abstract base class is also known as an abstract data type (ADT). Pure-virtual functions differ from virtual functions in that virtual functions are expected to be overridden (but needn't be) while a pure-virtual function must be overridden (but needn't be implemented by the ADT). Once overridden by a derived class, the function reverts to being a virtual function with respect to further derivatives. However, only classes that provide or inherit a complete implementation of the pure-virtual interface can be instantiated in their own right; those that do not are themselves abstract data types.

Which one is the best and efficient sort?

There are a great many sorts, Mergesort and Quicksort being among the most popular. These both have on the order of n*log n expected case runtime, and while Quicksort can get as bad as n^2, this is unlikely due to most implementations using a random pivot.

If you can make the assumption that ONLY NUMBERS will be sorted, you can use RadixSort, which is the fastest known sort for numbers.

As for how to sort in particular programming languages, consult your local API (in C++ it is in the STL's "algorithm" include file).

What is a property in OOP?

1.emphasis is on data rather than procedure

2.programs are divided into what are known as objects.

3.data structure are designed such that they charatersize the object.

4.data is hidden and cannot be accessed by external functions.

5.it follows bottom-up approach in program design

How do you declare variables in pseudo code?

In C, the most important rules are:

  • The declaration of a variable must precede its first usage.
  • When you declare a variable, its type must be already defined
  • When in a function, declarations can only be at the beginning of a block, before executable statements.
  • It should not start with any number.
  • Only underscore(_) symbol used in decalaration.

What is the use of learning computer languages?

There are system and application software. System software determine how to use computer hardware for instance operating systems while application software help users achieve a particular task like a word processor.

What is spanning tree in data structure?

A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

Binary digits 10101000 to decimal number?

101110102 = BA16

Its the same as any other base conversion. Iteratively divide the number by the desired base, using the rules of arithmetic for the original base, until the result is zero, and then record the remainders in reverse order. In the case of conversion from base 2 to base 16, you are dividing by 100002, which is the same as shifting to the right by four until you have nothing left.

101110102 divided by 100002 = 10112 remainder 10102

10112 divided by 100002 = 02 remainder 10112

Convert 10102 to A16 and convert 10112 to B16, and reverse write as BA16.

You can also do this by inspection, by simply grouping the original binary number, 10111010, into groups of four bits, 1011, 1010, and writing down the conversion, B, A.

What are Mistakes that cause a running program to produce incorrect results?

You could call it a bug in general but more specifically code with no syntax errors (i.e. it compiles and runs) but doesn't produce the output you expect would be called a semantic error.

Difference between high level and low level languages?

Low level languages bring you close to the machine, e.g. Assembly, or C. High level languages obfuscate more, so it makes life as a programmer easier. Consider:

Python, garbage collected.

C, not garbage collected.

Java, garbage collected.

And so forth.

C does has its uses, still: how could one make a hardware driver with a garbage collected language?

What is a universal pointer?

A universal pointer is a pointer variable that does not specify the type being pointed at. That is, it can be used to store any memory address regardless of the type of object actually stored at that address. It can be likened to a variable type, but you cannot dereference the memory address without providing some mechanism for determining the actual type stored at that memory address. Generally you would use a universal pointer when you don't actually care what type resides at the address, you are only interested in the address itself. But just as a typed pointer can point to 0 (or NULL), so can a universal pointer, which simply means it points at nothing at all.

Is PHP a general purpose programming language?

I defiantly wouldn't call it General Purpose but if you are fluent in PHP then there is pretty much nothing you can't do in PHP (provided you understand HTML, CSS and JavaScript). I've used PHP for items which I could have made via programs such as Access and Visual Studios but PHP is more first hand and easier for me. One good point to programs in PHP is because they are Server-side it should work for all Users.

Advantages and disadvantages of algorithm?

The advantages of algorithms are:

1.They are easy to understand

2.They are easy to implement

3.They are easy to modify

4.They are not dependent on any particular computer language.

How do you link a programming with other programming languages?

This is done via a call sequence. The syntax is different between languages but the process is about the same. The calling program issues a call to the called program and passes data items known as arguments. These arguments are used to instruct the called program on what actually to do. After the called program has completed its function it passes these arguments back to the calling program along with a return code to inform the calling program everything was ok, or not ok.

Draw a Do-until loop?

This is a loop function ... the loop will continue until something true happens. example: int i = 0; do { console.write(i + "< br />"); i++; }while(i < 100); This will loop 100 times.

In programming languages What are the advantages and disadvantages of having no types in a language?

There aren't any advantages. If there is an advantage it is only that it allows programmers to write sloppy code, which is never a good thing. Strongly typed languages make it abundantly clear exactly what type of data is physically stored in memory at all times whereas typeless languages are ambiguous, inefficient, and make it much more difficult to share data with other programs never mind passing data around the same program. It also makes it far too easy to assign different types to the same variable name.

Explain string handling in C with examples?

In this tutorial you will learn about Initializing Strings, Reading Strings from the terminal, Writing strings to screen, Arithmetic operations on characters, String operations (string.h), Strlen() function, strcat() function, strcmp function, strcmpi() function, strcpy() function, strlwr () function, strrev() function and strupr() function.

A string is a sequence of characters. Any sequence or set of characters defined within double quotation symbols is a constant string. In c it is required to do some meaningful operations on strings they are:

  • Reading string displaying strings
  • Combining or concatenating strings
  • Copying one string to another.
  • Comparing string & checking whether they are equal
  • Extraction of a portion of a string

Strings are stored in memory as ASCII codes of characters that make up the string appended with'\0'(ASCII value of null). Normally each character is stored in one byte, successive characters are stored in successive bytes.

Character

m

y

a

g

e

i

s

ASCII Code

77

121

32

97

103

10

32

105

115

Character

2

(

t

w

o

)

\0

ASCII Code

32

50

32

40

116

119

41

0

0

The last character is the null character having ASCII value zero.

Initializing Strings

Following the discussion on characters arrays, the initialization of a string must the following form which is simpler to one dimension array.

char month1[ ]={'j','a','n','u','a','r','y'};

Then the string month is initializing to January. This is perfectly valid but C offers a special way to initialize strings. The above string can be initialized char month1[]="January"; The characters of the string are enclosed within a part of double quotes. The compiler takes care of string enclosed within a pair of a double quotes. The compiler takes care of storing the ASCII codes of characters of the string in the memory and also stores the null terminator in the end.

/*String.c string variable*/

#include < stdio.h >

main()

{

char month[15];

printf ("Enter the string");

gets (month);

printf ("The string entered is %s", month);

}

In this example string is stored in the character variable month the string is displayed in the statement.

printf("The string entered is %s", month");

It is one dimension array. Each character occupies a byte. A null character (\0) that has the ASCII value 0 terminates the string. The figure shows the storage of string January in the memory recall that \0 specifies a single character whose ASCII value is zero.

J

A

N

U

A

R

Y

\0

Character string terminated by a null character '\0'.

A string variable is any valid C variable name & is always declared as an array. The general form of declaration of a string variable is

Char string_name[size];

The size determines the number of characters in the string name.

Example:

char month[10];

char address[100];

The size of the array should be one byte more than the actual space occupied by the string since the complier appends a null character at the end of the string.

Reading Strings from the terminal:

The function scanf with %s format specification is needed to read the character string from the terminal.

Example:

char address[15];

scanf("%s",address);

Scanf statement has a draw back it just terminates the statement as soon as it finds a blank space, suppose if we type the string new york then only the string new will be read and since there is a blank space after word "new" it will terminate the string.

Note that we can use the scanf without the ampersand symbol before the variable name.

In many applications it is required to process text by reading an entire line of text from the terminal.

The function getchar can be used repeatedly to read a sequence of successive single characters and store it in the array.

We cannot manipulate strings since C does not provide any operators for string. For instance we cannot assign one string to another directly.

For example:

String="xyz";

String1=string2;

Are not valid. To copy the chars in one string to another string we may do so on a character to character basis.

Writing strings to screen:

The printf statement along with format specifier %s to print strings on to the screen. The format %s can be used to display an array of characters that is terminated by the null character for example printf("%s",name); can be used to display the entire contents of the array name.

Arithmetic operations on characters:

We can also manipulate the characters as we manipulate numbers in c language. When ever the system encounters the character data it is automatically converted into a integer value by the system. We can represent a character as a interface by using the following method.

X='a';

Printf("%d\n",x);

Will display 97 on the screen. Arithmetic operations can also be performed on characters for example x='z'-1; is a valid statement. The ASCII value of 'z' is 122 the statement the therefore will assign 121 to variable x.

It is also possible to use character constants in relational expressions for example

ch>'a' && ch < = 'z' will check whether the character stored in variable ch is a lower case letter. A character digit can also be converted into its equivalent integer value suppose un the expression a=character-'1'; where a is defined as an integer variable & character contains value 8 then a= ASCII value of 8 ASCII value '1'=56-49=7.

We can also get the support of the c library function to converts a string of digits into their equivalent integer values the general format of the function in x=atoi(string) here x is an integer variable & string is a character array containing string of digits.

String operations (string.h)

C language recognizes that string is a different class of array by letting us input and output the array as a unit and are terminated by null character. C library supports a large number of string handling functions that can be used to array out many o f the string manipulations such as:

  • Length (number of characters in the string).
  • Concatentation (adding two are more strings)
  • Comparing two strings.
  • Substring (Extract substring from a given string)
  • Copy(copies one string over another)

To do all the operations described here it is essential to include string.h library header file in the program.

strlen() function:

This function counts and returns the number of characters in a string. The length does not include a null character.

Syntax n=strlen(string);

Where n is integer variable. Which receives the value of length of the string.

Example

length=strlen("Hollywood");

The function will assign number of characters 9 in the string to a integer variable length.

/*writr a c program to find the length of the string using strlen() function*/

#include < stdio.h >

include < string.h >

void main()

{

char name[100];

int length;

printf("Enter the string");

gets(name);

length=strlen(name);

printf("\nNumber of characters in the string is=%d",length);

}

strcat() function:

when you combine two strings, you add the characters of one string to the end of other string. This process is called concatenation. The strcat() function joins 2 strings together. It takes the following form

strcat(string1,string2)

string1 & string2 are character arrays. When the function strcat is executed string2 is appended to string1. the string at string2 remains unchanged.

Example

strcpy(string1,"sri");

strcpy(string2,"Bhagavan");

Printf("%s",strcat(string1,string2);

From the above program segment the value of string1 becomes sribhagavan. The string at str2 remains unchanged as bhagawan.

strcmp function:

In c you cannot directly compare the value of 2 strings in a condition like if(string1==string2)

Most libraries however contain the strcmp() function, which returns a zero if 2 strings are equal, or a non zero number if the strings are not the same. The syntax of strcmp() is given below:

Strcmp(string1,string2)

String1 & string2 may be string variables or string constants. String1, & string2 may be string variables or string constants some computers return a negative if the string1 is alphabetically less than the second and a positive number if the string is greater than the second.

Example:

strcmp("Newyork","Newyork") will return zero because 2 strings are equal.

strcmp("their","there") will return a 9 which is the numeric difference between ASCII 'i' and ASCII 'r'.

strcmp("The", "the") will return 32 which is the numeric difference between ASCII "T" & ASCII "t".

strcmpi() function

This function is same as strcmp() which compares 2 strings but not case sensitive.

Example

strcmpi("THE","the"); will return 0.

strcpy() function:

C does not allow you to assign the characters to a string directly as in the statement name="Robert";

Instead use the strcpy(0 function found in most compilers the syntax of the function is illustrated below.

strcpy(string1,string2);

Strcpy function assigns the contents of string2 to string1. string2 may be a character array variable or a string constant.

strcpy(Name,"Robert");

In the above example Robert is assigned to the string called name.

strlwr () function:

This function converts all characters in a string from uppercase to lowercase.

syntax

strlwr(string);

strrev() function:

This function reverses the characters in a string.

Syntax

strrev(string);

For ex strrev("program") reverses the characters in a string into "margrop".

strupr() function:

This function converts all characters in a string from lower case to uppercase.

Syntax

strupr(string);

For example strupr("exforsys") will convert the string to EXFORSYS.

/* Example program to use string functions*/

#include < stdio.h >

#include < string.h >

void main()

{

char s1[20],s2[20],s3[20];

int x,l1,l2,l3;

printf("Enter the strings");

scanf("%s%s",s1,s2);

x=strcmp(s1,s2);

if(x!=0)

{printf("\nStrings are not equal\n");

strcat(s1,s2);

}

else

printf("\nStrings are equal");

strcpy(s3,s1);

l1=strlen(s1);

l2=strlen(s2);

l3=strlen(s3);

printf("\ns1=%s\t length=%d characters\n",s1,l1);

printf("\ns2=%s\t length=%d characters\n",s2,l2);

printf("\ns3=%s\t length=%d characters\n",s3,l3);

}

What is the role of web server web programming?

Web programming is the coding of webpages. This includes different languages such as HTML, CSS, Javascript, PHP, and more. It is creating the code that will make a website work. These days it involves more Client side programming techniques using Jquery, Ajax etc. Lot of functionality is possible with JavaSCript libraries like that of Jquery.

How does a compiler convert high to low level language?

It depends on the compiler and operating system. A lot of compilers generate C(++) objects or code instead of assembly language. It seems to be easier for compiler developers to develop and support a C(++) platform instead of assembler.