How do you write an assembly language program to count the number of ones in a given byte?
1. Find algorithm.
2. Implement it.
Hint: if a non-zero N number has K 1-bits, then (N AND N-1) has K-1 1-bits.
It requires the same amount of memory, so it wouldn't spare anything. Don't do it.
How do you subtract improper fraction in C programming language?
The following shows how this can be achieved:
typedef struct fraction {
int n; // numerator
int d; // denominator
};
struct fraction subtract (struct fraction a, struct fraction b) {
struct fraction r; // result
r.d = lcm (a.d, b.d); // lowest common multiple
r.n = (a.n * (r.d/a.d)) - (b.n * (r.d/b.d));
return r;
}
The lcm() function has the following definition:
int lcm (int a, int b)
{
int sign = 1;
if (a<0) a*=-1, sign *=(-1);
if (b<0) b*=-1, sign *=(-1);
return (a*b) / gcd (a,b) * sign;
}
The gcd() function (greatest common divisor) has the following definition:
int gcd (int a, int b)
{ int sign = 1;
if (a<0) a*=-1, sign *=(-1);
if (b<0) b*=-1, sign *=(-1);
while (a!=b)
a>b?a-=b:b-=a;
return a * sign;
}
Which type of c program can be run on windows 7?
I guess you wanted to ask: why don't DOS-programs (like TurboC and programs generated by TurboC) run on Windows 7?
Answer: it is by design; unlike older versions, Windows 7 doesn't have a built-in DOS-emulator. Download and use DosBox.
How can you break apart an array to make two arrays?
If the two arrays are a simple division of the larger array (such as splitting it in half), you can use pointers to mark the start address of each sub-array:
int a[10];
int* p1 = &a[0]; // point to first half
int* p2 = &a[5]; // point to second half
You should also use unsigned integer variables to keep track of the size of each sub-array:
unsigned p1size = 5, p2size=5;
It's usually best to use a structure to keep array pointers and size variables together in one place:
typedef struct intarray {
int* ptr;
unsigned size;
}
If you need to split the array in a non-contiguous manner you will need to create new arrays that are at least as large as the original array, and then copy the appropriate elements to the appropriate sub-array. Once copied, you can (optionally) shrink the sub-arrays to eliminate any unused elements.
In C, all names (including functions) must be declared with a type before they can be used. Knowing a name's type allows the compiler to ensure that operations upon the name are valid for its type, thus preventing many common bugs that might otherwise be missed, such as trying to assign a string to an integer.
What is watch function in C programming language?
The C language and the standard C runtime toolkit does not contain a watch function, but development tools typically contain a debugger, which normally supports a watch tool.
The debugger's watch tool allows to watch the value of a variable changing while stepping through a program. This is one of the most basic and one of the most commonly used debugging tools.
What is code optimization phase?
Optimization compiler is a compiler that can minimize or maximize attributes of an executable computer program. It is most common to minimize the time that is taken to execute a program.
Is an abstract class cannot have any member variable in C plus plus?
An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.
How in C or C plus plus to static assert that a place in code be unreachable?
The only way to assert unreachable code is to place the assertion, assert(0), within the suspected unreachable code itself.
However, just because the assertion never triggers it does not follow that the code is unreachable -- only that the condition(s) required to reach that code segment have not thus far arisen. How certain can you be that the condition will never arise?
Unreachable code can sometimes be detected at compile time, depending on the compiler. Simple errors such as placing a return statement before unreachable code can normally be detected this way. However, logic errors may not always be as obvious.
For instance,
if( !condition )
// do something.
else if( condition )
// do something else.
else
assert( false ); // unreachable...
In general, if there is no logical proof to say a code segment is unreachable, it's best to leave the segment in place. An assert( false ) will alert you when the segment is hit, but even if it is never hit, you cannot be certain it will never be hit without a logical proof. If the unreachable code is trivial then it is usually not worth the effort to prove it is unreachable. If it is non-trivial, the only issue is how you test it in the event it is actually reachable. In that case you must force the conditions that would make it reachable.
In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.[1][2]
Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks. For example, B-trees are particularly well-suited for implementation of databases, while compiler implementations usually use hash tables to look up identifiers.
Data structures are used in almost every program or software system. Specific data structures are essential ingredients of many efficient algorithms, and make possible the management of huge amounts of data, such as large databases and internet indexing services. Some formal design methods and programming languages emphasize data structures, rather than algorithms, as the key organizing factor in software design
Why you use constreamh in c plus plus?
There is no such header in C++. You must consult the documentation provided with the file. It is most likely related to console input/output, perhaps providing enhancements to the standard I/O stream implementation.
What are the basic data type and subtype used by C compiler .explain properly?
Basically data types are divided into three types namely,
1. primary data type -> this is sub divide into int, float, char, void.
2. derived data type -> this is sub divide into array, pointer.
3. user defined data type -> this is sub divide into struct, union, enum, typedef.
by,
k.p.sruthi
First question: You can define zero or more functions before main, and zero or more functions after it. It's up to you. Of course you have to have prototypes for functions which are called before their definitions.
Second question: Good programming style includes many things, for example:
- keep your functions simple, short, easy to understand and modify
- orginize the code into modules (separate source files), the size of a module should be below a few thousands line.
- don't use global variable instead of function parameters
Which Keyword is used to return some value from a function?
return var_name;
e.g
int fun()
{
int x=...;
return x;
}
How do you convert decimal number 147 to binary?
First convert 37 in to decimal.
(3*8^1)+(7*8^0)=31.
Then convert it to binary.
2|31|
2|15---1
2 |7-----1
2|3------1
2|1-----1
so answer is in binary =(11111)
Or, by digits: 3->011, 7->111; 37->011111
What are the three types of data needed to post an incoming payment?
Outbound Delivery Number, Billing Document Type, Billing Date
How do you uppercase letters in palindrome string?
Use toupper from ctype.h for every letter. Obviously, it doesn't matter if the string is palindrom or not.
What is size of char far data type?
char is a primitive data type and depends on the programming language and the operating system.
What is polynomial in data structures?
Polynomials in data structures are sets of pairs of coefficient and exponent in two set which are designed for comparison (less, great, equal) to made third one resulting polynomial.
Operations that can be performed on polynomial are :
What are all the objects oriented programmes?
For a fairly exhaustive list, see the related link to this question. Popular languages are C++, Java, Objective-C, Visual Basic, and Ruby.
Netstat for Windows is provided by Microsoft itself, so you're unlikely to find any source code for it. However you may find Linux versions of Netstat source code available. The functionality may differ to some extent, but how useful they are will depend on why you need the source code in the first place.
Can you give me an example of source code using gotoxy and Microsoft visual basic c plus plus 2006?
can you help me create a program that will have the following output:
[1] Volume of Ellipsoid
[2] Volume of Prolate Spheroid
[3] Surface Area of Prolate Spheroid
[4] Volume of Oblate Spheroid
[5] Surface Area of Oblate Spheroid
[6] Surface Area of Spherical Triangle
Enter Your Choice:
You have chosen:
Enter Side a:
Enter Side b:
Enter Side c:
Volume =
Do you want to try again? [Y/N]
...
it must use gotoxy and clear screen after choosing Y or N ( in do you want to try again)
it must be used in Microsoft visual basic c++ 2006,,
here are the following formulas;;
Volume of Ellipsoid = (4/3)*3.14*a*b*c
( input a,b,c)
Volume of Prolate Spheroid = (4/3)*3.14*a*(pow(b,2))
(input a,b)
Surface Area of Prolate Spheroid = 2*3.14*b*L
(input b,L)
Volume of Oblate Spheroid = (4/3)*3.14*(pow(a,2))*b
Surface Area of Oblate Spheroid = 2*3.14*a*y
where:
y = a+(number/denom)
number = pow(b,2)
denom = 2(sqrt(pow(a,2)-pow(b,2))
(input a,b)
Surface of Spherical Triangle = ( A+B+C-3.14)*pow(r,2)
(input A,B,C,r)