# int x = 1;
if (x %26gt; 3) { if (x %26gt; 4) {
printf ("A"); }
else
{ printf ("B"); } }
else if (x %26lt; 2) {
if (x != 0) {
printf ("C"); } }
printf ("D");
is output "C"?
and also,
int j, k;
for (j = 1; j %26lt;= 4; j = j + 1) {
for (k = 1; k %26lt;= j; k = k + 1)
{ printf ("*"); }
printf ("\n"); }
is output "*"?
and finally,
int g, h;
for (g = 1; g %26lt;= 3; g = g + 1) (could you explain this line and the one after it?)
{
for (h = 0; h %26lt; 3; h = h + 1)
{
if (g == h)
{
printf ("O");
}
else
{
printf ("X");
}
}
printf ("\n");
for (g = 1; g %26lt;= 3; g = g + 1) (could you explain this line ?)
Outputs to following codes.?
First one is: CD
Second one is:
*
**
***
****
Third one is:
XOX
XXO
XXX
for(g=1; g%26lt;=3; g=g+1) is a for statement with the following characteristics:
g=1 assigns the variable g the start value of 1.
g%26lt;=3 is the condition for when the loop will stop (when g is less than or equal to 3 is will still loop. When this condition isn't true...say g=4, the loop terminates).
g=g+1 is incrementing g.
So the loop for g would look something like this if we printed the value of g for each iteration:
g=1
g=2
g=3
the loops with both variables g and h running will look something like this
g=1
h=0
h=1
h=2 //note that the condition in the loop for h is only less than
g=2
h=0
h=1
h=2
g=3
h=0
h=1
h=2
Reply:First Answer is : C D
For Second:
*
* *
* * *
* * * *
Reply:Do your own homework.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment