answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Built-in functions in C?

You can have #include after Stdio.h ...it has so many built in mathematical functions like CIRCULAR FUNCTIONS, ABSOLUTE VALUE and more..

Sadly, built-in functions and library functions are different things... there are no built-in functions in C (except for sizeof, which isn't an actual function).

What is the best BASIC compiler?

At the moment Visual basic 2005/8, 2005 for anything older then windows xp 2008 for xp or newer i don't know about other operating systems though...

How many base class and derived class can be created in inheritance?

As many as required. The only practical limits are those imposed by the hardware. For instance, 32-bit systems can only address a maximum of 4GB, but only 2GB is actually available to applications. On 64-bit systems there is no practical limit other than hard-drive space (for the virtual memory paging file).

Remember that every class of object requires memory to store its member variables (plus padding for alignment), which has to be multiplied up by the number of instances of those classes. Thus the more complex the hierarchy, the fewer instances you can create overall. Since alignment padding can add a substantial overhead, it's best to declare member variables from largest to smallest within each class because memory is allocated in the same order the members are declared. If a v-table is required (which it typically will be in a multi-level hierarchy) this will consume additional memory: essentially one function pointer per virtual function per override.

That said, it is difficult to imagine any hierarchy so large that you will hit a memory limitation, even on a 32-bit system, unless you happen to embed a particularly large member variable in your class, such as a hi-resolution image or video, rather than use a disk-based file stream. Aside from that the main concern is in how many instances of that hierarchy can you physically construct at one time. However, you need only look at some of the hierarchies within the Microsoft Foundation Classes to realise that your probably just scratching the surface of what is actually possible.

What is an isoscles triangle?

A triangle with two angles of the same degree and the this one at a different degree.

What type of operator is used to compare two values?

Conditional operators are used to compare two values. The result of a comparison is either true or false. Boolean data types can hold the values true or false.

Here's a list of operators.

= Equal to

> Greater than

< Less than

>= Grater than or equal to

<= Less than or equal to

<> Not equal to

Whwt is the algorithm to reverse the elements of a single linked lists without using a temporary list?

The actual code depends on whether the list is singly-linked or doubly-linked, however the algorithm is largely the same for both. Of course if the list is doubly-linked there is no need to reverse the list at all since the list can simply be traversed in reverse. However, for the sake of completeness, example code is provided for both.

The Algorithm

Set the current node to be the head node then repeatedly extract the current node's next node and insert it at the head of the list until the current node's next node is NULL.



Singly-linked Example (C++)


Assuming the list is a reference that has a head node pointer, and each node in the list has a next node pointer, a singly-linked list can be reversed as follows:

// Ensure there is a head node.
if(Node* current = list.head)

{

// Ensure the current node has a next node.

while(Node* temp= current->next )

{

// Move the next node to the head of the list.

current->next = temp->next;

temp->next = list.head;

list.head = temp;

}

}


Doubly-linked Example (C++)

In doubly-linked lists, it is assumed each node has a previous node pointer as well as a next node pointer. The algorithm is essentially the same but the node pointers obviously need to be adjusted in both directions, as follows:

// Ensure there is a head node.
if( Node* current = list.head )

{

// Ensure the current node has a next node.

while(Node* temp= current->next )

{

// Move the next node to the head of the list.

current->next = temp->next;

temp->next.prev = current;

temp->next = list.head;

list.head->prev = temp;

list.head = temp;

temp->prev = NULL;

}


// If the list also has a tail node, remember to reset it!

list.tail = current;

}

In both cases, when the while() loop finishes, the current node ends up pointing at the tail node. However, the current node never actually changes -- it always points to the same node, the original head node. As each loop progresses, the current node is demoted towards the tail, one position at a time, to eventually become the tail node. When the current node has no next node, the loop terminates and the list is completely reversed.


Repeating the reversal will naturally restore the list to its original order.


Circular Lists

The exact same algorithm can also be applied to circular lists. The only major difference is that you terminate the loop when temp points to the head of the list, rather than when it is NULL.

Should I learn C or C plus plus first if I want to learn C?

Very! C++ isn't the best language out there, it certainly has its issues, but it's very powerful. It's also fairly low-level, as far as modern languages are concerned. Python has all the power with few of the costs. If you already know how to program, you should be able to pick it up in less than two hours. Most the concepts you learned in C++ (inheritance, polymorphism, etc) still apply, too. Python has the advantage of plenty of super easy-to-use libraries for many thing (such as downloading a web page). It can't hurt to try, so give Python a spin and see if it benefits you.

see related link below

In java using command line argument write prime number program?

/* Program to print prime numbers up to given number */

import java.util.*;

public class Prime

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the number : (it prints prime numbers upto your given number)");

int n=sc.nextInt();

System.out.println("The Prime number upto "+n+" are : ");

while (n>=0)

{

int count=0;

for (int i=1;i<=n ;i++)

{

if (n%i==0)

{

count++;

}

}

if (count==2)

{

System.out.print(n+" ");

}

n--;

}

}

}

