answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

How to run C graphics program?

"http://wiki.answers.com/Q/How_to_run_C_graphics_program"

How to write a C program to generate Fibonacci series up to 10 elements and store in array?

#include <iostream.h>

#include <conio.h>

#include <stdlib.h>

int swap(int* , int*);

int main()

{

int c=0;

int b=1;

int max;

cout<<"Enter the maximum limit of fibbonacci series = ";

cin>>max;

if(max>0)

{

cout<<c<<endl;

}

else

{

exit (EXIT_FAILURE);

}

for(int i=0;i<max;i++)

{

c=b+c;

swap(&b,&c);

if(c<max)

{

cout<<c<<endl;

}

else

{

break;

}

}

getch();

return 0;

}

int swap(int *x,int *y)

{

int z;

z=*x;

*x=*y;

*y=z;

return z;

}

Who is the first discovered the speed of light?

The speed of light was measured by Ole Christensen Romer. He watched the moons of Jupiter, and observed that their movement around Jupiter appeared slower when the earth was moving away from Jupiter than when earth was moving towards Jupiter. This was because the light from the moons took longer to reach earth. He concluded that the speed of light is 220,000 kilometers per second. It is in fact 300,000 km/s, so he wasn't too far off.

In 1849, Hippolyte Fizeau performed the first earth-bound measurement of the speed of light. A beam of light was reflected off a two-way mirror; it then went through the teeth of an opaque cogwheel rotating very fast, was reflected off a mirror, returned through the teeth of the cogwheel, and went through the two-way mirror to a detector. In the time it took for the light to get from the wheel to the mirror and back, the wheel rotated slightly, which meant that some of the light which had previously gone through was blocked by the cogs. So the finiteness of the speed of light made the light slightly dimmer. By measuring its brightness, he calculated that the speed of light in vacuum was 313,000 km/s.

Fizeau's experiment was important because it could be used to measure the speed of light in any medium, whereas Romer's observation only worked for the speed of light in vacuum. Fizeau discovered that the speed of light is faster in air than in other media. This helped to resolve the long-standing question of whether light consists of particles or waves - the particle theory supported by Isaac Newton predicted that the speed of light would be slowest in a vacuum.

Someone observed that the speed of light was (up to experimental error) exactly equal to 1 / sqrt(epsilon * mu), where epsilon and mu are fundamental constants connected with electricity and magnetism, respectively. At the time, this observation just seemed weird. But when James Clerk Maxwell published his equations for electromagnetism, which predicted the possibility of waves travelling at this speed, it all made sense: light consists of electromagnetic waves. So if we want to measure its speed we only have to measure epsilon and mu. The values of epsilon and mu are different in different media, so this explains the differences in the speed of light.

Define Syntax Error in computer?

A syntax error is a scenario in programming where the code that is written by a programmer which is incorrect as per the language structure. For example I say the following statement in English: it is syntactically wrong:

I currently in write java questions for wikianswers yesterday and tomorrow all day short.

If you see the above statement, it is grammatically wrong. That is exactly what a syntax error is for a java program. It is incorrect as per the programming language specifications.

How can you sort an arraylist of strings?

You can sort an ArrayList by using the sort method of the Collecions class (java.util.Collections). Assuming you have an ArrayList called foo: Collections.sort(foo);

In C programming a character variable can at a time store how many characters?

You can store one, however if you make a char array:

char[50];

You can make a string out of your array of characters.

When do you declare a member of a class static?

Static members should be used whenever you have a member that is logically considered part of the class, but is not associated with any instance of the class. They are bit like global variables and functions but there's more control over their visibility outside of the class.

Static member methods can be thought of as being global functions that are scoped to the class (rather than to each instance of the class). As such, they do not inherit an implicit this pointer and can therefore be called without instantiating an instance of the class (access specifier permitting). However, any and all instances of the class have unrestricted access to all the static member methods of the class.

Static member variables can be thought of as being global variables that are scoped to the class (rather than to each instance of the class). That is, all instances of the class share the same set of static member variables amongst them, rather than each having their own (as they would with non-static member variables). Static member variables are also accessible to static member functions. As with all other static variables, they are initialised at compile time (which must be done outside of the class declaration), and will remain in scope for the entire lifetime of the program.

All static members are subject to the public, protected or private access specifiers, so while they can act like global variables and functions if declared public, their visibility outside of the class can be limited to private or protected access.

