# lab4 - COP 3502 Lab Notes Function Loop Tracing...

This preview shows pages 1–2. Sign up to view the full content.

Function This week’s lab will give you more practice writing and tracing code that contains loops and function calls. We will also introduce functions which call themselves, known as recursive functions. Tracing Code with Loops (answers below) Example 1 Example 2 Example 3 1 #include<stdio.h> int main() { int x, y; printf("A\n"); else printf("B\n"); return 0; } /* x=5 y=2 output is ? x=3 y=2 output is ? */ #include<stdio.h> int main() { int x, y, z; if( ((x==1)||(y>4)) && (z==3)) printf("G\n"); else if( z>2) printf("H\n"); else if (x < 4) printf("I\n"); else printf("J\n"); printf("The end\n"); return 0; } /* x =2 y= 4 z= 3 output is ?*/ /* x =1 y= 4 z= 3 output is ?*/ /* x =2 y= 5 z= 4 output is ?*/ /* x =5 y= 4 z= 2 output is ?*/ /* x =0 y= 0 z= 0 output is ?*/ #include<stdio.h> int main() { int a, b, c; if(a==3) { printf("a = %d ",a); printf("No\n"); } printf("Yes\n"); else

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

lab4 - COP 3502 Lab Notes Function Loop Tracing...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online