What is instance?

An individual object of a certain class. While a class is just the type definition, an actual usage of a class is called "instance". Each instance of a class can have different values for its instance variables


A case or occurance of something.

7 Why is binary code suitable for use with computers?

Binary is well suited for computers because it only needs two symbols to represent numbers a 1 and a 0. In a computer a circuit can be in 2 states on and off hence in the simplest implementation"on" represents a 1 and "off" a 0.

What is the difference between interpreter and parser and compiler?

in my personal point of view i would say a parser is more like "one-directional" "automatic" vs. an interpreter, the interpreter has more "intelligence"

What is the difference between traditional programming and object oriented programming?

Object oriented programming is a design paradigm supported by the languages compiler where aspects of the program are thought of as objects. The code (i.e. functions) and variables required by those methods are grouped together into objects. The object exposes methods to the programmer so the object can be manipulated. There are more advanced aspects of object oriented programming such as polymorphism and inheritance that allow more high level and abstract usage of objects.

Function oriented programming treats functions and variables separately. Functions are used like machines; they take in variables, manipulate, and return them. The variables and functions required to accomplish a task aren't grouped together as in object oriented programming.



For a large project object orientated programming is more flexible and easier to understand. Small, very specific tasks, can some times be best accomplished with straight forward function oriented programming.

How do you open a corrupt rar file?

Several methods are available to open a corrupt Word file. Some of them are given below:

  1. Open & Repair method: Free & Offered by Microsoft
  2. Start your Word in 'safe mode': Free
  3. Open you Word file in another format like RTF: Free
  4. Try to open on different computer: Need second computer
  5. Repair & Open by free Word repair program: Free
  6. Repair & Open by paid Word repair program: Paid but nominal charge

What is the name of the first programming language?

1950 - EDSAC - > This is the First Programming Language i know

next is..

1954 - FORTRAN

1958 - ALGOL - 58

1958 - LISP

1960 - COBOL

1964 - RPG

1964 - PL\1

1965 - BASIC

1967 - LOGO

1968 - APL

1970 - PASCAL

1970 - Smalltalk

1971 - FORTH

1972 - PROLOG

1972 - C

1979 - Ada

1981 - Modula -2

1982 - Dbase

1984 - Turbo PASCAL

1987 - HyperCard

1990s - Visual Basic

1990s - HTML, VRML and JAVA

I got this from my book when im in HighSchool ^__^

What variable scope is preferable?

Shorter lifespan, the better (preferable): local.

In some languages, local means within a {-} or begin-end pair, not necessarily a method/function. For example:

void MyDummyOperation() {

int i;

// 10+ lines of codes before the first time of using i

}

void LocalDemo() {

if (1==2) { int i = 0; ....}

}

Notice the local variable int i is declared at the true-branch of the if-statement (although the condition will not be evaluated to true) in LocalDemo() method. That variable cannot be seen outside of that scope, while the one in MyDummyOperation() has a life span of the entire function.

