What is the value of i and j?
i = 2; j = 1;
while (( i>-5) || (j - - > 0){
if ( (j%2) && (i - - % 3))
printf ("%d", j);
else
printf ("%d\n", i);
}
return 0;
}2 > -5 = true, so move to next step
j (1)%2 = true & 2 - - %3 = true
then starts over
1 > -5 = true
j (1)%2 = true & 2 - - %3 = true
-keeps working remainder through until remainder is false (0) and then prints.
Answer:
11 -1
11 -4
1 -5
How to write a program to clear the buffer
while (get char ( ) != ‘\n’)
What does ? : mean?
? = if \: = else
x = 0;
y (x>0) ? 10 : -10
answer 10
What is x?
x = 10 y = 0
y > 10) && (x - - >10
answer 10
What is x?
x = 10 y = 10
y > 10) || (x - - >10
answer 10
How to check if a char variable is an uppdercase letter?
((ch >= ‘A’) && (ch
How many times will this print?
int count = 0;
do {
printf (Welcome)
}
while ++countanswer 10
How many iterations (executions) in the loop?
int;
for (i = 1; i
answer n
int even = 0;
printf (“%d, even ? “true” : “false”)
answer false
How many times will this print?
int count = 0;
do
{
printf ("Welcome");
} while (count++answer 10
Which code is preferred? code 1: if (number%2 = = 0) even = 1; else even = 0;
code 2: even = (number %2 = = 0) ? 1:0
code 3: even = number % 2 = = 0);
answer = all three are correct but code 3 is preferred.
How to clear the buffer?
fflush (stdin)
How to deallocate memory in a dynamic array?
free ( (void *) d_ptr );
How can memory in an array be allocated?
malloc ( )
What is an address operator? (array)
& gives the address of a variable
What is the dereferencing operator? (array)
What is the sizeof ( ) operator used for in an array?
Used with an array to return the number of bytes in that array
How to deallocate memory in a dynamic array?
free ( (void *) d_ptr ); or free ( )
What can be used as a function declaration of an array?
funct ( int *array)
funct ( int array [ ] )
What can be used as a function call for an array?
int array [ 50]
funct (array);
The name of an array without any brackets will give the address of which cell?
The first cell
In an array, what does setting a pointer to NULL do?
Indicates that it doesn’t point anywhere
How many bytes does a floating point value use in array?
4 bytes. An 8 element array will use 32 bytes