What is meant by heap in c or cpp?
If you see the word "heap" in the context of C/C++ programming, it is probably referring to one of two ideas.
First, if it is written as "the heap", it is probably referring to dynamically allocated memory. We conceptualize memory as either being on "the stack" or "the heap" in main memory. Memory allocation from the heap happens when a call to malloc (or similar functions) are called in C, or when the "new" operator is used in C++. This is in contrast to statically allocated memory, which comes from the load module and is known at compile-time, or from the "stack" which is used at run-time to allocate local scope, or automatic, memory.
Another usage of the word heap is a certain data structure called a heap. It is a very common data structure for priority queues and is crucial to the famous HeapSort algorithm. You can easily find more information on this data structure e.g. by searching for HeapSort.
What is the TCP Reno algorithm?
TCP doesn't immediately acknowledge every single received TCP segment. If a
single segment is received it is necessary to wait for 100-200ms on the assumption
that the receiving application will probably generate a response of some kind. But
if there is delay in sending acknowledgement by the receiver then the network is
delayed.
Cc in plumbing refers to the measurement from one object to another. Since plumbing is round the measurements are taken from "center to center".
What is the ASCII value of white space in c language?
int main (void) { printf ("space is %d\n", ' '); return 0; }
What are the different types of control units and explain the hardwired control unit with diagram?
Answer: Control unit is a computerized part of the speech processor. Most of the controls, such as program, volume and sensitivity, are located on the control unit.
How do you find whether a given number is even or odd in Unix shell programming?
echo "Program to check even or odd number"
echo "Enter a number"
read n
a=`expr $n % 2`
if [ $a -eq 0 ] ; then #Semicolon is most important for Executing ifelse statements
echo "It is an even number"
else
echo "It is an odd number"
fi
Program to find the occurrences of a given character in a string in c plus plus?
#include
#include
size_t count_char (const std::string& s, const char c)
{
size_t count = 0;
size_t offset = 0;
while ((offset = s.find(c, offset)) != s.npos)
{
++count;
++offset;
}
return count;
}
int main()
{
std::string str {"Hello world!"};
std::cout << "String: "" << str << """ << std::endl;
for (auto c : str )
{
size_t count = count_char (str, c);
std::cout << "'" << c << "' occurs " << count << " time" << (count==1?"":"s") << "." << std::endl;
}
}
Example output:
String: "Hello world!"
'H' occurs 1 time.
'e' occurs 1 time.
'l' occurs 3 times.
'l' occurs 3 times.
'o' occurs 2 times.
' ' occurs 1 time.
'w' occurs 1 time.
'o' occurs 2 times.
'r' occurs 1 time.
'l' occurs 3 times.
'd' occurs 1 time.
'!' occurs 1 time.
Answers to Programming in C Third Edition by Stephen G Kochan?
Programming in C Third Edition by Stephen G Kochan is a book about a programming language that consists of cross platform usage as long as you had adhered to the rules of the language!
This language can be combined with other "SDK" header files or basically code sepearated and formatted to isolated header files that consist of "variable declarations", "function declarations" and perform certain matmatical operations for you as you use the functions in a "modular" way and share peacfully.
Write a program to print whether the letter is vowel or not in BASIC?
vowels$ = "aeiou"
CLS
PRINT "PROGRAM: Find if letter is a vowel or not"
INPUT "Type a single alphabet letter: (a-z)/and, then, press Enter key"; aLetter$
PRINT "Letter "; aLetter$;
IF INSTR(vowels$, LCASE$(aLetter$)) THEN PRINT " is a vowel." ELSE PRINT " is NOT a vowel."
END
Write a program to display Identity matrix?
#include <stdio.h> void main() { int a,b,c,i,j; printf("Enter the number of rows for square matrix : "); scanf("%d",&a); for(i=1;i<=a;i++) { for(c=1,j=1;j<=a;j++,c++) { if(c==i) printf("1 "); else printf("0 "); } printf("\n"); } getch(); }
"Mean" usually means "average", so you just add the numbers together, then divide by 8.
Assembly language program to check whether the number is even or odd?
;Program to check whether the value in register is even or odd
.ORIG X3000
AND R2,R1,X0001
BRZ EVEN
LEA R0,DEF ;PRINTS ODD IF VALUE IN REGISTER R2 IS 1
PUTS
HALT
EVEN:
LEA R0,ABC ;PRINTS EVEN IF VALUE IN R2 IS 0
PUTS
HALT
ABC .STRINGZ "EVEN"
DEF .STRINGZ "ODD"
.END
It is ASCII not ASC11.
American Standard Code for Information Interchange
Sales consultant interview questions?
One question may be about talking on the telephone. You may also be asked about how much you like dealing with others.
How do you print highest number in an array in C language?
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void input(double arr[], const int arr_size);
double max(double arr[], const int arr_size);
int main()
{
const int arr_size = 5;
double arr[arr_size] = {0.0};
input(arr, arr_size);
cout << "Highest number is: " << max(arr, arr_size) << endl;
system("PAUSE");
return 0;
}
void input(double arr[], const int arr_size)
{
cout << "Enter " << arr_size << " elements to find the highest:" << endl;
for (int i = 0; i < arr_size; i++)
{
cout << (i + 1) << " element is: ";
cin >> arr[i];
}
}
double max(double arr[], const int arr_size)
{
double highest_num = arr[0];
for (int i = 0; i < arr_size; i++)
{
if (highest_num < arr[i])
{
highest_num = arr[i];
}
}
return highest_num;
}
What are the impact of object oriented on software industry?
what are the impact object oriented on software industry
Base Conversion program in c language?
#include void main(void) { char base_digits[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; int converted_number[64]; long int number_to_convert; int next_digit, base, index=0; /* get the number and base */ printf("Enter number and desired base: "); scanf("%ld %i", &number_to_convert, &base); /* convert to the indicated base */ while (number_to_convert != 0) { converted_number[index] = number_to_convert % base; number_to_convert = number_to_convert / base; ++index; } /* now print the result in reverse order */ --index; /* back up to last entry in the array */ printf("\n\nConverted Number = "); for( ; index>=0; index--) /* go backward through array */ { printf("%c", base_digits[converted_number[index]]); } printf("\n"); }
Polynomial multiplication in link list using c language?
#include
#include
struct polynode
{
float coeff;
int exp;
struct polynode *link;
};
void poly_append(struct polynode **,float,int);
void display_poly(struct polynode *);
void poly_multiply(struct polynode *, struct polynode *, struct polynode **);
void padd(float, int, struct polynode **);
main()
{
struct polynode *first, *second, *mult;
int i,coeff,exp,high;
first = second = mult = NULL;
printf("Enter the highest power of polynomial 1: \n");
scanf("%d",&high);
for(i=high;i>0;i--)
{
printf("Enter value for coeff for X^%d : ",i);
scanf("%d",&coeff);
poly_append(&first, coeff,i);
}
printf("\nEnter the highest power of polynomial 2: \n");
scanf("%d",&high);
for(i=high;i>0;i--)
{
printf("Enter value for coeff for X^%d : ",i);
scanf("%d",&coeff);
poly_append(&second, coeff,i);
}
printf("\n\n");
display_poly(&first);
printf("\n");
display_poly(second);
printf("\n");
for(i=1;i<=79;i++)
printf("-");
poly_multiply(first, second, &mult);
printf("\n");
display_poly(mult);
}
/* adds a term to a polynomial */
poly_append(struct polynode **q, float x, int y)
{
struct polynode *temp;
temp = *q;
/* create a new node if the list is empty */
if(*q NULL ) )
{
r = malloc ( sizeof ( struct polynode ) );
r -> coeff = c;
r -> exp = e;
r -> link = temp -> link;
temp -> link = r;
return;
}
temp = temp -> link; /* go to next node */
}
r -> link = NULL;
temp -> link = r;
}
}
How do you clear a character in screen in c language?
this is a tricky one... press alt + f4 and see if that works.
Write your own printf and scanf functions?
just include #define next to #include
or
/*just follow the pattern below*/ example:
#include
#include
#define pf printf
#define sf scanf
void main
{
int number
pf("Enter a value:");
sf("%i",&number);
getch();
}