answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What are some examples of procedural and non procedural programming?

Procedural programming is classic programming where the program language is used to tell the computer EXACTLY what do do - step by step. Examples are Assembler, Fortran, Cobol, C, etc etc. Very detailed, very difficult and time consuming to write, but very efficient from the computers point of view. NON-procedural programming is where you tell the computer what you want, and it figures out how to get it. Non/P programming is often used for database manipulations, like SQL, Visual Basic, etc etc. A SQL command like "Select name, address, city, state, zip order by zip" is non procedural. That one line replaces dozens, or hundred of lines, that would be needed to do the same thing in Cobol or C to get data out of a database.

Which programming language is used in windows?

It would probably be easier to list those that don't have an implementation but even those intended for non-Windows systems can be used with emulation software. However, all of the most popular languages have Windows implementations, including C, C++, Java, Python, Ruby, Pascal, Cobol and so on.

How can we surf internet?

just go to google or yahoo and search for something-- anything random will work- and click on the links. all surfing the internet is is browsing it. you can't literally surf on it with a surfboard. have fun 'surfing' the web!

Why thread is called lightweight task?

A thread is similar to a separate process, in that it can do stuff (process) independently of other threads. But it is lightweight, since the operating system doesn't have to give it its own memory space, since it shares memory with the other threads in the process.

[Note: a thread or LWP shares the same instruction memory space as other threads of that process, but has its own datamemory space]

How do I delete a corrupt file or directory in Microsoft Vista Windows OS?

If vista doesn't allow you to delete corruptes files (folders), you have to boot your PC up in Safe Mode. In Safe Mode with administrative rights you can delete any file (directory/folder) which you like to.

To boot your system up in Safe Mode if have to press F8 just right after BIOS finishes to test the system.

What is palindrome in programming?

A palindrome is any data sequence that reads exactly the same forwards as it does backwards.

To test a sequence to see if it is a palindrome or not, we begin by pointing to the elements at the beginning and end of the sequence. So long as the pointers do not meet or cross each other and both refer to the same value, we advance the pointers one element towards the middle of the sequence. If the pointers meet or cross each other, the sequence is a palindrome, otherwise it is not.

The following tests a vector of some type T:

template<typename T>

bool is_palindrome (const std::vector<T>& v) {

size_t x {0}, y {v.size()-1);

while (x<y && v[x]==v[y]) ++x, --y;

return x<=y;

}

Example usages:

std::vector<double> d {1.2, 3.4, 5.6, 3.4, 1.2}; // is a palindrome std::vector<int> i {1, 2, 3, 4, 5}; // is not a palindrome

std::vector<char> c {'m', 'a', 'd', 'a', 'm'}; // is a palindrome

assert (is_palindrome (d) == true);

assert (is_palindrome (i) == false);

assert (is_palindrome (c) == true);

When testing strings, we typically strip out all non-alpha-numeric characters and use a case-insensitive comparison. To achieve this, we simply convert the string to a lower-case character array and invoke the previous function:

bool is_palindrome (const std::string& str) {

std::vector<char> v {};

for (size_t i=0; i<str.size(); ++i)

if (str[i]>='0' && str[i]<='9') v.push_back (str[i]); // push digit characters

else if (str[i]>='a' && str[i]<='z') v.push_back (str[i]); // push lowercase characters

else if (str[i]>='A' && str[i]<='Z') v.push_back (str[i]+32); // push uppercase as lowercase characters

return is_palindrome (v);

}

Example usage:

std::string s {"Madam, I'm Adam!");

assert (is_palindrome (s) == true);

What does BASIC as in the programming language stand for?

Beginners All-purpose Symbolic Instruction Code > B.A.S.I.C. > Basic.

John Kemeny and Thomas Kurtz developed the first version at Dartmouth University in 1964. It was originally created to allow non technical people to run a computer because, at that time, you couldn't operate a computer without programming it first. Basic was developed to give a more simple programming structure that was close to plain English so that anyone could use a computer. It has come a very long way since then becoming a very robust language.

Why is it necessary to overload an operator?

The assignment is done explicit without internal operation.

Subject to the programming language, explicit assignment operators are needed wherever implicit ones are insufficient. Implicit assignment is typically implemented as a flat copy, while explicit overloading of the assignment operator allows for any other suitable behavior.

Consider this example in pseudocode similar to C++:

class Demo {

int* valuepointer;

...

};

Demo a, b;

...

b = a;

Assigning a to b using implicit assignment means that a.valuepointer and b.valuepointer share the same value. Both a and b can change the pointed-to value, and the either will "see" the change.

