answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

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)

Is programming or software development easy?

It just depends on who you are and how you think. To do programming easily, you need a logical mind and you need to know how to think in a step-by-step manner. Ideally, you should have memorized the common commands of the language, but if you don't, that's fine, because you will learn them soon enough with practice.

Happy programming!

What gain is achieved by double buffering as opposed a single buffering?

Buffer is like bucket of data you write to at your own pace so that some other process can read from it at its own pace when it is needed. If you use a single buffer, you may end up overwriting what the other process did not read yet, or the other process may "catch up" with you before you finish writing your current set of data. Basically, you still need to carefully synchronize the two processes. With two buffers, you can write to one buffer while the other process is still reading the other buffer.

How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code:

while ( not(end of string) and letter(string at position X) is not 'P' ){

add(array, newposition) = letter(string at position X);

}

What are the characteristics of gray code?

Due to grey code it is less chance to clamp Wrong....

if something is wrong then due to color code it is identified,,

Presuming the question is about Gray Codes, aka reflected binary code, the primary benefit is that it requires only a single binary digit to change when incrementing or decrementing a binary number.

That is, the Grey Code representation of X (base 10) has N binary digits in it. The Grey Code representation of either X-1 or X+1 requires only a single binary digit to change, out of the N digits which make up the number. Normal binary code can require up to all N digits to change when adding or subtracting a single increment.

The advantage here is cleanliness, in particular for mechanical and electrical circuits. Since it is impossible to absolutely synchronize change of digits, in a normal binary representation of a number, incrementing or decrementing it can leave the number in a variety of intermediary states, of which an outside observer cannot tell which is correct. This can cause all sorts of problems when constructing working devices, that otherwise appear to be perfectly designed in the abstract.

For a better explanation of the mechanics and usefulness of Gray Code, look at the Wikipedia article below.

How do computers translate human language to binary code?

first there are ascci codes for every key word & character. when you press any key it means you have press specific ascci code for that character.

example: if you press 1 its ascci code is 48. so the no 48 will get converted to binary by using of universal gates and encoder, and it will get stored in the ram. then by using decoder and logic gates it again get converted in to human language.

harsheet147@gmail.com

An ellipsis following a menu item tells you what?

The convention is that ellipses following a menu item usually means that the menu item will open a dialog box with further choices, rather than immediately carrying out an action.

What are difference between A and AO algorithm?

# Initialise the graph to start node # Traverse the graph following the current path accumulating nodes that have not yet been expanded or solved # Pick any of these nodes and expand it and if it has no successors call this value FUTILITY otherwise calculate only f' for each of the successors. # If f' is 0 then mark the node as SOLVED # Change the value of f' for the newly created node to reflect its successors by back propagation. # Wherever possible use the most promising routes and if a node is marked as SOLVED then mark the parent node as SOLVED. # If starting node is SOLVED or value greater than FUTILITY, stop, else repeat from 2.