Differences among sequential access direct access?
Let's say you have a set of 100 pieces of data, which are all names. Now, if you want to find a specific name, "Kevin", you can find it in different ways. You could either go through each of the records one after another, or you could randomly generate a number, and check if that record is "Kevin", this is potentially faster than sequential access as "Kevin" could be the last record.
How are pointer different from other variables?
A pointer variable is a variable that contains the memory location of another variable or an array (or anything else in memory). Effectively, it points to another memory location.
For standard variables, you define a type, assign a value to that variable or read the value from it, and you can also read the memory location (&n = memory location of n) of the variable.
For pointers, you can point them to any variable, even another pointer, and you can get the value of the variable it points to (*p), the location of that variable in memory (p), or the address in memory of the pointer itself (&p).
Consider:
long n = 65;
long *p;
p = &n;
Results:
Type | Name | Location | Value
long n 0xA3FF 65
long * p 0x31DF 0xA3FF
So p points to n. Now,
n = 65
&n = 0xA3FF
p = 0xA3FF
*p = 65
&p = 0x31DF
You may find yourself having to use typecasts frequently when using pointers.
Pointers are useful when passing data to functions.
For instance, consider the following function:
void add(int a, int b, int c) { c = a + b; }
The problem here is that the computer copies each variable into a new memory location before passing them to the function as local variables. This function effectively does nothing. However, if you change the function to:
void add(int a, int b, int *c) { c = a + b; }
and call the function by passing in the location of the variable to the function:
add(a,b,&c);
then you can modify the variable itself.
Pointers are also good for working with arrays:
char *c = "Hello World";
int i=0;
while (c[i] != 0x00) { cout << c[i]; c++ } //print one letter at a time.
Is sizeof an operator or function why?
You cannot overload the sizeof() operator because that could introduce uncertainty in its evaluation. The sizeof() operator must always produce an accurate and logically predictable result, thus all user-intervention is completely forbidden.
What is the difference between modular programming and structured programming.?
Modular programming:It is the act of designing and writing programs as interactions among functions that each perform a single well defined function,& which have minimal side effect interaction between them.It is heavily procedural.The focus is entirely on writing code(functions). Data is passive.Any code may access the contents of any data structured passed to it.
Object Oriented programming:it is a programming paradigm using "objects"-data structures consisting of data fields & methods together with their interactions-to design applications and computer programs.programming techniques may include features such as data abstraction,encapsulation,messaging,modularity,polymorphism and inheritance.
Recursive function to find nth number of the Fibonacci series?
STEP1. Set value of count=1, output=1, T1=0, T2=1
STEP2. Read value of n
STEP3. Print output
STEP4. Calculate
output=T1+T2
STEP5. T1=T2 & T2=output
STEP6. Calculate count= count+1
STEP7. If (count<=n>
go to STEP3
else
go to STEP8
STEP8. End
You could also just plug in n into this formula:
F(n) = [φ^n - (1-φ)^n] / sqrt(5)
φ is about 1.618033989 and is the Golden Ratio
[It's also the limit as n approaches infinity of the nth term in the Fibonacci sequence divided by the (n-1)th term]
How do you generate Fibonacci series in c programming language?
#include<stdio.h>
#include<conio.h>
void main()
{
int a=-1,b=1,c=0,i,n;
clrscr()
printf("Enter the limit");
scanf(%d,&n)
printf(the resultant fibonacci sequence is:)
for(i=1;i<=n;i++)
{
c=a+b;
printf(%d, c)
a=b;
b=c;
}
getch();
}
Program for token separation in c language?
/* Write a program to identify and generate the tokens present in the given input */
/* Token Separation */
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iostream.h>
int key = 0;
char expr[100];
char cont[][20]={"CONTROLS","for","do","while","NULL",};
char cond[][20]={"CONDITION","if","then","NULL"};
char oprt[][20]={"OPERATOR","+","-","*","/","%","<","<=",">",">=","=","(",")","NULL"};
char branch[][20]={"BRANCHING","goto","jump" ,"NULL"};
void checking(char[],char[][20]);
void main()
{
int i,j,l,k,m,n;
char sbexpr[50],txt[3];
clrscr();
cout<<"Enter the expression:";
gets(expr);
for(i=0;expr[i]!=NULL;i++)
{
key=0;
for(j=i,k=0;expr[j]!=32 && expr[j]!=NULL;i++,j++,k++)
sbexpr[k]=expr[j];
sbexpr[k]=NULL;
if(key==0) checking(sbexpr,cond);
if(key==0) checking(sbexpr,cont);
if(key==0) checking(sbexpr,branch);
if(key==0)
{
for(m=0;sbexpr[m]!=NULL;m++)
{
key=0;
txt[0]= sbexpr[m];
txt[1] = NULL;
if(key==0) checking(txt,oprt);
if((key==0) ((sbexpr[m]>=97 && sbexpr[m]<=122) (sbexpr[m]>=65 && sbexpr[m]<=90)))
{
cout<<"\n"<<sbexpr[m]<<"------->"<<"Identifier\n";
key = 1;
}
}
}
if(key == 0)
{
cout<<"\n"<<sbexpr<<"------->"<<"Address\n";
key = 1;
}
}
getch();
}
void checking (char expr[],char check[][20])
{
for(int i=1;strcmp(check[i],"NULL")!=0;i++)
{
if(strcmp(expr,check[i])==0)
{
cout<<expr<<"------>"<<check[0]<<"\n";
key = 1;
}
}
}
In general, parsing is when you take a large chunk of data and break it down into smaller, more useful chunks.
When a compiler or interpreter is turning the source code of a programming language into executable code, it must first parse that source code so it knows what statements the program is trying to use. It can then use that information to translate your source into computer-understandable machine code.
Writing in pseudo code means writing in a natural language, not in any specific programming language, so there is no thing as "pseudo-code used in C" as opposed to "pseudo-code used in Java".
When you write in pseudo-code, you don't have to follow any specific syntactic rules, just to describe the steps you will use in your algorithm.
For example, pseudo-code for bubble sort (taken from wikipedia):
procedure bubbleSort( A : list of sortable items ) do swapped = false for each i in 1 tolength(A) - 1 inclusive do: if A[i-1] > A[i] then swap( A[i-1], A[i] ) swapped = true end ifend for while swapped end procedure
It is not written in any programming language, but it should be easy to implement this in any language after you understand the idea from the pseudo-code.
Application of binary tree in data structure?
1) the complexity of insertion,deletion and searching operation is depend on the height of the tree.
i.e. if height is n(for skew binary tree) then complexity is O(n) .
2) difficult to get the sorted list from the binary tree.which is easy for BST.
Command line arguments are provided at the time of running the program. Example: Suppose that your program needs input name and its value then running it from commandline(DOS prompt) you provide the values after the program name java xyz name JAX(name is name and value is jax)
Write a C program to swap 2 numbers using 3rd variable?
#include<stdio.h>
main()
{
int a,b;
printf("enter the value for a and b\n");
scanf("%d %d",&a,&b);
display(a,b);
}
display(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
printf("%d %d",x,y);
}
How do you write a c plus plus program to find area of a triangle where base4 and height6?
pi x radius x radius the forula for working out the area of a circle if this is what you're asking.
========================================================
Please give the Proper Answer...
Write a program to subtract two 3x3 matrices?
The value of a static global variable can never be changed whereas the value of a simple global variable can be changed.
how to create a 3x3 matrix written in c++:
#include
#include
using namespace.std;
int main()
{
string yourstinghere[3][3];
}
Is the C Plus Plus language good for making software?
C++ is one of the most flexible programming-languages there is. So, my first answer would be 'Yes'. However the question is, if C++ is the most suited language for the software that you want to make. There may be a alternative, easier language, in wich you can develop your software. Jahewi :-)
What is an abstract data structure?
Abstract Data Type in computing is a set of data along with a set of predefined operations.
The actual data inside the ADT is protected from direct manipulation. The exposed operations is the only way to manipulate the data.
In easier terms, it is very much like (though not limited) to the objects in object oriented programming.
What does putting your pointer finger to your lips?
word: seducing yourself
action of it crossing pointer fingers over your lips: you are going to make out with yourself and look at hot girls kissing each other on youtube!
SO EVERYONE CROSS YOUR POINTER FINGERS OVER YOUR LIPS!!!
call me baby
HOW can a program that outputs the days of the week using switch statement be created?
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the value of n");
scanf("%d",&n);
switch(n)
{
case1:printf("monday");
break;
case2:printf("tueday");
break;
case3:printf("wednesday");
break;
case4:printf("thursday");
break;
case5:printf("friday");
break;
case6:printf("saturday");
break;
case7:printf("sunday");
break;
default:printf("invalid number");
}
}
A queue is a first-in, first-out data structure. We use queues when one thread needs to communicate with another but they operate at different frequencies (asynchronously), such that the first thread may produce input for the second thread faster than the second thread can actually process each input. Thus the first thread will place each input on a shared queue and the second thread can deal with each in turn as and when it is ready. To avoid data races, all operations that modify the queue must be mutually exclusive, such that only one thread can gain access to these operations at any given moment. This can be implemented using a lock, such that only one thread can "own" the lock while all others must wait until the lock is released.
Example of formatted functions in C?
formatted functions::: Follows a fixed format like scanf,printf
Unformatted functions:::Do not have fixed format like gets,getchar
The char data types holds a single ASCII (or unicode) value, so it holds any character, for example: '2', 'r', or '~'. The problem is it only holds one character, not a whole string. That is why the string was developed; it holds a whole bunch of characters in a row. But strings cant be compared with < and >, so for alphabetical ordering, use char.
What is the difference between array and enum?
Array is collection of data items of same data type.
Enum is collection of data items of different data type.