Chapt 6 in C class

6.1

#1

a) function factorial is looking for a int and will return an int

b) function price is looking for 1 in and 2 doubles and will return a double

c) function yield is looking for 1 in t and 2 doubles and woll return a double

d) function interest is looking for 1 char and 2 floats and will return a char

e) function total is looking for 2 floats and will return a int

f) function roi is looking for 2 ints, 2 chars and 2 floats and will return a float

g) function get_val is looking for 2 ints and 1 char and will return nothing

#2

a) void check(int num1, float num2, double num3)

b) double find_abs(double num4)

c) float mult(float num5, float num6)

d) int dqr_it(int num7)

e) int powfun(int num8)

f) void display(void)

#4

a) void check(int num9, float num10, double num11)

b) #include<stdio.h>

void main(void)

{

int num9=1;

float num10=1.1;

double num11=1.11111111;

void check(int,float,double);

}

void check(int num9, float num10, double num11)

{

printf(" This is an int %d,This is a float %f and this is a double %lf",num9,num10,num11);

}

6.2

#1

#include <stdio.h>

#include <math.h>

void main(void)

{

double x=0.0;

while(x !=999)

{

printf("Enter a number to take the square root of ");

printf("\n or 999 to quit: ");

scanf("%lf", &x);

printf("\nThe square root of %lf is %lf \n\n"' x'sqrt(x));

}

}

#5

#include <stdio.h>

include <ctype.h>

void main(void)

{

char letter;

do

{

printf("\n\nEnter and character on an F to end: ");

letter=toupper(getchar());

getchar();

putchar(letter);

}

while(letter !='F');

printf("/nThe End");

}

6.3 I don't understand what I'm supposed to do here

#2

a)

key data type scope

number long int global to main(), func1() and func2()

a,b,c int local to main()

x and y double local to main()

secnum double global to func1() and func2()

o and p int local to func1()

abcop int local to func2()

r float local to func2()

stx double local to func2()

b)don't have to

 

c)func1() is looking for 2 int and gets 1 int

func2() is looking for 2 floats and gets 1 double

#4

The first printf used the variable firstnum and it's value is set locally to be 20

The next printf uses firstnum and it shows a 10. It's value is set globally