Where are store static variable in memory?
static variables are stored in a special area of the heap called the "permanent generation".
What is the flowchart for swapping two variables?
include
#include
void main()
{
int x, y, temp;
printf("Enter the value of x and y ");
scanf("d", &x, &y);
printf("Before Swapping x = %d\ny = %d\n",x,y);
temp = x;
x = y;
y = temp;
printf("After Swapping x = %d\ny = %d\n",x,y);
getch();
return 0;
}
Do you happen to know what a flow-chart is?
Write an algorithm for addition of two matrices?
Addition of two matrices is simply performed by iterating over all of the elements and adding elements with like indices together. A c code snippet...
for (i=0; i<N; i++) for (j=0; j<M; j++) c[i][j] = a[i][j] + b[i][j];
What are the advantages of pass by reference as compared to pass by value?
Call by reference, particularly when applied to objects, because call by value automatically invokes an object's copy constructor, which is seldom desirable when passing objects into functions.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node
{
int n;
struct node *ptr;
};
int main(void)
{
struct node *n1,*strt,*temp;
char a;
int cnt=0,i=0;
//char a[50],temp[100],line[100],word[50],e[50],final[100];
//FILE *fp,*fp1,*fp2;
strt=malloc(sizeof(struct node));
strt->n=90;
strt->ptr=NULL;
for(a='y';a!='n';)
{
n1=malloc(sizeof(struct node));
n1->n=++cnt;
n1->ptr=strt;
strt=n1;
scanf("%c",&a);
}
// ptr[1]=40;
// ptr[2]=30;
n1=strt;
while(n1!=NULL)
{ printf("\n %d at loc %p",n1->n,n1);
printf(" locaa %p \n",n1->ptr);
n1=n1->ptr;
}
return 0;
}
~
~
~
An AVL tree is another balanced binary search tree. Named after their inventors, Adelson-Velskii and Landis, they were the first dynamically balanced trees to be proposed. Like red-black trees, they are not perfectly balanced, but pairs of sub-trees differ in height by at most 1, maintaining an O(logn) search time. Addition and deletion operations also take O(logn) time.
Definition of an AVL treeAn AVL tree is a binary search tree which has the following properties:What is difference between a source program and an object module?
An object program is a compiled program ready to be loaded on a computer,
i.e. machine code, ready to be executed by the machine.
A source program is what the programmer wrote, which is then translated into object program by a compiler.
Is B tree a Binary Search Tree?
Yes because there is no real practical use for a binary tree other than something to teach in computer science classes. A binary tree is not used in the real world, a "B tree" is.
prime a loop is that how mach time it executed either max time or minimum time
The American Standard Code for Information Interchange was made to standardize 128 numeric codes that represent the English letters, Symbols, and Numbers. Any USA keyboard is made with this standard in mind.
How do you fix an infinite loop?
It comes from its name: it doesn't terminate, the user have to interrupt the program-run (in the worst case: power off the computer).
The infinite loop is also used to program loops with non-easily-deterministically end-of-loop conditions.
You write an infinite loop, such as for (;;) {statements}, and break out of the loop with the break statement when ready to terminate.
Why do you need assembly language?
Assembly language is more human-readable than machine language. Generally, statements in assembly language are written using short codes for the instruction and arguments, such as "MOV $12 SP", as opposed to machine language, where everything is written as numbers. Assembly language can have comments and macros as well, to ease programming and understanding.
Generally, programs called "assemblers" transform assembly language to machine language. This is a relatively straightforward process, there being a clear 1-to-1 transformation between assembly and machine language. This is as opposed to compilers, which do a complicated transformation between high-level language and assembly.
--------------------------------------------------------------------
ASSEMBLY is the key word to define the difference between Machine Language and Assembly. . Assembly language assembles steps of MACHINE CODE into SUB-ROUTINES defined by simple text words:
Such as: the assembly command 'ADD' may represents 20-30 machine commands.
Write a c program to merge two array?
#include <stdio.h>
#include <conio.h>
void main(){
int a[10],b[10],c[10],i,j,m,n,tmp,k;
printf("\nEnter the size of the 1st array:");
scanf("%d",&m);
printf("\nEnter the size of the 2nd array:");
scanf("%d",&n);
printf("\nEnter the 1st array values:");
for(i=0;i<m;i++){
scanf("%d",&a[i]);
}
printf("\nEnter the 2nd array values:");
for(i=0;i<n;i++){
scanf("%d",&b[i]);
}
for(i=0;i<m;i++)
{
for(j=0;j<m-i;j++)
{
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
}
printf("\n\n Array in the ascending order is - \n");
for(i=0;i<m;i++)
{
printf("\t %d",a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(b[j]>b[j+1])
{
tmp=b[j];
b[j]=b[j+1];
b[j+1]=tmp;
}
}
}
printf("\n\n Array in the ascending order is - \n");
for(i=0;i<n;i++)
{
printf("\t %d",b[i]);
}
i=j=k=0;
while(i<n&&j<m)
{
if(a[i]<b[j])
c[k++]=a[i++];
else
if(a[i]>b[j])
c[k++]=b[j++];
else
{
c[k++]=b[j++];
i++;
j++;
}
}
if(i<n)
{
int t;
for(t=0;t<n;t++)
c[k++]=a[i++];
}
if(j<m)
{
int t;
for(t=0;t<m;t++)
{
c[k++]=b[j++];
}
}
printf("\nFinally sorted join array is:");
for(k=0;k<(m+n);k++)
printf("\t\n %d ",c[k]);
getch();
}
We briefly list some of C's characteristics that define the language and also have lead to its popularity as a programming language. Naturally we will be studying many of these aspects throughout the course. * Small size * Extensive use of function calls * Loose typing - unlike PASCAL * Structured language * Low level (BitWise) programming readily available * Pointer implementation - extensive use of pointers for memory, array, structures and functions. C has now become a widely used professional language for various reasons. * It has high-level constructs. * It can handle low-level activities. * It produces efficient programs. * It can be compiled on a variety of computers. Its main drawback is that it has poor error detection which can make it off putting to the beginner. However diligence in this matter can pay off handsomely since having learned the rules of C we can break them. Not many languages allow this. This if done properly and carefully leads to the power of C programming. The standard for C programs was originally the features set by Brian Kernighan. In order to make the language more internationally acceptable, an international standard was developed, ANSI C (American National Standards Institute).
What are the algorithm in stopwatch c language?
#include <stdio.h>
#include <time.h>
int main()
{
time_t start_time;
time_t stop_time;
int e;
clrscr();
printf( "Type the Enter key to START timing.\n");
while(getchar()!='\n');
start_time=time(NULL);
printf( "Type the Enter key to STOP timing.\n");
while(getchar()!='\n');
stop_time=time(NULL) ;
e=difftime( stop_time,start_time);
printf( "Elapsed time: %d seconds.\n" ,e) ;
getch();
}
What is the main function of the spline?
the purpose of the spline is to support the weight of your head
What are the advantages of using a recursive function in c?
Advantages:
Through Recursion one can Solve problems in easy way while
its iterative solution is very big and complex.
Ex : tower of Hanoi
You reduce size of the code when you use recursive call.
Disadvantages :
Recursive solution is always logical and it is very
difficult to trace.(debug and understand)
Before each recursive calls current values of the varibles
in the function is stored in the PCB, ie process control
block and this PCB is pushed in the OS Stack.
So sometimes alot of free memory is require for recursive
solutions.
Remember : whatever could be done through recursion could be
done through iterative way but reverse is not true.
What is the difference between database and relational database?
A database is something that stores data. Using tools called Database Management Systems(like Oracle, Informix, Sybase, DB2), you can create, view, modify, and delete databases. Databases can be -Relational -Object Oriented -Object Relational Relational database stores data in tables(called realtions). These tables are related to each other.Just like in our family, our relations are related with each other. In Object Oriented Databases, the information is stored in the form of Objects as in Object Oriented Programming.OODBMS makes database objects appear as programming language objects in one or more porgramming languages. Object relational databases combine the features of both Object Oriented as well as Relational databases. Here you can not only store simple data like text in relational, but you can also store complex objects like images, audio and video in tables.
Q1 Find the minimum and the maximum number of keys that a heap of height h can contain?
Q1. Find the minimum and the maximum number of keys that a heap of height h can contain.
Progarm to delete previous node in linked list?
struct LinkedListNode
{
void* data;
LinkedListNode* next;
};
LinkedListNode* head;
LinkedListNode* tmp;
while (head)
{
tmp head->next;
free(head);
head tmp;
}
Can you Write a program in c plus plus to display the multiplication table?
void printTable() {
}
printf("\n");
printf(" ");
for (c = 0; c <= 10; ++c) {
printf(" -");
}
printf("\n");
// calculations
int r;
for (r = 0; r <= 10; ++r) {
// row headers
printf("%2d|", r);
// calculation for the current row
for (c = 0; c <= 10; ++c) {
printf("%4d", (r * c));
}
printf("\n");
}
}
How do you Assign an address to an element of pointer array?
Pointers were always difficult subject to understand. I would suggest to read several tutorials and spend some time playing with them.
Explanation:
/* create array of two pointers to integer */
int *aaa[2];
/* setting first pointer in array to point to 0x1212 location in memory */
aaa[0] = (int *)0x1212;
/* allocate memory for the second pointer and set value */
aaa[1] = malloc(sizeof(int));
*aaa[1] = 333;
/* if you want to can make first item to point to the second,
now arr[0] pointer address changed to the same as aaa[1] pointer */
aaa[0] = aaa[1];
/* print aaa[1] address and later print value */
printf("LOCATION: %X\n", (unsigned int)*(aaa + 1));
printf("VALUE: %d\n", **(aaa + 1));
/* exact the same here, but different way of how I wrote pointers */
printf("LOCATION: %X\n", (unsigned int)aaa[1]);
printf("VALUE: %d\n", *aaa[1]);
If you would do the same with 0 element of array, which points to 0x1212 memory location you would get some kind of number or Bus error if you accessed restricted memory place (for example the beginning of memory).
I hope this I did not make you more confused than you are.
Second-generation programming language is a generational way to categorize assembly languages. The term was coined to provide a distinction from higher level third-generation programming languages (3GL) such as COBOL and earlier machine code languages. Second-generation programming languages have the following properties:
* The code can be read and written by a programmer. To run on a computer it must be converted into a machine readable form, a process called assembly.
* The language is specific to a particular processor family and environment.
Second-generation languages are sometimes used in kernels and device drivers (though C is generally employed for this in modern kernels), but more often find use in extremely intensive processing such as games, video editing, graphic manipulation/rendering.
One method for creating such code is by allowing a compiler to generate a machine-optimized assembly language version of a particular function. This code is then hand-tuned, gaining both the brute-force insight of the machine optimizing algorithm and the intuitive abilities of the human optimizer.