answersLogoWhite

0

What is the default value of int in c?

Updated: 8/17/2019
User Avatar

Wiki User

8y ago

Best Answer

I'm not sure. I have written C programs in which the default value was what ever happened to be in the variable's memory location when the space was allocated. So it could be 0. Or it could be anything. That is why it is always important to initialize variables when using C.

I don't know if this is true with modern C compilers.

No default value for automatic variables, 0 for others.
User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the default value of int in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does default mean in Excel?

The default settings are those settings that are automatically used when a program is run. For example, the default typeface in MS Word is Times New Roman and the default size is 10 point. Likewise the default paragraph spacing is single line, so if you wanted a double space between paragraphs you would have to hit Enter twice. However, all default settings can be altered, so you could elect to have whatever typeface you choose, at whatever size you choose, with whatever spaces between paragraphs you choose.


What is (void)0?

A default argument is a function argument that has a default value. That is, if no value is specified for the argument, the default value is used. Only the trailing arguments of a function can be default arguments. That is, if an argument has a default value, all arguments that follow it must also have a default value: // declarations: void f (int=42); // ok void g (int, int=42); // ok void h (int=42, int); // compiler error (trailing default argument missing) // calls: f (); // ok -- invokes f(42); f (0); // ok -- invokes f(0); g (0); // ok -- invokes g (0, 42); A default value cannot be repeated in a function's definition unless that definition is the only declaration: // declarations: void f (int=42); void g (int=42); // definitions: void f (int x) { /* ... */ }; // ok void g (int x=42) { /.../ }; // error void h (int x=42) { /* ... */ }; // ok


What does c plus plus use call by value or call by reference?

When we call a function in C++ by passing the values as arguments, it is called call by value. e.g #include<iostream.h> #include<conio.h> int add(int,int); int main() { int a,b,c; cout<<"Enter numbers."; cin>>a>>b; c=add(a,b); cout<<"Sum : "<<c; return 0; } int add(int a,int b) { int c; c=a+b; return c; }


What is default value of formal arguments?

In C, there is no default value for formal parameters. In C++, there can be, but the value is whatever you declare in the function declaration.


What are default arguments in c plus plus?

Default arguments are function parameters for which a default value is implied when not explicitly stated. int foo(int x, int base=10 ) { return( x%base); } The above function assumes 'base' is 10 unless you specify otherwise when making the call. Thus calling foo(15) will return 5, as will foo(5,10), but foo(15,16) will return 15. Note that default parameters must appear after all non-default parameters in a function declaration. Once you specify a default parameter, all other parameters that follow must also have default values. Note also that when the definition of a function is split from its declaration, only the declaration should declare the default parameters: // Declaration: int foo(int x, int base=10 ); // Definition: int foo(int x, int base ) { return( x%base); }


How do you write a c program to find largest of 3 numbers using pointers?

Find the largest of two, then find the largest of that value and the third value. int* max (int* a, int* b) { return (a*) > (b*) ? a : b; } int* max_of_three (int* a, int* b, int* c) { return max (max (a, b), c); }


What is the by default value of globally declaration variable?

int, float: 0 pointer: NULL


What is the initial value of a numeric variable?

When we talk about instance variables, the default initial value for a numeric variable is always '0'. Any other variable in your code must be initialized before you can use it. public class MyClass{ public int x; // 0 by default public float y: // 0 by default public MyClass{ int z; z++; // Error 'z' don't have a default value } }


Why the return type of all the function by default is int in c?

Because int is the most common data-type in C. Don't rely on this though, always specify the return type explicitly.


What is the initial value of (-1-17) and (-3-15)?

When we talk about instance variables, the default initial value for a numeric variable is always '0'. Any other variable in your code must be initialized before you can use it. public class MyClass{ public int x; // 0 by default public float y: // 0 by default public MyClass{ int z; z++; // Error 'z' don't have a default value } }


What is the default value of integer in java?

According to the JLS, the default value of an int is 0. The default value of an object of type Integer is null. Of course, this applies only to class members fields, as local method-level fields must be explicitly assigned a value before use.


What is the default value of integer in c?

For static and global variables it is 0; automatic variables are not initialized by default.in the c language there is no default value for non static local variables. The variable holds whatever was in memory before it became a variable. It's best to always initialize a non static local variable before using it in the c language (or at least before comparing it to something else). Also It's best to assume that there is no default value because this varies from language to language, and hardware to hardware.Cheers!