answersLogoWhite

0

/* the sequence printed is Fibonacci's sequence, each element is calculated as a sum of two previous elements */
#include
int main()
{
int i;
int n;
int a0=0;
int a1=1;

printf("How many elements do you want to print? ");
scanf("%d",&n);

printf("0 ");
if (n > 0)
printf("1 ");


for (i = 2; i <= n; i++)
{
printf("%d ", a0+a1);

a1 = a0 + a1;
a0 = a1 - a0;

}
return 0;

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What is the return value of getch?

getch(); is used for unbuffered input. e.x: int main() { char num=0; printf("Press a keyboard button: "); num = getch(); //This brings in 1 character that the user pressed on the keyboard printf("\nYou pressed: %c", num); //This prints the character you pressed getchar(); // I am using getchar(); to stop the program from ending after pressing buttons return 0; } My input will be within the (). output: Press a keyboard button: (v) You pressed: v EOP //End of program I hope this has helped you!


How do I make a if a certain key is pressed do a set of code in Lua?

In Lua, you can use libraries like LÖVE (Love2D) for handling keyboard input. You can define a function like love.keypressed(key) to detect when a specific key is pressed. Inside this function, you can use an if statement to check if the key matches your desired key and then execute the corresponding code. For example: function love.keypressed(key) if key == &quot;space&quot; then -- Code to execute when space is pressed end end This will run the specified code whenever the spacebar is pressed.


What is the difference between Scan code and the ASCII code for a keyboard key?

A scancode (or scan code) is the data that most computer keyboards send to a computer to report which keys have been pressed. A number, or sequence of numbers, is assigned to each key on the keyboard.


Write a program for event handling mouse and keyboard events?

So far the only event used is the on_draw event. To react to keyboard and mouse events, it's necessary to write and attach event handlers for these events as well: import pyglet window = pyglet.window.Window() @window.event def on_key_press(symbol, modifiers): print 'A key was pressed' @window.event def on_draw(): window.clear() pyglet.app.run() Keyboard events have two parameters: the virtual key symbol that was pressed, and a bitwise combination of any modifiers that are present (for example, the CTRL and SHIFT keys). The key symbols are defined in pyglet.window.key: from pyglet.window import key @window.event def on_key_press(symbol, modifiers): if symbol == key.A: print 'The "A" key was pressed.' elif symbol == key.LEFT: print 'The left arrow key was pressed.' elif symbol == key.ENTER: print 'The enter key was pressed.' See the pyglet.window.key documentation for a complete list of key symbols. Mouse events are handled in a similar way: from pyglet.window import mouse @window.event def on_mouse_press(x, y, button, modifiers): if button == mouse.LEFT: print 'The left mouse button was pressed.' The x and y parameters give the position of the mouse when the button was pressed, relative to the lower-left corner of the window. There are more than 20 event types that you can handle on a window. The easiest way to find the event name and parameters you need is to add the following line to your program: window.push_handlers(pyglet.window.event.WindowEventLogger()) This will cause all events received on the window to be printed to the console.


How many times should the keys of a keyboard be pressed in order to type the first 300 counting numbers?

792

Related Questions

What combination keystrokes initiate a shutdown?

[(Ctrl + Alt)* + Delete] Tab + Tab + Enter + Enter *both left side the one in [ ] needs to be pressed all at the same time, the following buttons need to be pressed normally then after..


What is pressed in Tagalog?

Tagalog Translation of PRESSED: idiniin


Are rotors on a 1995 Saturn pressed on?

No, they are not pressed on.


How many syllables is pressed?

Pressed has one syllable.


What is pressed steel door frame?

what is pressed steel


What is pressed corn?

It is corn that is pressed, its not rocket science


Is a front wheel bearing on a 1991 Honda Civic pressed on not pressed?

Yes it is pressed, have a reputable shop do it for you though!!!


What does key sequence mean?

A key sequence refers to a specific combination of keys that are pressed in a particular order to perform a function or command in software or hardware. It is often used in programming, gaming, or software applications to trigger shortcuts or actions. For example, pressing &quot;Ctrl + C&quot; is a key sequence for copying selected text. Key sequences can enhance efficiency by allowing users to execute commands quickly without navigating through menus.


Where can you get your cricket bat pressed?

when you buy it,it should already be pressed!


How does cotton get pressed?

Usually, cotton cloth is pressed with an iron.


What is a past participle of press?

The past participle of &quot;press&quot; is &quot;pressed.&quot;


When pressed this key is pressed to display an item's shortcut menu?

Application