This is the required behavior in some cases, but often, you'd want to explicitly assign a to b such that each has its own pointer, accessing different copies of the value. This behavior would require an explicit assignment operator (or copy constructor).

What is a computer program?

A computer program is a list of instructions written in a special language that the computer understands. It tells the computer which operations to perform and in what sequence to perform them. Programs can be written in various "languages", such as C/C++, Java, Assembly, etc., which will then be converted to machine language by one of two pieces of software, a compiler or an interpreter.

A computer program is a sequence of one or more instructions and their operands written in machine code that a computer can understand. Programs are usually written in a high-level language that is easier for humans to understand, which the computer itself can then compile (using another program) into machine code that it understands. Once a program is compiled it can then be executed. Machine code can also be hand-crafted using a low-level language known as Assembler. Every machine has its own version of Assembler, specific to its particular architecture. By contrast, Disassembly is the process of reverse-engineering machine code in order to reproduce the original Assembler instructions. However, the resulting code will lack the comments and symbolic code that were used by the original author of the program (all of which were stripped out during assembly).

Some computer programs are not compiled into machine code. These programs are designed to be run within another program (which is itself machine coded). For instance, Java programs are compiled into byte code suitable for the Java virtual machine (JVM). The JVM is a machine code program that understands the byte code instructions and translates them into suitable machine code. This is known as interpretation, thus Java is an interpretive high-level language.

As a result of this interpretation, Java programs are very much slower than their equivalent machine coded programs. By contrast, C++ is compiled to native machine code and is therefore many times faster than an equivalent Java program. However, C++ programs must be compiled separately for each supported platform, whereas Java will run on any platform that runs a JVM implementation, without any need to recompile.

Is it easy to get job as a computer programmer?

it depends if you are in it to make money or as a hobby.

if you are in it to make money, then you need to be at a 3+ years of ACTUAL experience programming (either in college or as a trainee and self paced ) to get hired.

nobody will hire you if you don't have any programs that you made, what if you cannot make a program to work?

so, it is hard to make 1 dollar as a fresh programmer. trust me, i am a programmer. today's program will be obsolete in 6 month.

what are you going to learn anyway? it takes 3 to 4 years to get your computer science degree and by the time you graduate you are already behind in computer programming. going technical school is the same.

are you going to make Microsoft applications? or websites? or mac apps, or iPhone (dream on, it takes years to make a dollar from an iPhone app if you start learning today). if websites, are you going to make JSP? php, HTML, aspx, perl....after you decide what you are going to program in you will need to decide what database system to use. using excel (not even an RDBMS-relational database management system) or Microsoft access will be a joke compared to other people in the market. today you need at least (in 2009) to program in SQL server, Oracle or similar. it takes years to become an acceptable SQL query writer (stored procedures, etc) to a level where you meet the criteria of a money making programmer.

oh and i almost forgot, it takes you 2 years to become a programmer but unless you are programming using a technique called "object oriented", then good luck finding an employer.

Object oriented programming is what is taught to computer science people in their 3 to 4 years in college/university, then they need 2 to 3 years to learn a programming language appropriately with practical experience and then they will find a medium entry level job... until the recessions happened. now you are competing with people who have years of experience and know 10 times more programming techniques, languages, workarounds, shortcuts, methods, properties, classes, ... than you, who are waiting in line to work at entry level salary.

so it is hard to become a professional (=money earning) programmer. but as a hobby, if you don't bet your future on it, then it is as hard as you decide it to be. go for it.

Write a c program to arrange the digits of a number in ascending order?

#include

#include

void main()

