NetId:
____________________________
Section: _____________
Print out this page and fill in the blanks to answer the following
questions.
Hand in this assignment at the beginning of Lab 9.
As with all prelabs/labs, if you are not sure of the answer you
may go to any EWS lab on campus and check your results by using the gcc
compiler, or you can ask anyone of the CS101 staff for help.
A=
P eRT
Where A = amount after T years , P = Principal (initial investment), R = APR (annual percentage rate as a decimal, 5% = .05)
/*
Project: CS101 Prelab 9
File: investment.c
author: Slim Shady
class: CS101
Description: Program to calculate continuous compounding interest interest
*/
#include <stdio.h> /*This is included to make use of printf function*/
#include <math.h> /*This is included to make use of exp function*/
/*Don't forget to compile this file with the -lm option, i.e. gcc investment.c -lm */
void main(void)
{ /* write new code ONLY if the existing code has an error */
float P /* _______________________________________________________________ */
inut T ; /* _______________________________________________________________ */
R float ; /* _______________________________________________________________ */
float ; A /* _______________________________________________________________ */
printf("Enter the Principal : ) ; /* ____________________________________________ */
scanf("%i",&P) ; /* ____________________________________________ */
printf("Enter the number of years :") ; /* ____________________________________________ */
scanf("%i",T) ; /* ____________________________________________ */
printf("Enter the rate of interest(%) :") ; /* ____________________________________________ */
scanf('%i',&R) ; /* ____________________________________________ */
A = P exp(RT) ; /* ___________________________________________ */
printf("A = %f \n" A ) ; /* _____________________________________________ */
}
#include <stdio.h>
void main(void)
{
int i,j;
for(i=0; i<3; i=i+1)
{
for(j=0 ;j<=i ; j=j+1)
printf("A");
printf("\n");
}
}
#include <stdio.h>
void main(void)
{
do
{
while(0 > 1)
printf("B");
printf("A");
} while(0 > 1);
printf("\n");
}
#include <stdio.h>
#define N 5
void main(void)
{
int i , temp;
int a[N] = {-1 , -2 , 4, 3, 17};
/* swap first element with last element , second element with next to last element ... */
for(i=0; i < N/2; i = i+1)
{
temp = a[i];
a[i] = a[ __________________]; /* Hint: you need to use both i and N */
a[ _______________] = temp; /* Hint: same as above */
}
for(i=0; i <N; i=i+1)
printf("%i ", a[i]); /* prints 17 3 4 -2 -1 */
printf("\n");
}
int nums[20];_______________________________________________________
#include <stdio.h>
void main(void)
{
int row, col;
int a[5][5];
for(row=0; row < ________ ; row = row + 1)
for(col=0; _______________ ; col = col + 1)
a[row][col] = 10;
}