answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Write a program to exchange the value of two variables?

#include<stdio.h>

void main()

{

int a,b,t;

printf("enter the values of two varaible");

scanf("%d%d",&a,&b);

t=a;

a=b;

b=t;

printf("the exchanged values are",b,a);

}

What are the applications for circular linked lists?

A singly-linked circular list is useful for implementing queue data structures with minimum overhead. Normally we implement a queue with two pointers: one to the tail for insertions and one to the head for extractions. With a circular list we only need to maintain a single pointer to the tail because the tail always points "forwards" to the head (instead of null as it normally would), thus achieving constant-time access to both the head and tail via a single pointer.

Circular linked lists are generally useful wherever "wraparound" is necessary. That is, from any given node in the list, we can traverse forwards with the guarantee that we will eventually arrive back at that same node. With doubly-linked circular lists we have the advantage of traversing in either direction (bi-directional traversal).

What kind of drawing is 3D drawing?

A 3D drawing is when you use shadows and a sense of depth to create space. making the drawing more convincing and ugly.just kidding more real i meant.

What happens if recursion function is declared inline?

An inline function replaces the call to the function by the body of the function, thus reducing the overhead of saving the context in stack. This is good for functions which are small in size and called occasionally. A recursive function calls an instance of itself and thus can be a deeply nested. Different compilers handle this differently. Some will inline it up to a certain depth and then call a non-inlined instance for further recursion; others will not inline the function at all and generate a normal function call.

Why multidimensional array element access using indirection operator?

The number of dimensions is immaterial. All arrays are implemented as a one dimensional array. A multidimensional array is simply an array where every element is itself an array.

The only thing actually known about any array is that its name is a reference to the start address. Unlike an ordinary (non-array) variable, the elements in the array do not have names, we can only refer to them by their memory offsets from the start of the array. As such, in order to obtain the values stored at those offsets, we must dereference them. While the subscript operator gives us notational convenience, it's easy to forget that there's actually pointer arithmetic and dereferencing going on behind the scenes.

What are good books to use to start programming in python if i don't know how to program?

Your best bet as a beginner would be to try Al Sweigart's Invent Your Own Computer Games With Python. It is aimed at beginners, and is written to be easily understandable for people with zero programming experience. It is available for free from his website. (see related link)

The website includes links to other python resources, which are also worth checking out. Once you have gained a little experience in python, you may want to expand your knowledge by working your way through some other python books. The best commercially available book on python that I have come across is Programming in Python 3: A Complete Introduction to the Python Language, by Mark Summerfield.

What are the two methods of representing a binary tree?

Two method of representing a binary tree is

Static allocation, and

Dynamic allocation

What is the difference between looping statements - c program?

Repetition.

For example the following lines do the same thing:

while (expression) statement;

LABEL: if (expression) {statement; goto LABEL; }

Or these: for (exp1; exp2; exp3) statement;

exp1; LABEL: if (exp2) {statement; exp3; goto LABEL; }

What is Dijkstra's algorithm?

Dijkstra's algorithm is used by the OSPF and the IS-IS routing protocols. The last three letters in OSPF (SPF) mean "shortest path first", which is an alternative name for Dijkstra's algorithm.

How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

Please ask just one question at a time!
Question 1:

How do you declare an array of three pointers to chars?

How do you declare an array of three char pointers?


Note: both of these questions are merely alternative wordings for the same question.


Answer 1:

char * a[3];


Question 2:

How do you declare a pointer to an array of three chars?


Answer 2:

char a[3]; // an array of three chars

char * p = a; // a pointer to an array of three chars


Question 3:

How do you declare a pointer to a function which receives an int pointer?


Answer 3:

#include


// some functions we can point at:

void func_1(int * p){}

void func_2(int * p){}

// note: all functions we wish to point at with the same

// pointer must have the same signature.


int main()

{

int* p = NULL; // instantiate an int pointer

void (*pFunc) (int*); // declare a function pointer

pFunc = func_1; // point to func_1

pFunc(p); // call func_1 via function pointer

pFunc = func_2; // point to func_2

pFunc(p); // call func_2 via function pointer

return(0);

}


