Escolar Documentos
Profissional Documentos
Cultura Documentos
1. The generic function print() sends its arguments to the default output stream
2. The given blocks of code are a part of a class (Java, C++) and a file in C.
3. Print ( ) always prints with a new line.
Section 2: Technical
int i;
for(i = 0; i <= 2; i++)
print("Hi");
int i;
for(i = 1; i < 5; ++i)
{
if (i == 3)
continue;
else
print(i);
}
int i;
switch(i = 0)
{
case 0 : i++;
case 1 : i += 2;
case 2 : ++i;
}
print(i++);
int m, n;
for (m = 0; m < 3; ++m)
{
n = (m % 2 == 0) ? m : m + 2;
print(n);
}
int a = 4, b = 0;
if (a > 5)
{
b = 4;
}
else
if (a < 10)
{
b = 3;
}
else
if (a < 5)
{
b = 2;
}
else
{
b = 1;
}
print(b);
int i = 6720, j = 4;
while((i % j) == 0)
{
i = i / j;
j = j + 1;
}
print(j);
int checksum(int n)
{
int c;
if(n == 1)
return(1);
else
c = n * checksum(n - 1);
return(c);
}
int i, x;
for(i = 1; i <= 5; i++)
{
x = i * i;
print(x);
}
int res;
res = (64 >> (2 + 1 - 2)) | (1 << 2);
print(res);
int x = 3;
if (2 > x)
print("First");
else
print("Second");
if (2 > x)
print("Third");
print("Fourth");
print("Fifth");
int a = 1;
while (a <= 1)
{
if (a % 2 == 0)
print(a++);
else
print(++a);
}
print(a + 10);
int count = 5;
while (--count + 1 <= 5)
{
print(count);
if(count == 0)
break;
int m, n, p;
for (m = 0; m < 3; m++)
{
for (n = 0; n < 3; n++)
{
for (p = 0; p < 3; p++)
{
if ((m + n + p) == 2 && m==0 && n==0)
{
print(m);
print(n);
print(p);
}
}
}
}
A function may have any number of return statements each returning different values of
different data types.