answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

What is an example of using recursive functions?

Let's take the example of finding the factorial of a number (of a positive integer). The factorial of N is N * (N-1) * (N-2) * (N-3) ... * 3 * 2 *1 It is the product of all integers between that number (including that number) and 1. For example, factorial 2 = 2*1 = 2 factorial 3 = 3*2*1 = 6 factorial 4 = 4*3*2*1= 24 Now you define a recursive function Fac (N) as Fac (N) = Fac (N-1) * N, with Fac(1) predefined as 1. Thus, Fac(N-1) = Fac(N-2) * (N-1) and Fac(N-2) = Fac(N-3) * (N-2) and thus recursion takes over until such time fac(1) needs to be evaluated. We know the value of Fac(1) which is set as 1. Thus we can evaluate Factorial(N) using recursion.

How can the value of a j c Higgins 22 cal pellet pisol 12619380 be found?

Check "Blue Book of AirGuns 7th edition" Both Daisy and Crosman made Airguns under the J C Higgins name for Sears.

If then else statements and case statements essentially perform the same function when would you use one over the other?

I would recommend an If - then - else statement over a switch statement because:

1. It is simpler/easier

2. You do not get unexpected output because of missing break statements

A missed break statement in one of the conditions in a switch case statement means that all the conditions that come after the success condition are executed. In case of if else this is not the case and hence it is much safer for novice programmers.

> essentially perform the same function

No, they don't. Here is an example to prove this:

if (sin (alpha) > cos (alpha)) {

...

} else if (alpha / M_PI * 180 > 180) {

...

} else {

...

}

Why return 0 is used in int main function in c?

It depends on the context.

- it means "no" in functions that check something (like "isatty", "isascii", "isdigit")

- it means "success" in functions whose return value is an error code (0 means no error)

- it means "fail" or "not found" in functions that return a pointer (like strchr or fopen).

If the length of a piece of string... is any length of string cut from a spool... 'what is the maximum length of a piece of a piece of string' or 'how much string is on a spool'?

100 metres seems to be the length of a spool of gardeners cotton Discuss:How_long_is_a_piece_of_string...we are not talking about jute twine here!So the maximum length of a piece of string would be 999.99mm!So the real answer to 'how long is a piece of string?' would be...anything between 0.01mm to 999.99mm.

How many bytes in an address of an int variable?

32 bits or 4 bytes and an int is not an address, it is a primitive so it directly access the data without a reference.

What programming languages are used in programming an EEPROM?

In one sense, since EEPROM is memory, you don't program memory. You store things in memory, and the thing you are programming in this case would likely be a micro-processor or micro-controller that is on the same circuit as the EEPROM.

In theory, an EEPROM is just memory, so any language that would be able to produce machine language output for the CPU type connected to the EEPROM in any instance could be used.

In practice, many programs written to EEPROM would be for embedded systems. In this case, a lower level language like C could be used, or a higher level language that output C or the right kind of assembly.

A higher level language like C# or Java would likely not be used, as the overhead of the virtual machine might be considered to be too heavy for a micro-controller, or small micro-processor.

That being said, in practice, you could use anything. But it is likely you would have some libraries in C or C++ that you might want to use, so you would likely use a language that was compatible with any libraries you might use.

yah it's correct.

Which comma is used for characters in switch case statements?

There is only one comma, but it is not used in switch-case. Character literals are between apostrophes: 'x'

What is real world object?

Take a look around you! The world is just full of objects. The sun, trees, birds, flowers, are all objects created in God's divine plan. Everyday you should give thanks to the Maker who declared and instantiated you and I and all living and nonliving things.

Why is cyclic inheritance not in any programming language?

Cyclic inheritance is physically impossible. A base class cannot inherit from one of its own derivatives any more than you could inherit some generic trait from one of your own descendants. Inheritance is strictly a one-way street.

How should you design a scientific calculator using C plus plus?

The easiest way to implement a calculator is an RPN calculator (enter the numbers first, perform the operation last). You need a last-in-first-out stack (there's a "stack" class in C++, but you can also implement your own using an array or a linked list), and a set of functions that pop the last elements from the stack and push the result (e.g. Add() pops the last 2 values and pushes their addition).
You'll need the math.h library for scientific operations.

Why wont your c plus plus program stay open?

If you are talking about the program executing, but the output screen being displayed for a flash and then disappearing, I suggest adding getch() or getchar() function at the end of your main function. This will make sure that the output screen waits for you to press a character before the program terminates.

Can Array-based lists can never be empty?

It's either an array or it's a list, it cannot be both. However, an empty array is entirely possible:

std::vector<int> my_vector; // an empty array

my_vector.push_back(42); // an array of 1 element

my_vector.push_back(1); // an array of 2 elements

my_vector.clear(); // an empty array

An empty list is also possible:

std::list<int> my_list; // an empty list

my_list.push_back(42); // a list of 1 element

my_list.push_back(1); // a list of 2 elements

my_list.clear(); // an empty list

The same thing can be done in C:

int* my_array = nullptr; // an empty array

my_array = malloc (2*sizeof(int)); // an array of 2 elements

my_array[0] = 42;

my_array[1] = 1;

free my_array; // an empty array

my_array = 0;

How do you make a game more better in Roblox?

Probably you just like to insert a bunch of free models and Bam is done. Well it isn't so easy. If you are only a beginner to make a game better after you insert some models.

Ungroup them (Click model and press Ctrl + U) and change it to make a whole lot different. If it just a plain part, retexture it in to wood and change it brown. If it is small resize it or rotate it. After you're done Regroup it back in to a Model. Highlight all the parts you want to group or Hold Shift and Click all the parts and Regroup it (Ctrl + G)

Not that you think you are done but it just the beginning, Next you will think all the Models aren't in the right position. First you have to Click the Collision button to make models collide with each other. Do not drag the models where you want it, You have to Click the Move button (A Cross with arrows) Then drag one arrow to make it where it is.

Wait a minute, You will get this problem: Everytime you drag something either its not really precise, There are 3 buttons next to Collision: 1 stud 1/2 stud and Off, Well for moving big models around I recommend turn it OFF if you make a game from scratch, use either 1/2 Studs and off.

Then you will want to make the game more real Click Lighting in the Explorer (Click View Section, Click Explorer) and Click Properties while you at it. Then Click Lighting, In the properties you will see a lot of Settings, Ambient, Brightness, etc. You can mess with everything except: FogStart and GeographicLatitude.

After all you can Publish or save your game.

Write a program to find the sum of first 20 odd numbers in foxpro?

set status off
clear
input "Enter any number" to num
p=2
do while p<=num
if num%p=0
exit
endif
p=p+1
enddo
if p=num
?"prime"
else
?"not prime"
endif
return

Can structures be passed to the functions by value?

Structures can be passed to the functions by value. But it has to be copied to another location. Hence wastage of memory

When an array name is passed to function in c?

It 's address is received by the function .

that any changes in the value of array elements in the function will result in actual change.

What is the c program for the 3 numbers determine whether they form the sides of a triangle?

The length of one side is smaller than the sum of the lengths of two other sides, and bigger than their difference. The bigger side stands in opposite to the biggest angle.

Is it necessary to read or display the elements of an array in order of its subscripts?

By no means; you can access any random array element. If you have ever seen examples which process them in order, it is because of the following: when the order doesn't matter (for example, you want to calculate the sum of all the array elements), it is easiest to process them in order.

How do you write a program to enter your name in c using?

/*to print your namr*/

/*by girish kumar raghuvanshi*/

#include<stdio.h>

#include<conio.h>

void main()

{

printf("print ur name");

puts("girish");

getch();

}