Write an assembly language program for arranging nos in the ascending order?

title ascending order using bubble sort

.model small

.stack 64

.data

a db 34h,78h,56h,47h

si_ze dw $-a ;si_ze=no of elements

.code

bubsort:

mov ax,@data

mov ds,ax

mov bx,si_ze

dec bx ;bx=no of passes needed to complete sorting(n-1)

outlup:

mov cx,bx ;cx=no of comparisions to be performed in a pass

mov si,0

inlup:

mov al,a[si]

inc si

cmp al,a[si]

jb go_on

xchg al,a[si]

mov a[si-1],al

go_on:

loop inlup ;dec cx,until cx=0

dec bx

jnz outlup

int 3 ;breakpoint interrupt

align 16

end bubsort

Does machine code means assembly language?

No. Assembly language is a low-level symbolic language that needs to be translated (assembled) to produce the machine code. The reverse of assembly is disassembly, where machine code is disassembled to produce code that is similar to assembly but has no symbolic names or comments. Disassembly is essentially a human-readable version of machine code whereas assembly is the code written by a human in order to produce the machine code, the only language the machine actually understands.

How the data and functions are organized in object oriented programming?

We can think of an object is being an aggregate of one or more data types, where each member is allocated memory according to its type, and one member immediately follows another in the order it is declared. The total size of an object is therefore equal to the sum of its member types. However, some types need to be padded so they begin on a word boundary (such as a 4 byte boundary), so there may be unused padding bytes between certain members. This is why we strive to declare data members in descending order of size to minimise wastage.

Public and protected members are also inherited from base classes and are therefore part of the derived object, however private members are also part of the object (they're simply not accessible via the derived object), thus the total size will include those members as well. As such, each member can be accessed indirectly as an offset from the start address of the object. However, the compiler takes care of this for us, we can simply access object members through their given name (so long as access is permitted of course).

While every object of a class has its own discrete set of member data, as determined by the class definition, there is only one instance of each member function. The compiler knows which instance of the object to operate upon because a hidden "this" pointer is passed to every non-static member function. Thus the member functions are not considered part of the object per se, they are part of the class.

Every class that declares or inherits a virtual function also has its own virtual table, which is an aggregate of its base class virtual tables plus any of its own virtual function declarations. Each entry in the table points to the most-derived override for each virtual function. This ensures that the most-derived override is invoked even when the function is called against one of the object's base classes.

As such, there is only one implementation of every function in a program, and each has a unique address regardless of how many objects that function is a member of. This is similar to the way in which static member functions are shared by all instances of a class, the only difference being that static member functions do not receive a "this" pointer. By the same token, there is only one instance of each static data member which is shared by all objects of the class but is not associated with any specific object of the class. All static data members are allocated in the program's data segment whereas non-static member data is allocated on the stack unless the object is allocated dynamically upon the heap.

What is the defferences between flowchart and pseudocode?

A flowchart is a graphical approach to describe the computer program's logic process.

Pseudocode is a mock-up code written using easy-to-understand words to describe the details of that logic just before drafting the actual code to build the program.

What is awk in unix?

AWK is a programming language developed in 1977 by Alfred Aho, Peter Weinberger, and Brian Kernighan. It is was developed as a text-processing language - it has simple syntax to match lines of patterns, separate out the fields, and operate on them.

What is the Swift programming language?

Swift is an Apple programming language for iOS, macOS, watchOS, tvOS and Linux. It is a general-purpose, multi-paradigm, compiled programming language which can inter-operate with C, C++ and Objective-C code in the same program.

What is the merits and demerit of recursion in algorithm?

The advantages of recursion tend to revolve around the fact that there are quite a few algorithms which lend themselves to recursion (tree traversal, binary searches, quick sort, etc.)

The disadvantages of recursion include:

* finite number of recursive steps (limited heap space) * speed/efficiency (easier to increment a loop counter than call a function)