What is the C program for byte stuffing?
#include
#include
main()
{
char a[20],fs[50]="",t[6],r[5];
int i,j,p=0,q=0;
clrscr();
printf("enter bit string : ");
scanf("%s",a);
strcat(fs,"01111110");
if(strlen(a)<5)
{
strcat(fs,a);
}
else
{
for(i=0;i
{
for(j=i;j
{
t[p++]=a[j];
}
t[p]='\0';
if(strcmp(t,"11111")==0)
{
strcat(fs,"111110");
i=j-1;
}
else
{
r[0]=a[i];
r[1]='\0';
strcat(fs,r);
}
p=0;
}
for(q=i;q
{
t[p++]=a[q];
}
t[p]='\0';
strcat(fs,t);
}
strcat(fs,"01111110");
printf("After stuffing : %s",fs);
getch();
}
What is pseudo code for GCD of two numbers?
public class GCD {
public static void main(String[] args) {
//Example how to use this method
System.out.println(GCD(15,50));
}
//find the greatest common divisor of two numbers
public static int GCD(int a, int b){
if (b == 0) return a;
return GCD(b, a % b);
}
}
Hope this help to solve you problem.
Write a programme in c to convert Fahrenheit to celsius and vice versa?
double celsiusToFahrenheit(double degreesC)
{
return degreesC * 9.0 / 5.0 + 32.0;
}
double fahrenheitToCelsius(double degreesF)
{
return (degreesF - 32.0) * 5.0 / 9.0;
}
Or instead of having to divide and multiply you can simply use (Celsius +32)1.8.
(C+32)1.8
Fahrenheit -32 divided by 1.8.
F-32/1.8.
Write an algorithm for addition of two integer?
1.Declare three variables as
int a,b,c;
2.Get the Input of two numbers of Integers from the user:
scanf("%d",&a);
scanf("%d",&b);
3.add a and b and store the result in c
4. print c
How do you provide the default values of function parameters?
It depends on the programming language, however in languages based upon C, we simply assign the default values within the function declaration.
int f (int x; int y=0; int z=42);
Note that if we provide a default value for any argument, all the remaining arguments must also have default values. Here, x has no default but y does, thus z requires one as well.
When defaults are given, the caller need not provide values if the defaults suffice:
f (1, 2, 3); // ok -- all three values given
f (1, 2); // ok, f (1, 2, 42) implied
f (1); // ok, f (1, 0, 42) implied
f (); // error -- missing argument! x has no default
We can also provide default values in the function definition (because a definition is itself a declaration), however the declaration (alone) is preferred because it provides the best means of documenting functions; it's what the compiler "sees" and is what the user refers to. If a function has no forward declaration then it was never intended for users anyway; it's an implementation detail. But providing defaults in both the declaration and definition (or even just the definition) is frowned upon, and most compilers will guard against this.
In C++ and other object-oriented languages, although many classes do have a "natural" default value (a string defaults to an empty string, for instance), we cannot use this as an implied default. All default values (including natural default values) must be explicitly stated in the function declaration otherwise values are expected to be passed via the caller:
int g (std::string s, std::string s2="");
Here, although std::string defaults to an empty string, the argument s does not: thus the caller is expected to provide a value for s. However, s2 has an explicitly stated default (the natural default), so the caller need not provide a value for s2:
g("hello", "world"); // ok -- both arguments given
g ("foobar"); // ok - s is given, s2 defaults to empty
g (); // error - missing argument! s has no default
Binary search program for 8085?
Res db " position",13,10,"$"
msg2 db 'key not found!!!!!!!!!!!!!. $'
.code
mov ax,@data
mov ds,ax
mov bx,00
mov dx,len
mov cx,key
again:cmp bx,dx
ja fail
mov ax,bx
add ax,dx
shr ax,1
mov si,ax
add si,si
cmp cx,arr[si]
jae big
dec ax
mov dx,ax
jmp again
big:je success
inc ax
mov bx,ax
jmp again
success:add al,01
add al,'0'
mov res,al
lea dx,msg1
jmp disp
fail:lea dx,msg2
disp:mov ah,09h
int 21h
mov ah,4ch
Why we use extension as cpp in c plus plus programs?
Source files use a .cpp file extension, while headers use .hpp. However, this is merely a convention. Most C++ programmers use .h for all headers, even though this convention implies a C-style header rather than a C++ header. Ultimately, the extension is immaterial. If the file can be included in other files, then it is a header, otherwise it is a source file.
flow charts are useful in getting a lot of information or methods across by a systematic order of flow of informaion. some people are visual in learning information and this is a form of a 'pictorial' diagram of conveying info. in an organizaed manner. It depicts a map of info.
Why is assembly language called a low level language?
x86 assembly language is crucial to be able to do any serious security or reverse engineering work. In addition, it allows one to write well optimized code. It also gives the opportunity to understand how things really work inside the computer, which is by itself very important if you want to become a competent programmer.
x86 assembly language is not very hard to learn. In fact, if you know basic math (The one that you learn in elementary school), you could learn it yourself.
I recorded an online video course for x86 assembly (paid) and exercises (Open source).
You can find it at the address xorpd dot net.
This course will teach you x86 assuming that you know nothing. It only assumes
that you know how to add numbers. (In base 10).
In the end of the course you will be able to write fully working x86 assembly
programs on the Fasm assembler over the Windows operation system.
xorpd.
What is a primitive campground?
Many "primitive" campgrounds are located in wilderness areas on federal or state land.
Generally, a "primitive" campground means one with few, little, or NO improvements.
Basically, a cleared patch of ground to pitch a small tent or lay down your sleeping bag.
Improvements are generally things like:
- running water, as opposed to a hand pump or well
- a toilet or an outhouse/privy
- electricity or lights
- buildings, cabins, shelters, ...
What is meant by arguments in c?
Arguments appear in functions and in function calls. Arguments passed to a function are known as actual arguments. The arguments used by the function are known as the formal arguments. In C, all arguments are passed by value, such that the formal argument is a copy of the actual argument.
How can I change the output font of a C program?
C++ doesn't understand the notion of a font. To work with fonts you will need a graphics library. The library will provide the methods required to change font sizes.
Example of predefined function?
function callMe (fx_params) {
alert(fx_params);
}
callMe('Alert Loaded from a JavaScript function');
This would be in a javascript page, or in a JS Script tag..
- Caleb
Convina Web Design and Hosting
The AVL tree is named after its two inventors, G.M. Adelson-Velsky and E.M. Landis, who published it in their 1962 paper "An algorithm for the organization of information."
The balance factor of a node is the height of its right subtree minus the height of its left subtree. A node with balance factor 1, 0, or -1 is considered balanced. A node with any other balance factor is considered unbalanced and requires rebalancing the tree. The balance factor is either stored directly at each node or computed from the heights of the subtrees.
2 Write a program in java to find factorial of a number?
import java.math.BigInteger;
public class Factorial {
public static void main(String[] args) {
BigInteger n = BigInteger.ONE;
for (int i=1; i<=20; i++) {
n = n.multiply(BigInteger.valueOf(i));
System.out.println(i + "! = " + n);
}
int number;
int i=2;
while (i<number)
{
if(number%i==0)
{
printf("Not a prime no.");
break;
}
else
printf("number entered is prime");
getch();
}
Enumerations are a method of grouping constant values. For example:
enum suits { clubs, diamonds, spades, hearts };
By default, the first constant is assigned the value 0 and all subsequent values increment by 1. However, you can assign any value to any constant -- the automatic increments will continue from that point.
enum suits { clubs = 1, diamonds, spades, hearts };
You can also assign the same value to multiple constants.
enum suits { clubs = 1, diamonds, spades = 1, hearts };
By grouping constants within enumerations your code becomes more secure because you cannot pass constant literals into functions that expect an enumeration. Consider the following:
void print_suit(unsigned id)
{
switch (id)
{
case (0): std:cout << "Clubs"; break;
case (1): std:cout << "Diamonds"; break;
case (2): std:cout << "Spades"; break;
case (3): std:cout << "Hearts"; break;
default: std::cout << "Invalid";
}
}
In the above example there is nothing to prevent the caller from passing an invalid value, such as 42, which the function caters for with a default case. However, by passing an enum instead, invalid values are completely eliminated:
void print_suit(suits suit)
{
switch (suit)
{
case (clubs): std:cout << "Clubs"; break;
case (diamonds): std:cout << "Diamonds"; break;
case (spades): std:cout << "Spades"; break;
case (hearts): std:cout << "Hearts";
}
}
Parameterized constructor in c plus plus?
Every class requires at least one constructor, the copy constructor. It is implied if not declared. If no constructors are declared, a default constructor is also implied. Every class also requires a destructor, which is also implied if not declared.
The purpose of constructors is to construct the object (obviously) but by defining your own you can control how the object is constructed, and how member variables are initialised. By overloading constructors, you allow instances of your object to be constructed in several different ways.
The copy constructor's default implementation performs a member-wise copy (a shallow-copy) of all the class members. If your class includes pointers, you will invariably need to provide your own copy constructor to ensure that memory is deep-copied. That is, you'll want to copy the memory being pointed at, not the pointers themselves (otherwise all copies end up pointing to the same memory, which could spell disaster when one of those instances is destroyed).
The destructor allows you to tear-down your class in a controlled manner, including cleaning up any memory allocated to it. If your class includes pointers to allocated memory, you must remember to delete those pointers during destruction. The destructor is your last-chance to do so before the memory "leaks". The implied destructor will not do this for you -- you must implement one yourself.
class foo
{
public:
foo(){} // Default constructor.
foo(const foo & f){} // Copy constructor.
~foo(){} // Destructor.
};
Swap function in c plus language?
#include<iostream>
void swap(int* x, int* y)
{
int tmp = *x; *x=*y; *y=tmp;
}
int main()
{
int a=2, b=4;
std::cout<<"a="<<a<<", b="<<b<<std::endl;
swap(&a, &b);
std::cout<<"a="<<a<<", b="<<b<<std::endl;
}
How is a c plus plus program stored in the memory?
C++ programs are not stored in memory (RAM) they are stored on mass storage devices (usually disk drives). When compiled, they produce machine code programs which contain machine instructions and their operands. These are also stored on mass storage devices, but when loaded into memory the machine instructions are executed by the CPU.
What is the difference between a binary tree and a complete binary tree?
Let's start with graphs. A graph is a collection of nodes and edges. If you drew a bunch of dots on paper and drew lines between them arbitrarily, you'd have drawn a graph.
A directed acyclic graph is a graph with some restrictions: all the edges are directed (point from one node to another, but not both ways) and the edges don't form cycles (you can't go around in circles forever).
A tree, in turn, is a directed acyclic graph with the condition that every node is accessible from a single root. This means that every node has a "parent" node and 0 or more "child" nodes, except for the root node which has no parent.
A binary tree is a tree with one more restriction: no node may have more than 2 children.
More specific than binary trees are balanced binary trees, and more specific than that, heaps.
A binary tree can be empty ..whereas the general tree cannot be empty
What is binary search and linear search in data structure?
A Binary Search is a technique for quickly locating an item in a sequential list.
A Sequential Search is a procedure for searching a table that consists of starting at some table position (usually the beginning) and comparing the file-record key in hand with each table-record key, one at a time, until either a match is found or all sequential positions have been searched.
Based on execution
1. Iterative Function
2. Recursive Function
Based on Argument and return value
1. No argument No return value
2. With argument Without return value
3. With out argument without return value
4. With argument With return value
What are the six stages that typical c programs go through to be executed?
First of all the source code is get compiled and the object code is returned i.e.binary code(machine language).Then the Linker, a computer program that takes one or more objects generated by a compiler and combines them into a single executable program. Now when the program is executed then the .exe file is first loaded into the memory and then executed by the processor.
In short the steps are:
1.Compilation
2.Linking
3.Loading
4.execution