Docsity

Academic Excellence Workshop - Worksheet 6 for ECS 102, Spring 2006 - Prof. Marjory Baruch, Assignments of Computer Science

Toggle sidebar
bg1
ECS 102 Academic Excellence Workshop - Worksheet 6 Spring 2006
1. p215 #1, 2
2. p216 # 1
3. p221 # 1, 2
4. p230 # 1, 4
5. What will be the output?
#include<stdio.h>
int main()
{
int k;
int m;
m=5;
for (k=1; k< m; k=k+1)
{
printf("# ");
}
printf("#\n");
for (k=1; k< m; k=k+1)
{
printf(" # ");
}
printf("\n");
k=6;
while (k>0)
{
printf(" / ");
k=k-1;
}
printf("\n");
for (k=1; k<=3*m; k=k+3)
printf("/");
printf("\n");
return(0);
}
6. Write a program that produces a sin and cos table for angles in degrees from 0 to 360.
Don’t forget that the math library uses radians, not degrees. Be flexible. Should it
print every degree? In steps of 5? Give the user a choice of step size?
1
pf2

Partial preview of the text

Download Academic Excellence Workshop - Worksheet 6 for ECS 102, Spring 2006 - Prof. Marjory Baruch and more Assignments Computer Science in PDF only on Docsity!

ECS 102 Academic Excellence Workshop - Worksheet 6 Spring 2006

  1. p215 #1, 2
  2. p216 # 1
  3. p221 # 1, 2
  4. p230 # 1, 4
  5. What will be the output?

#include<stdio.h> int main() { int k; int m; m=5;

for (k=1; k< m; k=k+1) { printf("# "); } printf("#\n"); for (k=1; k< m; k=k+1) { printf(" # "); } printf("\n"); k=6; while (k>0) { printf(" / "); k=k-1; } printf("\n"); for (k=1; k<=3*m; k=k+3) printf("/"); printf("\n"); return(0); }

  1. Write a program that produces a sin and cos table for angles in degrees from 0 to 360. Don’t forget that the math library uses radians, not degrees. Be flexible. Should it print every degree? In steps of 5? Give the user a choice of step size?
  1. Write a program that takes a number, divides it by 2, and keeps dividing the quotient by 2 until the quotient is 0. After each division, write the remainder. For example, given the number 19,

19 /2 = 9, R 1

9 /2 = 4, R 1 4 /2 = 2, R 0 2 /2 = 1, R 0 1 /2 = 0, R 1 So the output should be 11001 which is the reverse of the base two representation of 19.

  1. Make a multiplication table with the number 0 through 9 across the top and down the side. Write a function that prints the row next to the number n.