Possible uses for static members are many and varied. By way of an example, suppose you want to maintain a read-only count of all instances of a class. The following framework demonstrates how this can be done with static members:

class Object

{

public:

Object(){++s_instances;}

~Object(){--s_instances;}

static unsigned int GetInstances(){return(s_instances);}

private:

static unsigned int s_instances;

};

// Static member variable initialiser (evaluated at compile time):

unsigned int Object::s_instances=0;

int main()

{

cout<<"Current instances:\t"<

Object * p1 = new Object();

cout<<"Current instances:\t"<

Object * p2 = new Object();

cout<<"Current instances:\t"<

delete( p1 );

cout<<"Current instances:\t"<

delete( p2 );

cout<<"Current instances:\t"<

}

Output:

Current instances: 0

Current instances: 1

Current instances: 2

Current instances: 1

Current instances: 0

Previous Answer

In the code, if you want to have only one instance of the member variable irrespective of the number of objects created for that class. In these kind of scenarios static members are used

Does a cylinder have 4 sides?

It is the area of the ends of the cylinders which is Pi x r^2 so we have two of those and the total is 2 Pi r2 now add to the the area of the sides. This is 2x Pi x r x h so the total surface area is: 2 Pi r2 +2Pi x r h

Advantage of flowchart in c language?

Pre-test loop in C#

