answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Who was Ernest Rutherford and what did he do?

· Ernest Rutherford was the son of James Rutherford.

· His mum was Martha Thompson

· He was born on August 30th 1871 in Nelson

· He died on October the 19th 1937

· His first name was mistakenly spelled Earnest when his birth was registered

· He Split the attom

Which is better DarkBasic or BlitzBasic?

Well, I use darkbasic pro, but loads of people annoy me by saying they hate db pro and love blitz basic. But I love DB pro and think it is an easy, but not too easy programming language.

What is the algorithm to determine if a year is a leap year?

Use the following algorithm to determine if a year is a leap year or a common year:

If 4 is not a factor of the year then it is a common year,

else if 100 is not a factor of the year then it is a leap year,

else if 400 is not a factor of the year then it is a common year,

else it is a leap year.

This algorithm is the most efficient method of determining if a year is a leap year or not using the fewest operations for the majority of years. If we assume the year could be anything in the closed range 1501 to 2500 (a range of 1000 years), 750 of those years (75%) are common years, all of which are caught by the first if statement (not divisible by 4). The remaining 250 years are all divisible by 4 and will fall through to the second if statement, which eliminates a further 240 of those 250 years (96%), all of which are leap years (divisible by 4 but not by 100). The remaining 10 years are divisible by both 4 and 100 and will fall through to the final if statement which eliminates a further 75% of those years, all of which are common years (not divisible by 400), which leaves us with just 3 years, 1600, 2000 and 2400, all of which are leap years.

The following is a (verbose) example implementation using C or C++:

bool is_leap_year (const unsigned year) {

if (year%4!=0) // not divisible by 4

return false; // common year

else if (year%100!=0) // divisible by 4 but not by 100

return true; // leap year

else if (year%400!=0) // divisible by 4 and 100 but not by 400

return false; // common year

else // divisible by 4, 100 and 400

return true; // leap year

}

Note that the % operator is the modulo operator. The return value is the remainder of integer division of the left-hand value by the right-hand value. If the result is 0, the right-hand value is a factor of the left-hand value, otherwise it is not.

The following is a more succinct version using implicit casts from unsigned to boolean. We can also eliminate the otherwise redundant else clauses and take advantage of constant-expression compile-time evaluation:

constexpr bool is_leap_year (const unsigned year) {

if (year%4) return false;

if (year%100) return true;

return !(year%400);

}

By declaring the function constexpr, the compiler can take advantage of compile-time evaluation when the given year is a constant expression or a literal constant. For instance, a good compiler will convert this:

bool leap_year {is_leap_year (2000)};

To this:

bool leap_year {false};

This completely eliminates the runtime cost. However, the following version will remain unchanged because the given year is a variable which must incur a runtime cost:

void f (unsigned year) {

bool leap_year {is_leap_year (year)};

}

The runtime cost itself is minimal given the efficiency of the algorithm.

What are the features of batch file programming?

Batch file programming is dos based programming you have to use dos commands .It is very good to perform some repetitive task in computer programming is easy you should only know the dos commands.

How do you take files out of an exe file?

An exe is a file which is run by the computer. It is not a data file. You can not take it apart. It does not contain separate files per se although it may liink to several separate files within the computer such as dll files.

C programming example source code?

This is a very wide question, which could have many different answers, from the simple to the complex.

However, as a start, an example of a program in C where you enter distance and time and calculate speed might look something like this:

