HW4 - Solutions

# HW4 - Solutions - EC327IntroductiontoSoftwareEngineering...

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

EC327 Introduction to Software Engineering HW #4 Solutions Problem 1 [15 points] Problem 2 [85 points] /* pe12-4.c */ #include <stdio.h> int callme(void); #define SIZE 10 int main(void) { int i, lim, count; printf("Enter number of loops: "); scanf("%d", &lim); for (i = 0; i < lim; i++) callme(); count = callme(); printf("Function was called %d times in loop and once afterwards.\n", count - 1); return 0; } /* keeps track of the number of times it was called */ int callme(void) { static int called = 0; return ++called; } //Solution to P2, HW4 //By Jiaxi Jin #include "stdio.h" #include <time.h> #define LENGTH 100 int numOfIte = 0;//number of iterations, need to be increased wherever an iteration takes place //using namespace std; void printArray(int *p); void bubbleSort(int *p); void binsrch(int *p,int num); //binary search, search integer num in integer array p[]

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

View Full Document
int main( void ) { int array[LENGTH],*ptr; /* Seed the random-number generator with current time so that the numbers will be different every time we run. */ srand( (unsigned)time( NULL ) );
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/09/2010 for the course ECE 327 taught by Professor Babakkia during the Fall '09 term at BU.

### Page1 / 3

HW4 - Solutions - EC327IntroductiontoSoftwareEngineering...

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

View Full Document
Ask a homework question - tutors are online