What is machine dependent assembler features?
1) Instruction format and addressing modes. 2) Relocation. For details refer "System Software By L.L.Beck" BY:: SUNIL SHARMA (sunil13982@gmail.com)
What is the algorithm to delete a child node in binary tree?
as far as i know u have 4 cases for the node u wanna delete
1.It's a leaf (has no children)
2.It has only left child
3.it has only right child
4.it has both children ,left and right
now, let's work on it :>
set a pointer node to the root
while the element to be deleted doesnt equal the pointer
if it's smaller, move the pointer to the left subtree
if it's large , move the pointer to the right subtree
if pointer reached the end of the tree , null, break the loop (unluckly that means u didnt find the element that should be removed)
end while //(now u must have found the target, the while condition is breaked normally)
// this is case 4
if both children don't equal null
get the most left node in the subtree of the pointer node
assign its value to the pointer node.
remove it (set that most left thing to equal null)
//...case 2
if pointer node.right only equals null
pointer node = pointer node.left
//...case3
if pointer node.left only equals null
pointer node = pointer node.right
//... case 1
if pointer node.left and .right equals null
pointer node.data = null
maybe it doesnt look like any algorithm style ,sorry for that, that's as far as i knw, i doubt case 4 anyways..
Why do you need to use comments in a C program?
Preferably as little as possible, however it depends on the language. Low-level languages require a vast amount of user-comments because it can be extremely difficult to read the logic from the code alone. High-level languages require very few comments because the code should be largely self-documenting. Languages like C++ allow you to express concepts and ideas directly in code, so there's very little you need to document with a comment. Choosing good names for functions, classes and variables is a vital aspect of creating readable code.
What are IF statement functions?
A statement and a function are two separate things. An if statement is a selection statement and has the following forms in C:
if (expression) {
statement;
}
if (expression) {
statement;
} else {
statement;
}
In the first form, the statement executes only when the expression evaluates true. In the second form, the first statement executes when the expression evaluates true, otherwise the second statement executes. The second statement may be another if statement (a nested if):
if (expression) { statement;
} else if (expression) {
statement;
} else {
statement;
}
Here, the second expression is only evaluated when the first expression evaluates false. If both expressions evaluate false, the final statement executes. Note that the final else clause is optional within nested if statements.
Nested ifs can often be thinly-disguised switch statements:
if (x==0) {
f(x);
} else if (x==1) {
g(x);
} else if (x==2) {
h(x);
} else {
i(x);
}
If statements of this type are best implemented using a switch statement:
switch (x) {
case 0: f(x); break;
case 1: g(x); break;
case 2: h(x); break;
default: i(x);
}
As well as being easier to read (and maintain), execution is more efficient as the control expression (x) need only be evaluated once and execution will immediately pass to the appropriate case label (much like a goto statement). With a nested if statement, each expression has to be evaluated in turn until one of them evaluates true, or execution passes to the else clause.
Switch statements are also more flexible in that the default clause need not be the final clause and execution automatically "falls through" to the next case label until a break or return statement is encountered.
How do you include a system header file called sysheader.h in a c source file?
There is no system header called share.h, but if there were, it would be:
#include <share.h>
What is a pointer variable in C?
Pointer variables point to data variables. They are mostly used to point to dynamically allocated data variables, but can actually point to anything (e.g. statically allocated variables, array elements, anywhere inside a variable, program machine code, I/O device descriptors, nonexistent memory). Misuse of pointer variables, either unintentionally or intentionally, is a major cause of nearly impossible to debug software problems in programs written in C (and C++).
How to write Program to swap two variables using function call by value?
//This program swaps the values in the variable using function containing reference arguments
#include<iostream.h>
void swap(int &iNum1, int &iNum2);
void main()
{
int iVar1, iVar2;
cout<<"Enter two numbers "<<endl;
cin>>iVar1;
cin>>iVar2;
swap(iVar1, iVar2);
cout<<"In main "<<iVar1<<" "<<iVar2<<endl;
}
void swap(int &iNum1, int &iNum2)
{
int iTemp;
iTemp = iNum1;
iNum1 = iNum2;
iNum2 = iTemp;
cout<<"In swap "<<iNum1<<" "<<iNum2<<endl;
}
Reference arguments are indicated by an ampersand (&) preceding the argument:
int &iNUm1;
the ampersand (&) indicates that iNum1 is an alias for iVar1 which is passed as an argument.
The function declaration must have an ampersand following the data type of the argument:
void swap(int &iNum1, int &iNum2)
The ampersand sign is not used during the function call:
swap(iVar1, iVar2);
The sample output is
Enter two numbers
12
24
In swap 24 12
In main 24 12
------------------------------------------------------------------
By Satish from here
/ * Program to Swap Two Numbers by Using Call By Reference Method * /
#include
main()
{
int i, j;
clrscr();
printf("Please Enter the First Number in A : ");
scanf("%d",&i);
printf("\nPlease Enter the Second Number in B : ");
scanf("%d",&j);
swapr(&i,&j); /* call by reference*/
printf("A is now in B : %d",i);
printf("B is now in A : %d",j);
}
/* call by reference function*/
swapr(int *x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
Why you use class keyword in c?
You may use it as an identifier, because it is not a reserved word in C.
What is statement terminator in c language?
The compiler demands it: your programs wouldn't compile without them.
Explain pointer with the help of an example?
Pointers are data types that hold integer values, those "integer" values are simply addresses of another variables.
Example:
int x = 15; // this is an integer variable with value 15
int* ptr; // this is a pointer to an integer
ptr = &x; // now we assigned the address of x to the pointer ptr
// if you want to access the value of x (15 in this example),
// you should use the deterrence *
// so you can say:
printf("%d", *ptr); // this will print 15
// you can print the value of ptr (which is the address of x) using:
printf("%p", ptr); // this will print an integer, which is the address of x.
==========================================================
More explanation, let's imagine that this is a memory:
-00--01-02-03-04 =====> these are the address of the memory
|--- |--- |---|---|---| =====> values inside the memory
For the example I gave before, let's imagine the following:
-00-01-02--03--04
|---|15|--- | 01 |---|
------x------- ptr
As you can see, x hold the value 15, ptr holds the value 01 which is actually the address of x. Now ptr have a distinct address too, which is 03.
In reality, the address of a memory is longer, and usually represented as hexadecimal values. example 0x002154
You can find more information here:
http://en.wikipedia.org/wiki/Pointers
Structure declaration syntax:
struct tag_name
{
data_type member1;
data_type member2;
_______________________
_______________________
data_type membern;
};
A public class is a base class declared with public inheritance:
class base {
// ...
};
class derived : public base {
// ...
};
In the above example, base is a public class of derived, thus derived is regarded as being a type of base. The derived class inherits all the public and protected methods of its base. Protected methods are accessible to the derived class, its derivatives and their friends.
If base were declared protected, its public methods become protected methods of derived. The base class is then an implementation detail of derived; only members of derived, its derivatives and their friends can treat derived as being a type of base.
If declared private, the public and protected methods of base become private methods of derived. The base class is then an implementation detail of derived; only members of derived and its friends can treat derived as a type of base.
How do you do the summation of two matrix in c language?
#include
void f1(int a[]);
int a1[2][2],a2[2][2];
int i,j;
void main()
{
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("enter a1[%d] [%d]\t",i,j);
scanf("%d",&a1[i][j]);
}
printf("\n");
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("enter a2[%d] [%d]\t",i,j);
scanf("%d",&a2[i][j]);
}
printf("\n");
}
f1(a);
}
void f1(int a[])
{
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("therefor the result is: %d%d\t",a1[i][j]+a2[i][j]);
}
printf("\n");
}
}
In c plus plus what is the purpose of the keyword public and private in the definition of a class?
Public members/functions can be accessed from outside the class, private members/functions can only be accessed from functions of that class.
Ex.
class sampleClass{
private int value;
public void setValue(int a){value = a;} /* legal, value can be accessed since this is a method within the same class */
public int getValue(){return value;}
};
int main()
{
sampleClass sc; // class is instantiated
sc.setValue(5); // legal, setValue() is public
sc.value = 7; // ERROR, value is private, will not compile
printf("%d\n", sc.getValue()); // Will print 5
return 0;
}
Write a C programme for arithmetic operations using menu driven?
#include<stdio.h>
void main()
{
int num1, num2,res;
char ch;
printf("\n Enter the 1st operand");
scanf("%d",&num1);
printf("\n Enter the operator");
scanf("%c",&ch);
printf("\n Enter the 2nd operand");
scanf("%d",&num2);
switch(ch)
{
case '+' :res=num1+num2; break;
case '-' :res=num1-num2; break;
case '*' :res=num1*num2; break;
case '/' :res=num1/num2; break;
}
printf("\n The result of %d %d %d is =%d",num1,ch,num2,res);
}
Write a C programme to find out sum of the array elements?
main()
{
int n,a[i],s;
s=0;
printf("enter no of elements in array");
scanf("%d",&n);
printf("Enter elements in array");
for(i=;i
scanf("%d",&a[i]);
s+=a[i];
}
printf("sum of elements=%d",s);
return;
}
What is Volatile in c language?
'int' is the type, 'volatile' warns the compiler, that the value might be changed asynchronousy, so it mustn't be optimized (e.g. cached in register.)
Can you give a C plus plus program about FCFS algorithm?
#include<iostream.h>
#include<conio.h>
#include<alloc.h>
#include<stdio.h>
struct node
{
char name[10];
int bt;
int wt;
int tat;
struct node*next;
};
typedef struct node n;
n *start=NULL;
void main()
{
int i,m;
n *p,*temp,*t;
clrscr();
cout<<"\nEnter the number of Process:";
cin>>m;
for(i=0;i<m;i++)
{
p=(n*)malloc(sizeof (n));
cout<<"\n\tEnter the Process Name:";
cin>>p->name;
cout<<"\n\tEnter the Burst Time:";
cin>>p->bt;
if(start==NULL)
{
start=p;
start->next=NULL;
start->wt=0;
start->tat=start->bt;
}
else
{
temp=start;
while(temp!=NULL)
{
t=temp;
temp=temp->next;
}
t->next=p;
temp=p;
temp->wt=t->tat;
temp->tat=t->tat+temp->bt;
temp->next=NULL;
}
}
temp=start;
cout<<"\nProcesses\t\tBT\t\tWT\t\tTAT";
while(temp!=NULL)
{
cout<<"\n\t"<<temp->name;
cout<<"\t\t"<<temp->bt;
cout<<"\t\t"<<temp->wt;
cout<<"\t\t"<<temp->tat;
temp=temp->next;
}
cout<<"\n\n Created By:\n\tSanjog";
getch();
}
What is the latest compiler of C plus plus compiler?
C++ compilers are many and varied. There is no single "latest compiler" because every IDE implements their own version according to the current C++ standard. However some (Microsoft in particular) do not fully adhere to the C++ standard.
The "latest compiler" for your IDE is either provided as an interim update to the IDE, or by upgrading the IDE to the latest version.
What is static extern variables in C?
Basically storage class defines the accessibity of a variable. If you specify a variable with auto storage class, then that variable can be accessed only in that function or block where it is declared. if you specify a variable with static storage class, it has the same visibily like an auto variable but it can retains it's value between function calls where as an auto variable cannot. look at this example: void main() { int i,j ;
for(j = 0; j< =2; j++) { i = fun1(); printf("%d",i); } } int fun1() { static int k =0; k = k+1; return k; } it prints 1 2 3
What is the INT86 function in C programming?
INT 86 Int86() is a C function that allows to call interrupts in the program. prototype in dos.h In and out register must be type of REGS. REGS is a built in UNION declaration in C. It is defined in the header file <DOS.h>
Is it possible negative index in array?
Yes, but it will cause data corruption and/or abnormal program termination. Don't do it.
1 22 333 4444 how to create c program?
1 22 333 4444 Any text editor is usable for that.
1 22 333 4444 But if your question was about printing this sequence for nth term, then:
#include
#include
void main()
{
int n,i,j;
clrscr();
printf("Enter the last limit\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
}scanf(" ");
getch();
}
Hey look the above code will print out the series up-to the nth limit which is inputed from the user.
If u use only puts() then u have limitation, i.e. u can't print the series up-to nth term in a normal way and generally this program appears in series up-to nth term.
Thank u.
Cor c source code for Bank Management System?
code]
//***********************************************************************//
//***********************************************************************//
//******COMPUTERISED BANKING SYSTEM BY ****//
//Declaration of header files
#include <iostream.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <iomanip.h>
#include <graphics.h>
typedef char option[15];
const int ROW = 10,COL = 10;
int scan;
// To hold the special characters for moving the prompt in menu
int ascii;
// To display the main menu options
option a[]= {
"NewAccount",
"ListofAccounts",
"IndAccount",
"DailyTrans",
"MonthlyReport",
"EditAccount",
"Exit"};
// Displays the modify menu options
option b[] = {
"Modify Account",
"Closeaccount",
"Quit"
};
// Function used to do screening
class main_menu
{
int i,done;
public:
void normalvideo(int x,int y,char *str);
void reversevideo(int x,int y,char *str);
void box(int x1,int y1,int x2,int y2);
char menu();
void control_menu();
char e_menu();
void edit_menu();
void help(void);
};
/* Class member functions for drawing boxes */
class shape
{
public:
void line_hor(int, int, int, char);
void line_ver(int, int, int, char);
void box(int, int, int, int, char);
};
// Class contains the initial deposit of customers
class initial
{
public:
void add_to_file(int, char t_name[30], char t_address[30], float); // For initial deposits in customers account
void display_list(void); // Displaying customers account list
void delete_account(int); // Deleting customers account
void update_balance(int, char t_name[30], char t_address[30], float); // For updating the customer account
void modify(void); // To modify the customer account information
int last_accno(void); // To know the last account number
int found_account(int); // To found the account is in "INITIAL.dat" or not
char *return_name(int); // Function for validation entry of customer name
char *return_address(int); // Function for validation entry of customer address
float give_balance(int); // To print the balance amount of a particular customer
int recordno(int);
void display(int); // To display the customer account
private:
void modify_account(int, char t_name[30], char t_address[30]); // Function to modify the customer account
int accno;
char name[30], address[30];
float balance;
};
// Class contains the customers daily transaction entry
class account
{
public:
void new_account(void); // Function to create a new account
void close_account(void); // Function to close an account
void display_account(void); // Function to display the accounts
void transaction(void); // To display the transaction process
void clear(int, int); // Function to perform a clear screen function
void month_report(void); // Function to list monthWise transaction report
private:
void add_to_file(int, int, int, int, char, char t_type[10], float, float, float);
// Function to add transaction records
void delete_account(int); // Function to delete a transaction record
int no_of_days(int, int, int, int, int, int); // Function to find the total days
float calculate_interest(int, float);
// Function for calculating interest of anaccount
void display(int); // Function to display a transaction account
void box_for_display(int); // Function for displaying box
int accno;
char type[10]; // Account type as Cheque or Cash
int dd, mm, yy; // To store the system date/ Enter date
char tran; // As the account type is Deposit or Withdraw
float interest, amount, balance;
};
// Function to displays all the menu prompt messages from the pointer array of option a[]
void main_menu::normalvideo(int x,int y,char *str)
{
gotoxy(x,y);
cprintf("%s",str);
}
// Function to move the cursor on the menu prompt with a reverse video color
void main_menu::reversevideo(int x,int y,char *str)
{
textcolor(5+143);
textbackground(WHITE);
gotoxy(x,y);
cprintf("%s",str);
textcolor(GREEN);
textbackground(BLACK);
}
void main_menu::box(int x1,int y1,int x2,int y2)
{
for(int col=x1;col<x2;col++)
{
gotoxy(col,y1);
cprintf("%c",196);
gotoxy(col,y2);
cprintf("%c",196);
}
for(int row=y1;row<y2;row++)
{
gotoxy(x1,row);
cprintf("%c",179);
gotoxy(x2,row);
cprintf("%c",179);
}
gotoxy(x1,y1);
cprintf("%c",218);
gotoxy(x1,y2);
cprintf("%c",192);
gotoxy(x2,y1);
cprintf("%c",191);
gotoxy(x2,y2);
cprintf("%c",217);
}
char main_menu::menu()
{
clrscr();
textcolor(22);
box(20, 6, 65, 20);
box(18, 4, 67, 22);
textcolor(5+143);
gotoxy(36, 5);
textbackground(BLUE);
cprintf("B A N K I N G");
textbackground(BLACK);
textcolor(22);
for(i = 1; i < 7; i++)
normalvideo(32, i+10, a[i]);
reversevideo(32, 10, a[0]);
i = done = 0;
_setcursortype(_NOCURSOR);
do
{
int key = getch();
switch (key)
{
case 00:
key = getch();
switch (key)
{
case 72:
normalvideo(32, i+10, a[i]);
i--;
if (i '0')
return;
if (strlen(t_address) > 25)
{<br
When using CodeBlocks IDE for Linux how do you compile the program you are writing as an EXE?
CodeBlocks is an extensible, cross-platform IDE but it does not come with a compiler nor a linker since they are platform-specific. When you first run the IDE, it will scan your system for all supported compilers and integrate them into your IDE If you have more than one supported compiler, then you must choose the master compiler. But if you have no compiler, then you must add one. To build an EXE you must configure the project's compiler and linker switches according to your chosen compiler. Consult the compiler's own documentation for more information on this.