{

int n ,i,j,temp,a[12]; //in a[] specify some number .

printf("Enter the no of inputs:");

scanf("%d", &n);

printf("Enter %d integer numbers :", n);

for(i=0;i

{

scanf("%d",&a[i]);

}

for (i=0;i

for(j=i+1;j

{

if(a[i]>a[j])

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

printf("THE %d NUMBERS SORTED IN ASCENDING ORDER ARE :\n", n);

for(i=0;i

{

printf("%d ",a[i]);

}

getch();

}

Here is another version of the program. While the previous one is obviously simpler, this one is a good program to master the basics of pointer and array problems which might plague them at the beginning.

#include

#include

int a[100],i,j,k,n;

void sort(int *a,int n);

void swap(int *x,int *y);

main()

{

printf("How many numbers? ");

scanf("%d",&n);

printf("Enter the %d numbers separated from each other by a blank space: \n\n",n);

for (i=0;i

scanf("%d",&a[i]);

sort(a,n);

printf("\nThe numbers in descending order is: \n");

for (k=0;k

printf("\n%d",a[k]);

printf("\n\n");

}

void sort(int *a,int n)

{

int p=n-1;

while (p>=0)

{

for(i=0;i<=(p-1);++i)

{

if (a[i]<=a[i+1])

swap(&a[i],&a[i+1]);

else

continue;

}

--p;

}

}

void swap(int *x,int *y)

{

int t;

t=*x;

*x=*y;

*y=t;

}

Find out prime number between 1 to 100 in java?

public class v3

{

public static void main()

{

int b=0,i;

for(i=1;i<=100;i++)

{

for(j=1;j<=i;)

{

if(i%j==0)

{

b=j;

System.out.print(b+" ");

b=0;

}

}

}

}

}

What are Principles of object oriented programming language?

Java is an object oriented programming language. The main concepts used in Java are:

Class

Defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog would consist of traits shared by all dogs, such as breed and fur color (characteristics), and the ability to bark and sit (behaviors). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self-contained (generally using encapsulation). Collectively, the properties and methods defined by a class are called members.

Object

A pattern (exemplar) of a class. The class of Dog defines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.

Instance

One can have an instance of a class or a particular object. The instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that's defined in the object's class.

Method

An object's abilities. In language, methods (sometimes referred to as "functions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit() or eat() or walk() or save_timmy(). Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking.

Message passing

"The process by which an object sends data to another object or asks the other object to invoke a method." Also known to some programming languages as interfacing. For example, the object called Breeder may tell the Lassie object to sit by passing a "sit" message which invokes Lassie's "sit" method. The syntax varies between languages, for example: [Lassie sit] in Objective-C. In Java, code-level message passing corresponds to "method calling". Some dynamic languages use double-dispatch or multi-dispatch to find and pass messages.

Inheritance

"Subclasses" are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own.

For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance of the Collie subclass. Suppose the Dog class defines a method called bark() and a property called furColor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once.

Each subclass can alter its inherited traits. For example, the Collie class might specify that the default furColor for a collie is brown-and-white. The Chihuahua subclass might specify that the bark() method produces a high pitch by default. Subclasses can also add new members. The Chihuahua subclass could add a method called tremble(). So an individual chihuahua instance would use a high-pitched bark() from the Chihuahua subclass, which in turn inherited the usual bark() from Dog. The chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua. In fact, inheritance is an "a... is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class: a Collie is a Dog ("a... is a"), but Lassie is a Collie ("is a"). Thus, the object named Lassie has the methods from both classes Collie and Dog.

Multiple inheritance is inheritance from more than one ancestor class, neither of these ancestors being an ancestor of the other. For example, independent classes could define Dogs and Cats, and a Chimera object could be created from these two which inherits all the (multiple) behavior of cats and dogs. This is not always supported, as it can be hard both to implement and to use well.

Abstraction

Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.

For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviors, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.

Abstraction is also achieved through Composition. For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects composing the class interact with each other.

Encapsulation

Encapsulation conceals the functional details of a class from objects that send messages to it.

For example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume). Timmy, Lassie's friend, however, does not need to know exactly how she barks. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface - those members accessible to that class. The reason for encapsulation is to prevent clients of an interface from depending on those parts of the implementation that are likely to change in future, thereby allowing those changes to be made more easily, that is, without changes to clients. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: Java uses the default access modifier to restrict access also to classes in the same package, C# and VB.NET reserve some members to classes in the same assembly using keywords internal (C#) or Friend (VB.NET), and Eiffel and C++ allow one to specify which classes may access any member.

Polymorphism

Polymorphism allows the programmer to treat derived class members just like their parent class' members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to method calls of methods of the same name, each one according to an appropriate type-specific behavior. One method, or an operator such as +, -, or *, can be abstractly applied in many different situations. If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). They both inherit speak() from Animal, but their derived class methods override the methods of the parent class; this is Overriding Polymorphism. Overloading Polymorphism is the use of one method signature, or one operator such as "+", to perform several different functions depending on the implementation. The "+" operator, for example, may be used to perform integer addition, float addition, list concatenation, or string concatenation. Any two subclasses of Number, such as Integer and Double, are expected to add together properly in an OOP language. The language must therefore overload the addition operator, "+", to work this way. This helps improve code readability. How this is implemented varies from language to language, but most OOP languages support at least some level of overloading polymorphism. Many OOP languages also support Parametric Polymorphism, where code is written without mention of any specific type and thus can be used transparently with any number of new types. Pointers are an example of a simple polymorphic routine that can be used with many different types of objects.

Decoupling

Decoupling allows for the separation of object interactions from classes and inheritance into distinct layers of abstraction. A common use of decoupling is to polymorphically decouple the encapsulation, which is the practice of using reusable code to prevent discrete code modules from interacting with each other. However, in practice decoupling often involves trade-offs with regard to which patterns of change to favor. The science of measuring these trade-offs in respect to actual change in an objective way is still in its infancy.

Note: Not all of the above concepts are to be found in all object-oriented programming languages, and so object-oriented programming that uses classes is called sometimes class-based programming. In particular, prototype-based programming does not typically use classes. As a result, a significantly different yet analogous terminology is used to define the concepts of object and instance.

What are the limitation of object oriented programming language?

  • Performance (since the generated code is much more than when working procedural)
  • Memory (more memory is needed to store code and data)

What are the functions of a utility program?

functions of utility program is to perform specific tasks related to the management of computer functions,resources or files as password protection,memory management,virus protection and file compression
This utility reads all V3 MMS output files, print out the header, partial sub-header and a value from all fields in the dataset.

What is the difference between mirco and macro?

macro-The climate of a large geographic area.

micro- is a local atmospheric zone where the climate differs from the surrounding area

If process stop its execution will thread also stop or it will continue to run?

Processes do not execute, it is the threads within a process that actually execute. All processes have at least one thread of execution, the main thread. If the main thread falls from scope, the process ends, taking all threads with it. This can lead to undefined behaviour if the threads are not terminated gracefully from within the main thread before it falls from scope.

Can you specify variable field width in scanf format string?

Answer

You can't specify a variable field with a fixed format string, but you can get around this by making the format string variable:

int width; char format[20]; /* or whatever size is appropriate */ int value; ... sprintf(format, "%%%dd", width); /* generates a string like "%5d" */ scanf(format, &value);

The only drawback to this method, other than requiring two statements, is that the compiler can't do a sanity check on the arguments to scanf like it can when the format is a string constant.

Answer

If you want to specify a variable width in a printf format string (as opposed to scanf), you can do the following:

printf("%*d", width, num);

That will use the value of "width" as the width for formatting the value of "num" as a decimal integer.

What experience do you need to become a computer programmer?

All computer programmers started with no experience in programming. However, to help you to pick up the skill faster and doing better, Math background and typing speed were 2 of my recommendations.

The algebra concept and operations definitely helps your logical thinking and will translate business requirements into code faster than those without math background.

Typing speed, well, just help EVERY one to know what you think on the screen or in the program. I have encountered some better thinkers, but suffer from typing skills that audience (readers, teammates) just became very impatient...(Of course you can have someone transcribe for you)

When making an on-site service call what should you do before making any changes to software or before taking th case off the computer?

The best way to keep your data safe is backing it up onto an external hard drive, which can be found at any electronics store. They vary from $250-$1000+, and can hold as much as 2 TB. Before you make any changes whether software or hardware related make sure to ask permission even if the user has just given you permission to interact with the PC.

Advantages of programmable logic array-PLA?

used as mux and demux , used for implement haff adder $ full adder, by program it

What are the types of computer software?

There are mainly two types of computer software. 1.Application Software. 2.System Software.

Why is using arrays with loops improve program efficiency?

Arrays provide the most compact method of representing one or more element of the same type in computer memory (whether in working memory or on disk). There is absolutely no memory overhead with arrays, other than when the array is allocated on the heap in which case you need to maintain at least one reference or pointer to the allocated memory. The structure of the array is built-in to the array itself, such that one element immediately follows another, and each element is exactly the same length (in bytes). This makes it possible to access any element in the array in constant time using simple pointer arithmetic. That is, knowing the start address of the array allows you to reference any element in the array using a memory offset or suffix operator. The first element is always found at offset zero (the start of the array) while the next is at offset 1. Thus for an n-element array, the final element will be at offset n-1. By offset, we really mean offset * sizeof (type), where type is the type of each element in the array. However, when working with arrays, the language knows the size of each type therefore we just use the offset as a zero-based index, where element 5 will be found at index 4, which is 4 * sizeof (type) bytes from the start of the array.

Given that arrays allow constant-time random access, loops make it extremely easy to traverse arrays from any element to any other element, both forwards and backwards. The loop control variable simply acts as the index to the element we wish to process on each iteration of the loop. We can also choose to skip elements if we're only interested in every other element, or every third element, simply by incrementing the control variable accordingly.

Looping through array indices is only efficient when you actually intend to traverse the array, such as when printing the entire array. When searching arrays for a specific value, loop traversal is the least efficient method. If we plan to search an array many times for many different values, it pays to sort the array first. We can then use the binary search technique, starting from the middle element. If that's not our element, the fact the array is sorted means we can eliminate one half of the array, depending on how the middle value compares to the value we are searching for. We then repeat the process with the remaining half, reducing the remaining elements by half each time until we either find our value, or the remaining half has no elements (in which case the value does not exist).