answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

A company makes two products x and y using two machines a and b each unit of x that is produced requires 50 minutes processing time on machine a and 30 minutes processing time on machine b each?

Solution

Let

• x be the number of units of X produced in the current week

• y be the number of units of Y produced in the current week

then the constraints are:

• 50x + 24y <= 40(60) machine A time

• 30x + 33y <= 35(60) machine B time

• x >= 75 - 30

• i.e. x >= 45 so production of X >= demand (75) - initial stock (30), which ensures we meet demand

• y >= 95 - 90

• i.e. y >= 5 so production of Y >= demand (95) - initial stock (90), which ensures we meet demand

The objective is: maximise (x+30-75) + (y+90-95) = (x+y-50) i.e. to maximise the number of units left in stock at the end of the week

Solving simultaneously, rather than by reading values off the graph, we have that x=45 and y=6.25 with the value of the objective function being 1.25

Why is COM1 is not available?

It can be switched off in BIOS of your PC.

In Apple Macintosh there's no COM1 at all.

How do you write an algorithm to check whether a number is a prime number or not?

Checking if a number is prime is a popular question for programming competitions.

It's also necessary when implementing software that generates private keys for RSA public-key encryption.

There are several formulas for computing the prime numbers such as Willans' Formulas and Wormell's Formula. These two are used to generate a prime number.

The simplest way to check if a given number is prime (primality testing) is to search for a factor.

Try possible factors and see if the number can be evenly divided into any of them.

In C, that simple check is:

bool IsPrime(long int number)

{

if (number < 2) return false;

if (number <= 3) return true;

long int ns, temp;

for (ns = 3; ns < number; ns++)

{

temp = number / ns;

if (temp*ns number) {

printf("The smallest prime factor of %li is %li .\n", number, ns );

printf("The product of %li * %li is %li .\n", ns, temp, number );

return false; //can be divided!

}

}

return true;

}

This can be sped up a little more by only checking primes (rather than every odd number), perhaps using the sieve of Eratosthenes to find those primes.

Because all primes are integers, it's usually best not to use floating-point when working with them.

Even with all known speedups, every known method for factorizing a number is still too slow for some applications -- it would take centuries to check the numbers used in RSA public-key encryption -- and so people have developed much faster, much more complicated algorithms for primality testing.

These fast algorithms can prove that a number is almost certainly prime; however, when they indicate that a number is composite, they don't reveal any of the factors of that composite number.

Such fast algorithms include

the Fermat primality test,

the cyclotomy test,

the Lucas test,

the Proth test.

the Miller-Rabin primality test,

the Solovay-Strassen primality test, and

the AKS primality test.

The implementation, of those formula, unfortunately cannot be listed in here.

How do operating systems handle all the different peripherals that are on the market?

Operating systems usually communicate with peripherals using "drivers", which are usually written by the designers\manufacturers of the peripheral.

Drivers are essentially programs or processes that the operating system loads which contain the necessary routines and information to make use of the peripheral.

Write a C plus plus program to convert a given number into years weeks and days?

#include<iostream>

void num_to_years_weeks_days(

unsigned num, unsigned& years,

unsigned& weeks, unsigned& days)

{

years = num / 365;

num -= years * 365;

weeks = num / 7;

num -= weeks * 7;

days = num;

}

int main()

{

unsigned years, weeks, days;

unsigned num = 1000;

num_to_years_weeks_days(num, years, weeks, days);

std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl;

num = 12345;

std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl;

}

C program to print 1 12 123 1234?

#include <stdio.h>

int main (void) { puts ("1 22 333 4444 55555"); return 0; }

What is the binary complement 8 bit representation for negative 19?

8-bit 2s complement representation of -19 is 11101101

For 1s complement invert all the bits.

For 2s complement add 1 to the 1s complement:

With 8-bits:

19 � 0001 0011

1s � 1110 1100

2s � 1110 1100 + 1 = 1110 1101

Why is appeasement important?

The idea of appeasing your enemy to keep him at arms length away from you is a good idea in theory to protect yourself. But, enemies do not always stay appeased. Appeasement does not really work if the enemy is not appeased as in the case of Adolf Hitler. He went against every nation that tried the appeasement tactic with him.

Write a program to print 'hello' in output?

Ah, the infamous "Hello World" program.

I'm assuming you have a compiler (if not Dev-C++ if a good)

the code is as follows:

#include <iostream>

using namespace std;

int main()

{

cout << "Hello World" << endl;

system("PAUSE");

return 0;

}

What is the limitation of linear queue and how do you overcome using circular queue?

in linear queue when any element is pop out than we do size-1 value changing ie

like in the pile of coin when we take out the last coin then all changes there places so likewise we have to change the position of each element.....

we can overcome by circular one as we have to change the value of the first and last not the values changes in the array....

but circular queue also had limitation that

either u have to use it as size-1 queue or

it will show you full even though it is empty fully....as first==last...

When was Emergency Language Systems created?

Emergency Language Systems was created on 2009-09-04.

How much should an 18 year old php developer be earning part time in the uk based on a fixed hourly wage with one company not as a freelancer With 5 plus years experience in php and MySQL?

You should be earning at least the minimum wage for an 18 year old (which is currently at £4.98/hr) unless you are doing an apprenticeship, in which case they can pay you as little as £2.65/hr.

5+ years with PHP and MySQL experience is pretty impressive for an 18 year old; it would mean developing since you were at least 13!

So let's assume you do 16 hours a week. That's what is usually agreed upon as "part-time" in the UK.

Let's say you do about 39 weeks out of 52 in the year. This is a rough estimate based on being part-time.

That's 16 hours * 39 weeks which is 624 hours in a year you work.

On 18 year old minimum wage that's (624*4.98) = ~£3108/yr.

On <19 year old apprentice minimum wage that's (624*2.65) = ~1654/yr.

Of course you may earn more or less depending on how much you work.

Work it out like so:

x = your total earnings

m = minimum wage for you

h = # hours you work a week

w = # weeks you work in the year

x = (m*(h*w))

What is the task of dll and ocx in programming?

Dll is "dynamic link library" it provides all the information about built in methods which we used in program at run time. these could be keywords(main, if , for etc) or functions( pow(), main(), strcat() etc) or classes in opps.

An OCX is an Object Linking and Embedding (OLE) custom control, a special-purpose program that can be created for use by applications running on Microsoft's Windows systems.

Is the c drive hardware?

No. The C drive is simply a partition that you create. The harddrive is hardware.

The main method of a program has?

The Java main method of a program is the place where the program execution begins. A main method would look like below

public static void main(String[] args){

}

When argument are passed by value the function works with the original arguments in the calling program?

When a function is passed by value the calling function makes a copy of the passed argument and works on that copy. And that's the reason that any changes made in the argument value does gets reflected to the caller.