answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What is the purpose of gcc?

I suppose GCC can have many meanings. The only interpretations that come to mind in context with computer programming are the GNU Compiler Collection or the GNU C Compiler (which is part of the compiler collection).

The GNU C Compiler allows creating software in various dialects of the C language family, aimed at a multitude of target processors and operating systems.

Write a program WAP to print a given integer in the reverse order?

int n; // the number you want to reverse

int rev_n = 0;

while (n > 0) {

// shift rev_n digits left

rev_n *= 10;

// put rightmost digit of n onto right of rev_n

rev_n += n % 10;

// remove rightmost digit of n

n /= 10;

}

Is PROLOG is an example of a fourth generation programming language?

Not really. Officially, there is no such thing as a fourth-generation language (4GL). The term 3GL first appeared after the third-generation of hardware first appeared and applied to all high-level languages, including PROLOG. Today we do not use terms such as 4GL or 5GL as they are just meaningless buzzwords coined by marketing types. Today, all high-level languages are classified according to whether they are imperative, declarative, functional, object-oriented, and so on. PROLOG, in its un-extended form, is an example of a declarative language.

What is multidimensional arrays?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right.

A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables.

Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.

The more common name for the programs or instructions on your computer?

Software. Anything that is not hardware (a physical device) is software. This includes both the programs and data used by those programs.

What is the purpose of object oriented programming?

The answer lies in difference in Object oriented and variable based technology. Object oriented technology has a lot of benefits. One of which is that it eliminates declaration of variables for every time usage. It means that disk space is saved as variables are declared only once and only object is created further which gets an instance of these variables. It makes logic to easy implement and understand. Its systematic way of implementing a problem statement.

In PHP How do you print this pattern h h e h e l h e l l h e l l o?

String hello = "hello";

for(int i = 0; i < hello.length(); i++){

System.out.print(hello.substring(0,i+1));

}

/*

* This loop will loop over the string "hello". For each loop it will print

* the entire string from the beginning to the index of i. Therefore, the

* first loop will print hello.substring(0,1), or "h". The next loop will

* print hello.substring(0,2) or "he". These are all printed together so

* it becomes "hhehelhellhello"

*/

Who developed an algorithm?

Here are some of the first we know of:

* Babylonians, 1600 BC - factorization and square roots
* Euclid, 300 BC - greatest common divisor (GCD)
* Eratosthenes, 200 BC - prime numbers
* Liu Hui, 263 AD - systems of linear equations

See related link.

What is the first object oriented programing language?

Smalltalk was the language created as a proof-of-concept implementation of the object-oriented programming paradigm.

What are the parameters for measuring the efficiency and performance of a computer system?

  1. effectiveness of the system if whether it achieves its goals or not.
  2. efficiency , check if what is produced is it the product that was supposed to be produced.
  3. complexity ,checking on how the system elements are complicated .
  4. control ,operate under the given instruction.

Name different programs that can be used on a computer?

Some of the common examples of scientific software include those used to predict weather, those used in prediction of genome structure, etc.

Basically scientific software's are those that are used to perform some rigorous calculations which help in understanding some physical process.

Is it better to use malloc or calloc to allocate memory?

In general using malloc is faster, since calloc initializes the allocated memory to contain all zeroes. If this is what you want, however, then calloc can be used. The results can vary among different operating systems and environments, though. Memory allocation in an OS that uses floating blocks in heaps, such as Microsoft Windows and MacOS, should use the OS-native memory allocators instead. "Use malloc() almost always and calloc() almost never." The reason is that the initialization to zero that calloc() performs is usually not very helpful: - The initialization to "all-bits-zero" is not necessarily the same as initialization to "all-data-zero." C says very little about the representation of values in memory, nothing at all for floating-point or pointer values. On many machines all-bits-zero representations will in fact correspond to f.p. zeroes or null pointers, but this is not guaranteed by the language and there have been machines where the correspondence did not hold. If you get in the habit of using calloc() to initialize f.p. and pointer items, you may be heading for trouble. - Usually, one allocates a chunk of dynamic memory in order to store something in it -- and when you store something in it, you'll overwrite whatever was there before. Thus, the initialization performed by calloc() is usually not needed anyhow. There are occasional exceptions where all- bits-zero initialization is helpful, but they are unusual.

Can you provide a solution to the diamond-square algorithm using Java and recursion?

Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.