Note that the brackets in the function pointer declaration are required. If you omit them, you will end up with a standard function declaration that returns a pointer to void, resulting in a compiler error.





Why c is top down approach?

It doesn't. Programmers might use any approach they like.

What is the difference between magnetic media and optical media?

Optical media is written and read on disks with lasers, such as a CD-Roms, BluRays, and DVDs. Magnetic media is written and read with magnets (like your hard drive and a floppy disks (which are almost non-existant anymore)).

What does an abstract look like?

nothing its a piece of art that's nothing really. you remember when you were little when you scribble scrabbled, that was abstract!

What are some types of bugs in software?

Examples of software bugs.

1. Off by one. For instance, If you use an 8-bit register or area of memory, you can only have a range of 0 to 255. However, suppose your code is off by one in an operation. One possible outcome is that the program will crash with an overflow error.

2. Using the wrong Boolean or numeric operator. You might use "less than" when you mean "less than or equal." Or you may interchange AND and OR. So the logic does not work as expected due to using the wrong word or symbol. You might be trying to trap errors and instead, you cause errors.

3. Access after free. If you release a block of memory a program is using, you are not supposed to keep using it. Some other code could be using it. If you read after releasing the block, the data cannot be trusted, since something might have modified it. If you write after releasing the block, you could be corrupting what is used elsewhere.

4. Buffer overrun. That is when a memory operation writes more data to a memory location than declared, and puts data past just the location you are modifying. So it ends up corrupting other data or even the program itself, another program, or the operating system. That will certainly lock up the computer with a blue screen.

Why wont this python program print work?

This is the program that I couldn't fit in the question: Sorry for the underscores but it wouldn't let me indent

# !/usr/bin/python

# Filename: prime5.py

#<---program is supposed to print prime number chosen--->

y = int(input('How many prime numbers do you want to see?'))

x = 6

w = 0

primes = [2,3,5]

z = len(primes)

j = 0

while w != 1:

____if y*0!=0:

________y = input('Please pick another NUMBER: ')

____elif y*0==0:

________w = w + 1

while z <= y:

____if x % primes[j] (j+1) and x % primes[j] != 0:

________primes.append(x)

________x = x + 1

________j = 0

____elif x % primes[j] != 0:

________j = j + 1

print ('These are the numbers you wanted to know', primes)

Difference between event driven programming and traditional programming?

In traditional programming, code was run from start to finish and sometimes asked for input along the way. Event driven programming, on the other hand, does nothing until it gets an event, such as a mouse moving or a key being pressed.

Difference between machine language and binary code?

Machine language is often (incorrectly) referred to as binary language. Binary is a numbering system comprised of zeros and ones. (Also thought of as true/false, or originally from the electronic ancestry, on and off.)

Machine language is the instructions that computers understand. These instructions are comprized of binary values which instruct the CPU to perform specific actions.

When is source code freely available for a program?

In one of two conditions:

  1. public domain code - anyone can do anything they want with this source
  2. open source code - this source is legally copyrighted, but distributed with a licence controlling how you can modify and redistribute

What are the advantage of function prototype?

It allows the compiler to verify that the number and types of the functions parameters are correct when the function is actually called.

If the function were called with the wrong number or type of parameters, and no function prototype were supplied, the error would not be discovered until the program was actually run.

What is the Decimal Binary and Hexadecimal system?

It is a numerical system where each significant numeral represents a change of 2^16th power. Decimal, or, "base 10", is the normal system of decimals. For example, 124 is "10 ^ 2 + 2 * 10 ^ 1 + 4 * 10 ^ 0" (or "one hundred twenty four"). In hexadecimal, each position is 16 base units instead of 10. This makes reading binary code easier, as binary and hex easily convert to each other directly.

Is c sharp a case sensitive language?

Yes.

The upper/lower case chars are regarded as being different in C.

For example, you can have two variables, one called 'x' and the other called 'X' and the compiler will recognize them as separate variables.

What does a high CO2 level indicate?

It means that the levels of carbon dioxide in the blood are increased usually causing a deficient level of oxygen. This condition can cause cells to die.

A device driver is a computer program that makes communication possible between your computer and one of its peripherals?

a device driver is software, making communication between your motherboard and your OS, probably Windows, possible.