SP Lab1 InLabExercises Sec#1
SP Lab1 InLabExercises Sec#1
Lab Exercises
Exercise Ex. 1 Ex. 2 Ex. 3 Ex. 4
Mark /4 /1 /2 /3
Total Mark / 10
Lab #1 Objectives
⮚ Using IDE to create, compile, debug and run C programs.
⮚ Using simple input and output statements.
⮚ Identifying and using fundamental data types.
⮚ Using arithmetic operators
⮚ Using comments.
Page 1 of 5
Lab Exercises
Exercise 1–
Exercise Objectives
✔ Debugging simple programs
✔ Working with data types
Problem Description
A. Find the error in the following code. Add a comment next to each line causing an error.
The comment should explain why that line or part of the line is causing an error
Fix the code so that it runs without errors and produces reasonable output. Submit the fixed
code for grading
#include <stdio.h>
int main ()
char i = 'j';
char f = 'n';
int x='55'
printf(" %c is short for floating point", f);
return 0;
}
C. The code below does not print the character 'D', why? Submit your answer for grading
#include <stdio.h>
int main () {
char var = 'D';
// DO NOT MODIFY ANYTHING BELOW THIS LINE.
printf(" %d", var);
return 0;
Page 2 of 5
}
Exercise 2
Exercise Objectives
✔ Implement A flowchart
Problem Description
Consider the following flowchart, write a C program to properly implement the flowchart.
Copy and paste your code in response to this exercise.
Page 3 of 5
Exercise 3 –
Exercise Objectives
✔ basic problem solving
Problem Description
Using flowgorithm, construct the flowchart of a program that converts and print the area
of the Parallelogram, which is computed using the following equation:
Area = b X h
Parallelogram’s Area = 15
Page 4 of 5
Exercise 4 –
Exercise Objectives
✔ basic problem solving
✔ Using simple input and output statements.
✔ Identifying and using fundamental data types.
✔ Using arithmetic operators
✔ Using comments.
Problem Description
Write a program to create a customer’s bill for a furniture shop. The shop sells 3 different
products with the unit price as following:
Table - 100 JD
Chair – 180 JD
Carpet – 120 JD
The program must read the quantity of each product purchased by a customer. It then
prints the Sub Total Price (for each item) and the Total Price in the following format:
Page 5 of 5