answersLogoWhite

0

Java ints can be any whole number between 2147483647 and -2147483648

22 int

1.5 (illegal as it's a float)

-1 int

2.3 (illegal as it's a float)

10.0 (illegal as it's a float)

5 int

-6875309 int

'7' is a legal int, but it won't be a seven, but the decimal ASCII equivalent (assumes a single character in apostrophes is a char). '7' is 55

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

How do you use malloc and calloc to allocate memory for 100 integers?

int *p, *q; p = (int*) malloc (100 * sizeof (int)); q = (int*) calloc (100, sizeof (int)); Note that p is left in an uninitialised state whereas q is initialised with the value zero.


Write a C plus plus code segment that generates and displays 100 random 3-digit positive integers?

#include<stdio.h> #include<stdlib.h> int main(void) { int i; int j[100]; for(i=0;i<100;i++) { j[i]=rand()%100; printf("%d",j[i]); } }


Declare an array of 100 integers?

int array_name [100];


What are constants in computer programming?

A constant may refer to a literal constant, a constant variable. A literal constant is a value that we use to initialise or assign to a variable, literally, such as: int x {42}; // initialise x = 0; // assign Here, the values 42 and 0 are literal constants. A constant variable is a variable which will not change value after initialisation: const int x {42}; // initialise x = 69; // error - cannot assign to a constant variable Constant variables are useful when we wish to use the same constant value repeatedly within a scope. We could also use a literal constant rather than a constant variable, however naming our constants makes it easier to refer to the value consistently, particularly during code maintenance where we may wish to review the value. With a constant variable we need only change the initialiser, but with literal constants we must change every occurrence of the literal and that can lead to inconsistencies. Consider the following: int x[100]; int y[100]; for (int i=0; i<100; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<100; ++i) { cout << y[i] << endl; } Here we've used the literal constant 100 four times. At a future time we may decide array x really needs 200 elements rather than 100, but we have to be careful which literals we change because array y makes use of that same literal constant. Using constant variables helps keep those usages separate: const int xmax {100}; const int ymax {100}; int x[xmax]; int y[ymax]; for (int i=0; i<xmax; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<ymax; ++i) { cout << y[i] << endl; } Now we can safely change the xmax initialiser without affecting any usage of the ymax constant: const int xmax {200}; const int ymax {100}; int x[xmax]; int y[ymax]; for (int i=0; i<xmax; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<ymax; ++i) { cout << y[i] << endl; } Note that a constant variable cannot be initialised by a non-constant variable: int x {42}; const int y {x}; // error - x is non-constant


How can we create an unsized array to c programme?

Use a pointer... int a*; a = malloc(sizeof(int)*100); //allocate space for 100 elements free(a); a = malloc(sizeof(int)*1000); // allocate space for 1000 elements free(a);

Related Questions

What is Literal in java?

Literals are the values assigned to variables. int num = 10; Here 10 is the integer literal.


Write a program which will display the list of even and odd numbers?

In Java:System.out.println("Even numbers")for (int i = 2; i


How do you use malloc and calloc to allocate memory for 100 integers?

int *p, *q; p = (int*) malloc (100 * sizeof (int)); q = (int*) calloc (100, sizeof (int)); Note that p is left in an uninitialised state whereas q is initialised with the value zero.


Write a C plus plus code segment that generates and displays 100 random 3-digit positive integers?

#include<stdio.h> #include<stdlib.h> int main(void) { int i; int j[100]; for(i=0;i<100;i++) { j[i]=rand()%100; printf("%d",j[i]); } }


Declare an array of 100 integers?

int array_name [100];


How do you return array of pointers?

Example: int **myfun (void) { int **myptr= calloc (sizeof (int *), 100); return myptr; }


In c program how to print addition from 1-100 numbers?

#include using std::cout;using std::endl;int main(){const int numToAdd = 100;int sum = 0;for (int i = 1; i


What are the kinds of literals in c language?

Literals are either numeric types (integers and floating point types), or character types. int i = 42; // literal integer double pi = 3.14; // literal floating point char c = 'x'; // literal character char s[] = "Hello world"; // literal string Note that you cannot take the address of a literal since there's no way to refer to it.


What are constants in computer programming?

A constant may refer to a literal constant, a constant variable. A literal constant is a value that we use to initialise or assign to a variable, literally, such as: int x {42}; // initialise x = 0; // assign Here, the values 42 and 0 are literal constants. A constant variable is a variable which will not change value after initialisation: const int x {42}; // initialise x = 69; // error - cannot assign to a constant variable Constant variables are useful when we wish to use the same constant value repeatedly within a scope. We could also use a literal constant rather than a constant variable, however naming our constants makes it easier to refer to the value consistently, particularly during code maintenance where we may wish to review the value. With a constant variable we need only change the initialiser, but with literal constants we must change every occurrence of the literal and that can lead to inconsistencies. Consider the following: int x[100]; int y[100]; for (int i=0; i<100; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<100; ++i) { cout << y[i] << endl; } Here we've used the literal constant 100 four times. At a future time we may decide array x really needs 200 elements rather than 100, but we have to be careful which literals we change because array y makes use of that same literal constant. Using constant variables helps keep those usages separate: const int xmax {100}; const int ymax {100}; int x[xmax]; int y[ymax]; for (int i=0; i<xmax; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<ymax; ++i) { cout << y[i] << endl; } Now we can safely change the xmax initialiser without affecting any usage of the ymax constant: const int xmax {200}; const int ymax {100}; int x[xmax]; int y[ymax]; for (int i=0; i<xmax; ++i) { cout << x[i] << endl; } // ... for (int i=0; i<ymax; ++i) { cout << y[i] << endl; } Note that a constant variable cannot be initialised by a non-constant variable: int x {42}; const int y {x}; // error - x is non-constant


Hoe can you write a programme to claculate 1 plus 2 plus 3..100?

You add the numbers in a loop. Here is an example in Java:int sum = 0;for (int i = 1; i


What is arry as in java?

An array is a contiguous block of memory in which to store data. For instance, an array of integers is essentially a chunk of memory with integers stored one after another. // Use [] to define an array of the given type. int[] intArray; // Instantiate intArray with enough space to hold 100 ints. intArray = new int[100]; // Store some data... int[0] = 100; int[1] = 99; int[2] = 98; ... int[99] = 1; // Retrieve some data... for(int i = 0; i < intArray.length; ++i) { System.out.println(intArray[i]); }


How can we create an unsized array to c programme?

Use a pointer... int a*; a = malloc(sizeof(int)*100); //allocate space for 100 elements free(a); a = malloc(sizeof(int)*1000); // allocate space for 1000 elements free(a);