The Executive Order 11850 is the prohibition of using chemical herbicides in war or in agents to contain or halt public riots. It went into effect in the year 1975.
How to write c programme of Sleeping-barber problem in opertating system?
#define CHAIRS 5 /* # chairs for waiting customers */
typedef int semaphore; /* use your imagination */
semaphore customers = 0; /* # of customers waiting for service */
semaphore barbers = 0; /* # of barbers waiting for customers */
semaphore mutex = 1; /* for mutual exclusion */
int waiting = 0; /* customer are waiting (not being cut) */
void barber(void)
{
while (TRUE) {
down(&customers); /* go to sleep if # of customers is 0 */
down(&mutex); /* acquire access to "waiting' */
waiting = waiting - 1; /* decrement count of waiting customers */
up(&barbers); /* one barber is now ready to cut hair */
up(&mutex); /* release 'waiting' */
cut_hair(); /* cut hair (outside critical region */
}
}
void customer(void)
{
down(&mutex); /* enter critical region */
if (waiting < CHAIRS) { /* if there are no free chairs, leave */
waiting = waiting + 1; /* increment count of waiting customers */
up(&customers); /* wake up barber if necessary */
up(&mutex); /* release access to 'waiting' */
down(&barbers); /* go to sleep if # of free barbers is 0 */
get_haircut(); /* be seated and be served */
} else {
up(&mutex); /* shop is full; do not wait */
}
}
Why may you recommend the use of a macro instead of a subroutine inside a loop in a program?
A subroutine call generates additional work for the hardware to perform when activated. A macro in general does not call a subroutine but rather puts the commands in-line inside the loop, resulting in a faster program.
Calculate length of string using printf statement only?
printf does return the length:
size_t len = printf ("%s", str);
How many hexadecimal digits are used to locate an address in the memory?
depends on the depth of memory, N address lines can map 2 Power N locations.
Dynamically allocated array waste storage and time?
It's actually not true. In order to make a good program which can work with big arrays you have to use dynamic arrays because you can cleam memory used by dymanic arrays any time. For static arrays is not true, memery which was reserved for static arrays will be available for other applications only when you finish working with your application (which is working with static arrays).
What is centralized test groups and decentralized test groups?
I require more details but let me answer in terms of team hierarchy.
Centralized test groups: A TCOE is formed in an organization which provide test resources (people) to projects as per their requiement. Training, skill, Time and billings are tracked. Mostly lead by Test Manager.
Decentralized: Project teams own test resouces. so a project manager/dev manager are leads and test team report to them dedicately.
How do you Add 2 numbers using pointer and array in C?
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i;
int a[4]={1,2,3,4};
int *p1,*p2,*p3;
for(i=0;i<4;i++)
{
p1=&a[0];
p2=&a[2];
p3=*p2-*p1;
printf("\n value of p3%d",p3);
}
getch();
}
What are the advantages and disadvantages of writing programs in high level languages?
The main advantage is of course convenience - it is much easier to write\read code in a high-level language.
The main disadvantage is the performance - in general, if you write the same program in a high-level language and in a low-level language, the first will usually take more time.
It can make a difference if your program is very heavy, or if performance is very important (e.g. you're writing an operating system), but for most normal programs I would recommend using a high-level program, and python is a great example of one!
How do you print a pyramid in c?
#include<stdio.h>
void main()
{
int i,j,k,n;
printf("Enter the value of n: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=1;k<=n-i;k++)
printf(" ");
for(j=1;j<=2*i-1;j++)
{
printf("*");
}
printf("\n");
}
}
Can you use conditional operator in cout statement?
Yes, but 'cout' is not a statement! Examples for statements: null-statement, block, expression, if-else, while, do-while, for, continue, switch, break, return.
A pointer is a variable that stores the memory address of another variable. In programming, pointers are typically located in the stack if they are local variables within a function, or in the heap if they are dynamically allocated. The actual data that the pointer points to can reside in either memory area, depending on how it was allocated.
What is the term for a space memory used to store information for later use?
A space used by memory to store information for later use is called the cache (pronounced like cash).
What is the importance of union in a c program?
Importance of union in 'C':
unions are the concept borrowed from structures in structures we allow different datatypes in which each datatype is allocated a separate memory location .But in unions same as structures we use different data types but all the datatypes will be allocated to a single memory location and only one datatype with maximum size will be used for allocation of all the data types used in a union program.Sample code for union is as follows:
union item
{
int m;
float c;
char x;
}code;
In the above program we used three kinds of datatypes here integer size is 4 so the other data types will be shared in the same location of size 4.then the memory will not be wasted and all the memory will be utilized perfectly.
Why a function is not defined in to another function?
A function is not deigned in to another function. It is because that would lead to dependency injection.
When you pass an array element to a method the method receives?
Yes, you can use array-elements as parameters. Do you have any problem with that?
1. a is a factor of b.
2. c = 2b = 4a, thus b = 2a and c = 4a.
3. d is prime between 10 & 20.
4. a + b + c + d = 41.
Therefore: a + 2a + 4a + d = 41
7a + d = 41
d = 41 - 7a
The only integer value for awhich results in d being a prime between 10 and 20 is where a = 4.
If a = 4 then
b = 2a = 4 * 2 = 8
c = 4a = 4 * 4 = 16
d = 41 - (7*4) = 41 - 28 = 13
The numbers are thus 4,8,16 and 13.
Are arrays in C created on the stack or the heap?
That depends on where you define them. Arrays defined inside functions are declared on the stack (like other variables defined in functions). Arrays defined outside of any function, or using the static keyword inside a function are allocated in the static data area of the program.
Other arrays may be allocated using malloc() (or "new" in C++); these are allocated on the heap.
Loops are used to repeat the execution of the same set of instructions again and again in a program.
What is the sum of a two digit number less the sum of its digits?
There exist no numbers which are less than the sum of their digits.
This is obvious for single digit numbers, since each number would be exactly equal to the sum of its digits.
For multi-digit numbers, this still holds true. Let's take a two digit number in the form: ab. Where a and b represent the digits of this number.
The sum of the digits of ab = a + b.
The number ab = a*10 + b.
It should now be obvious that ab will always be greater than a + b.
For larger numbers, the difference between the sum of digits and the number only grows, as a number abc = a*100 + b*10 + c, abcd = a*1000 + b*100 + c*10 + d, etc.
Proof by exhaustion (via Java code, since this is listed in the programming category):
for (int n = 10; n <= 99; ++n) {
int _n = n;
int sumDigits = 0;
while (_n != 0) {
sumDigits += _n % 10;
_n /= 10;
}
if (n < sumDigits) {
// This code is never reached, since n >= sumDigits for all 10 <= n <= 99
System.out.println(n + " < " + sumDigits);
}
}
What is an initialization statement?
When a declared variable receives a value to hold.
i.e.
int lalalala;
lalalala = 0; //initialization of lalalala