How do you open gcc compiler in ubuntu?

You don't "open" gcc, you "use" it.

$ cat >helloworld.c

/* helloworld.c */

#include

int main (void)

{

puts ("Hello, world");

return 0;

}

^D

$ gcc -W -Wall -pedantic -o helloworld helloworld.c

$ ./helloworld

Hello, world

Under what circumstances would a user be better of using a time-sharing system rather than a PC or single-user workstation?

In early computing days, computers were expensive, and so to absorb the cost, a big computer would be shared across many people who would pay for time-sharing (such as one hour units). The limiting factor, money, would be the only reason why someone might use a time-sharing system. For that individual, their use of a computer is so infrequent that they cannot justify purchasing an actual computer, or their current hardware is inadequate for their needs, so they lease time on a more powerful system to play games, process data, etc.

Time sharing is most frequently found today in terms of "virtual machines", such as virtual servers or virtual desktops that are accessed remotely through a less powerful system or even a thin client (a keyboard, mouse, and monitor connected to a very small computer with only enough RAM and CPU power to access the remote desktop). It is projected that as computer networking and virtualization becomes more powerful, time-sharing will soon replace or heavily supplement PCs and single-user workstations.

Algorithm to insert and delete an element from a circular queue?

The Method To Add an element in Circular Queue

# define MAXQUEUE 100 struct queue{

int items[MAXQUEUE];

int front, rear;

}

struct queue q;

q.front=q.rear=MAXQUEUE -1;

void ENQ(struct queue *pq, int x)

{

/* make room for new element*/

if(pq ->rear = MAXQUEUE - 1)

pq-> rear = 0;

else

(pq->rear)++;

/* check for overflow */

if(pq ->rear==pq->front)

{

printf("queue overflow);

exit(1);

}

pq->items[pq->rear]=x;

return;

}/* end of ENQ*/

A Method to Delete an element from Circular Queue

int DQ(struct queue *pq)

{

if(pq-> rear == pq-> front)

{

printf("queue underflow");

exit(1);

}/*end if*/

if(pq->front = = MAXQUEUE-1)

pq->front=0;

else

(pq->front)++;

return(pq->items[pq->front]);

How program written in high level language changed into machine code?

The way you stated your question is rather confusing, but what I think you're asking is, "are programs written in high level languages called compiled programs?"

Well, not all high level languages are compiled. Python, for example, is interpreted, instead of compiled. Many, such as C++ (although that is more medium level) are compiled. In general, one would not call a program written in a compiled language a "compiled program" until it's been compiled.

How do you convert excel document into pdf file in 2010?

Download and install the free PrimoPDF. This provides you with a PDF print driver which you can use to print any document. However, travelling back in time to 2010 I can't help you with.

What is pointer to function in c?

Accessing data by their address. A good example is parameter argv of function main.

1. Easy access

2.To return more than one value from a function.

3. To pass as arguments to functions. For eg. consider the following structure

struct student

{

char name[10];

int rollno;

};

If you pass this structure object as argument to function then, 14 bytes(10+4) of memory will be passed to the function. Instead, if you pass the pointer to the structure as argument then only 4 bytes (or 8 bytes)of memory will be passed to the function.

C program for upper triangular matrix for a given matrix?

This sounds very much like a homework problem. If you work on it and get started, you found a great place to ask a specific question. However, this is not a place to have your homework done for you.

What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop

Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 2?

public static void main(String[] args) { int count = 0; int sum = 0; for(int i = 100; i < 200; i++) { if(i%7 == 0){ System.out.println(i); count++; sum = sum + i; } } System.out.println("Number of values divisble by 7 is: " + count); System.out.println("Sum of the values divisible by 7 is: " + sum); }

How do you write a java program to find a prime number?

#include<stdio.h>

bool is_prime (unsigned n) {

if (n<2) return false;

if (!(n%2)) return n==2;

unsigned max_factor = (unsigned) sqrt (n) + 1;

unsigned factor;

for (factor=3; factor<max_factor; ++factor) {

if (!(n%factor)) return false;

}

return true;

}

unsigned next_prime (unsigned n) {

while (!is_prime (++n));

return n;

}

int main() {

/* print the first 100 prime numbers */

unsigned i, n=0;

for (i=0; i<100; ++i) {

n = next_prime (n);

printf ("%d\n", n);

}

return 0;

}