(PLEASE NOTE: I CAN'T GET THIS TO FORMAT PROPERLY - THERE SHOULD BE A BLANK LINE AFTER "stdio.h" and after each semi-colon)

#include "stdio.h"

int main(void) {float distance, speed, timetaken;

printf("Enter distance in miles:");

scanf("%f", &distance);

printf("Enter time taken in seconds:");

scanf("%f", &timetaken);

speed = distance / timetaken;

printf ("\nSpeed = %10.2f (miles per second)\n", speed);

return 0;

}

What is low voltage programming?

LVP is the programming of the chip in which we don't need traditional high voltage like 12V or 13V. chip can work at lower voltage. so to programming a chip such a way that it can work at lower voltage that 12 V or 13 V is known as low voltage programming. PIC is by default work under LVP.

Write a program to illustrate the concept of extern variable?

#include

extern int errno;

int main (void)

{

fopen ("nosuchfile", "r");

fprintf (stderr, "error code=%d\n", errno);

return 0;

}

REGARD

Dheeraj Kumar

From S.M.U Hajipur (Bihar)

How you can store a class variables in array list?

An (non generic) arrayList in java can save any type of object (in this case your class variable) in this straightforward way:

MyClass myClassVar = new MyClass();

ArrayList myArrayList = new ArrayList();

myArrayList.add(myClassVar);

Why do you need two types of coding in one programming language?

It would be easier to answer, if you explained what the 'two types of coding' were.

Which option should we adopt to improve the database design of the organisation?

That would depend on what those specific options are. The options can only be determined by examining the flaws within the current database design of the organisation.

How long does it take a beginner to make an app?

Using the tutorial a person can probably do the example app in an hour or so, regardless of any previous experience (or lack). However this is very basic and has little functionality.

To actually design, code, test, and build a deliverable app that actually does something useful can take weeks to many months depending on your goals in developing this app and your experience in programming on other development environments. As a beginner I assume you have no experience programming using any development environment.

I have been programming computers using many different languages and development environments since 1973. From 1992 to 2008 the programming I did at work was all team projects that would have been impossible for one programmer to do entirely by himself, most of these projects took years for professional experienced software engineers working as a team to design, code, test, and build a deliverable for the customer.

Even with this experience I have never successfully written an app using a GUI, except for one tutorial several years ago (IIRC this took me a little over an hour). On projects I did at work that used a GUI other members of the team that were experts at coding GUI interfaces handled that code. My specialties at work were Requirements Analysis and Derivation, Documentation Preparation (some of our documents were 5 foot tall stacks of paper!!), Built In Test, realtime Failure Analysis, and Fault Logging systems.

Please do not let these comments discourage you in any way, one has to start somewhere. I wish you every chance of success in your task. Software development is both a very exciting but often frustrating field to pursue. My initial interest in programming back in High School resulted in a 30 year career getting well paid to do exactly the things I would have been most willing to pay them to allow me to do.

What is the difference between activity diagram and sequence diagram?

Activity diagram shows the work flow from start point to the end point detailing many decision points. Sequence shows detail flow of specific use case and it also shows interaction between actors, system and system components

What is a delegation event model in java?

Event model is based on the concept of an 'Event Source' and 'Event Listeners'. Any object that is interested in receiving messages (or events ) is called an Event Listener. Any object that generates these messages ( or events ) is called an Event Source

Event Delegation Model is based on four concepts:

The Event Classes

The Event Listeners

Explicit Event Enabling

Adapters

The modern approach to handling events is based on the delegation event model, which defines standard and consistent mechanisms to generate and process events. Its concept is quite simple: a source generates an event and sends it to one or more listeners. In this scheme, the listener simply waits until it receives an event. Once received, the listener processes the event and then returns. The advantage of this design is that the application logic that processes events is cleanly separated from the user interface logic that generates those events. A user interface element is able to "delegate" the processing of an event to a separate piece of code.

How do you do the algorithm?

The question is not specific enough. There are thousands upon thousands of algorithms - not just one. So we have no way of knowing which algorithm you are talking about!

Write a function to code the Fibonacci series in LISP programming language?

(defun fibo (n)

(if (< n 2)

n

(return (+ (fibo (- n 1)) (fibo (- n 2))))))

How do you create a table using another table including constraints?

If your using Ms SQL, use enterprise manager to export all scripts for a particular table in one file

What is a syntax-free programming language?

The term "syntax-free" is actually misleading. Every language has to have a syntax of some kind. What the term really means is a programming language that has a flexible, much more natural syntax rather than the strict syntax used by today's most popular programming languages. We can imagine such a language being extremely useful in speech-recognition software, where "Tea, Earl Grey, hot" would be a much more natural way for a human to interact (i.e., program) a vending machine than it would be to press buttons or use a touch-screen interface. However, in order to be flexible, the machine must also be able to cope with all the different ways a human might issue the same instruction, such as "Hot tea, Earl Grey" or even the much simpler "Earl Grey" or just "tea!". After all, the "hot" instruction can be assumed to be the default unless the user explicitly requests iced-tea, and the particular type of tea is only of importance if the consumer (the programmer) actually has a preference; if unspecified, choose the most popular type. The computer must also be able to cope with pleasantries such as "May I have cup of tea please?". Without syntax, the computer wouldn't be able to make sense of these instructions.

What is the following warning in a function where msg is a function name without prototype?

In C, each function needs a prototype declaration in the header file so that it can be called from outside of its immediate domain. To speed up compiling, the compiler only looks in the header files for function declarations. This greatly speeds up compiling when the function being called is located in another file. This way, it doesn't have to scan the whole file to make sure you didn't make a mistake. All you need to do to clear this error is to include a function prototype in the header. I'm not sure about C, but you *might* be able to get away with declaring the function at the beginning of the .c file.

Example:

--(file helloworld.h)--

long msg(int, int, char *); //this is the prototype

--(file helloworld.c)--

#include "helloworld.h"

void main()

{

msg(1,5,"Hello World");

}

long msg(int x, int y, char *message)

{

//code to display message here

}

Notice that the prototype only needs the data types, and not the variable names. If you don't want to bother with a header file, you can try putting your declarations at the beginning of your .c file (after the preprocessor directives), I know I've done it that way before but I'm not sure in which cases it will work.

What is a postscript?

A postscript is added at the end of an article or letter. It comes from the Latin words "post" meaning after, and "script" meaning writing. A postscript to a letter starts with the letters P.S. which stand for postscript, after writing.

Who invented programming?

Charles Babbage is commonly credited with the invention of the programmable computer, while Ada Lovelace is commonly credited as the inventor of the first computer programming language (called "Ada" after the inventor). Depending on the precise meaning of your question, either one of these two people are likely whom you are looking for.