bool condition = false; [NOTE: this line is not part of the loop it is the condition which must be met for the loop to occur. If it is not satisfied the loop does not happen.

while (condition == false)
{
Do stuff
condition = checkCondition();
}

To draw this as a flowchart you just have to show that your flowchart can repeat a step/steps indefinitely depending on a condition

What is 0.65 as a fraction?

0.065 is a fraction. It is a fraction in decimal form rather than in the form of a ratio. However, that does not stop it being a fraction. Its rational equivalent is 65/1000 which can be simplified. But simplification will mean that you lose information about the precision of the fraction.

Name two languages which are used for client side scripting?

Two different client side scripting languages are JavaScript and VBScript.

Scripting languages are not compiled and run on the client machine (in most cases, the web browser.)

There are several currently in use. The most popular is JavaScript. It's a prototype-based, object oriented language, with a Java or C-like syntax.

Microsoft has also produced a competing language called VBScript. VBScript has a syntax based off of Microsoft's Visual Basic programming language. It's used in Active Server Pages, and as the Windows Script Host language, used by sys-admins.

What is the purpose of intermediate code generation incompiler?

The intermediate code generation phase transforms parse tree into an intermediate-language representation of the source program.

Intermediate codes are machine independent codes, but they are close to machine instructions.

The given program in a source language is converted to an equivalent program in an intermediate language by the intermediate code generator.

Intermediate language can be many different languages, and the designer of the compiler decides this intermediate language.

  • syntax trees can be used as an intermediate language.
  • postfix notation can be used as an intermediate language.
  • three-address code (Quadraples) can be used as an intermediate language
  1. we will use quadraples to discuss intermediate code generation
  2. quadraples are close to machine instructions, but they are not actual machine instructions.
  • some programming languages have well defined intermediate languages.
  1. java - java virtual machine
  2. prolog - warren abstract machine
  3. In fact, there are byte-code emulators to execute instructions in these intermediate languages.

What is the circumference of a CD?

12 cm approx I'm a little surprised that you haven't got a CD and some sort of ruler or measuring tape near you. The idea of a homework question like that is to help you get some idea of common sizes.

What Is bool data type?

There are a number of data types that we use in computer science. Bool data type stands for boolean data type. In boolean data type the data is stored in form of 0 ans 1s. On boolean data type logical functions like AND, OR ,NOT ,XOR etc functions can be performed.

Write a C program for Sum of factors of a number?

#include<stdio.h>

#include<conio.h>

void factor(int num)

{

int i,sum=0;

for(i=1;i<num;i++)

{

if(num%i==0)

{

sum=sum+i;

}

}

printf("Sum of the factor of %d is %d",num,sum);

}

void main()

{ int num;

printf("Enter the number=");

scanf("%d",&num);

factor(num);

getch();

}

What is need and characteristics of oop?

OOP stands for Object oriented programming.

The main characteristics of OOP are

1. Class

2. Objects

3. Instance

4. Methods

5. Message Passing

6. Inheritance

7. Abstraction

8. Encapsulation

9. Polymorphism &

10. Decoupling

OOP is a concept that allows us to have a program that is

1. "robust and secure".

2. "architecture neutral and portable".

3. "high performance".

What is meant by syntax rules of programming language and a natural language?

Syntax is defined as a set of rules governing how a language is structured, and the relationships between words, Just as in English * we don't put an adjective after a noun - "I have a car blue new" is wrong and "I have a new blue car" is correct... * and the placement of the verb affects the meaning of the sentence. "I have a new blue car" is very different from "Have I a new blue car".

So too do programming languages have rules which say how pieces of code must relate to one another, and in what sequence they must be phrased.

What is the memory's addressibility?

HI I am Ahtarva,

The addressibility is how many bits does that particular processor or micro-controller's architecture use to specify the address of a memory location in the memory. For example if someone say that addressibility is 8 bit then your memory address contains 8 bits and at maximum you have 2^8 different memory locations (or say memory addresses in your device). Here 2^8 is called Address space.

Which rate is the number of signal transitions per period of time?

The number of cycles per second - if that's what you mean - is called the frequency. The unit is the hertz (Hz).

Is python is easy to learn?

Yes, Python is easy to learn. It's very easy to experiment with because it provides you with a interactive environment in the form of a Python interpreter (written for many platforms including those supported by C, Python, Java, and .NET). Enhanced wrappers and tools around the interpreter, for example ipython, really make learning Python easy. Reducing the compile, link, and load time to zero has the effect of saving you tons of time while learning and not having to deal with the complexities of building software. You can leave that part for Python to figure out all by itself at a preliminary stage.

Now, you may begin learning Python and there are several ways to approach it. If you are already a programmer and would just like to see what features Python has to offer to you, you can start with the Python tutorial located here: http://docs.python.org/tut/tut.html. A tool for the Firefox browser, called the Python Sidebar (found at http://www.edgewall.org/python-sidebar/ ), can aid you to quickly look up Python documentation (including the tutorial) within Firefox.

Instead if you are already an accomplished programmer and prefer learning by breaking down examples of real and useful programs, Dive Into Python (http://www.diveintopython.org) written by Mark Pilgrim is an excellent read.

How to Think Like a Computer Scientist is a good book for beginning programmers starting with Python as their first language. While, a second edition of this book is available for free online (at http://www.openbookproject.net/thinkCSpy/ ) as well, I have only read the first edition (at http://www.greenteapress.com/thinkpython/thinkCSpy/ ) of this book online.

While the above-mentioned books are free for reading online, there are some gems that are commercially available for small prices. Beginning Python from Novice to Professional (Magnus Lie Hetland; Apress) is an excellent book for beginning programmers as well. Text Processing in Python (excellent book by David Mertz; Addison-Wesley), Learning Python (Mark Lutz and David Ascher; O'Reilly), Programming Python (Mark Lutz; O'Reilly), and Python Cookbook (ASPN; O'Reilly) are excellent books on the subject as well.

I hope all this information proves helpful to you.

How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n!

int fact(final int n) {

// keep track of factorial calculation in f

// f starts at n, and we will multiply it by all integers less than n

int f = n;

// loop from n-1 down to 2

for(int i = (n - 1); i > 1; --i) {

// increase our total product

f *= i;

}

return f;

}

What is a group of programs that coordinate and control the resources of a computer system called?

A group of programs that coordinate and control the resources of a computer system is called a system software. In other publications, it also includes software development tools like a debugger, linker or compiler.

What is a benchmark?

Benchmarking programs are used to compare computer performance. Here is a list:

3DMark2001se

Most people don't use this program anymore because it's quite outdated, but if you really want the most benchmark utilities you can get then it would be a good program to get. Gamers benchmark. Mediumly recommended.

3DMark03

A program that a lot of people still use. Gamers benchmark. Highly recommended.

3DMark05

A program that only gives good scores if you have very up to date components. Still useful. Gamers benchmark. Mediumly recommended.

PCMark04

Fairly useful benchmarking utility. Mediumly recommended.

PCMark05

An updated PCMark. Mediumly recommended.

SiSoftware Sandra

Very useful benchmarking utility. Able to bench nearly all of you components separately. Highly recommended.

Super Pi

In case the name didn't give it away, this is a program that calculates 4,294,960,000 digits of pi. The benchmark comes in the form of a number (in seconds, perhaps minutes) that shows how long it took your computer to calculate those digits of pi. The simple score readout makes it very easy to compare scores. Highly recommended.

Aquamark3

An excellent gamers benchmark. Fun to watch (at least the first couple times) and very fun UI. Highly recommended.