Lab 6-Variables, Format Identifiers and Math Functions
Lab 6-Variables, Format Identifiers and Math Functions
ABOUT LAB 6
Lab Description: This lab has two parts: part 1 has some codes and examples to
practice. Part 2 includes Assignments that students should work on and submit the
report by the due date.
Note 1: Your name must be on top of every single code, printed in the code.
Note 2: If the test case given, do not hardcode values, and your screenshot should be
based on the test case only!
Submission: Students must submit the lab report for Part2- Assignments (A1-A4) as a
Word doc (based on the instruction in file InstructionsforLabsByfarnazDerakhshan.pdf).
Please double check all the items, before submitting the report and make sure to not miss
the due date, late submissions will not be accepted.
1|Page
PART 1- PRACTICE AND LEARN:
P1-
Complete the code, correct it and run the program, how many issues you have found?
incld<stio.h
Int Main
Int var;
printf(HUMBER is my second home /n ”)
Printf(How old are you??\n)
Scanf(: %d”, var1;
Printf( %d Var); Return(0)
P2-
2|Page
printf ("%5.2lf\n", (double)a/b);
printf ("%5.2lf\n", (double)b/a);
Write down your expected output before running the code, then compare your expected
output with the observed outputs. Indicate spaces (blanks) with the pound character #. For
example, printf ("%2d", c); is #1
P3-
You can calculate the squre root of a number using the function call
Z = sqrt(m). The sqrt() function is also defined in the math.h header file. The result of
this calculation will be double.
Example: Calculate and print the square root of 9 and 15.
3|Page
PART 2- ASSIGNMENTS
A1
A2
I- Complete the code, in here there are errors, you should fix the errors line by line, and add
the error in your report.
For each line in your report, you should add the original line of the code here, and then write
down the missing parts, or mistakes, by adding #1, #2, numbering format. Do not use the same
numbers, and each number is unique for an error, and by the end, the last # shows the whole
number of errors on this code.
Example:
Include <stdio. #1- I should be lower case for include
4|Page
II- After finishing all the errors, then copy the code, and then complete the code, correct it
(debug it), and run the program, take a screenshot for the report.
III- Based on the following given test case, take the last screenshot for the report.
Test case, and entered values from the keyboard (users’ input):
num1=900 num2=99 value100=100 numb200= -2
includ<stdio.h
int main
{ INT num1;num2, sum
Double Value100, numb200, product printf(\n“This
is a practice to learn variables\n ”);
Sum=Num1+num2;
Retur(0);;
5|Page
A3
Write a program use the given codes in your program, then run it. The \t is the Escape
Sequence that tabs the output several spaces.
A4
6|Page