0% found this document useful (0 votes)
8 views3 pages

Lab 2a - Arithmetic (Updated)

This document is a lab sheet for CS101 at Yanbu University College, focusing on arithmetic calculations using C programming. It outlines objectives such as variable declaration, basic input/output manipulation, and solving arithmetic problems. The document includes a basic program skeleton and several exercises for students to complete, including price conversion, depreciation calculation, distance evaluation, number swapping, temperature conversion, and averaging three numbers.

Uploaded by

slmyaljhny440
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Lab 2a - Arithmetic (Updated)

This document is a lab sheet for CS101 at Yanbu University College, focusing on arithmetic calculations using C programming. It outlines objectives such as variable declaration, basic input/output manipulation, and solving arithmetic problems. The document includes a basic program skeleton and several exercises for students to complete, including price conversion, depreciation calculation, distance evaluation, number swapping, temperature conversion, and averaging three numbers.

Uploaded by

slmyaljhny440
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS101: Computer Programming

Department of Computer Science & Engineering


Yanbu University College
Lab Sheet 2 – 1 : Arithmetic Calculation

OBJECTIVES:

By the end of this lab session, you should be able to:


1. declare and initialize variables
2. write and manipulate basic input/output programs
3. write a C program to solve basic arithmetic problems

BASIC PROGRAM SKELETON

For every C program that you write (either for lab exercises or lab assignments), please use the
following template:

/*************************************************************
Author: Your name
Date: date
Description: basic description of what your program does – what
does it solve?
Input: list of input required by your program
Output: list of output produced by your program
*************************************************************/

#include <stdio.h>

void main(void)
{

Write your program here

}
Exercises (Please do ALL):
1. Write a program to read the price of an item in decimal form
like (75.95) and print the output in halala (7595 halala)
Output:

2. The straight line method of computing the yearly depreciation


of the value of an item is given by
Depreciation = (purchaseprice – salvagevalue) / yearsofservice

1
Write a program to determine the salvage value of an item when
the purchase price, years of service and depreciation are given
Output:

3. The total distance travelled by a vehicle in t seconds


Distance = ut + (at)2 / 2
Where u is the initial velocity (meters per second), a is the
acceleration (meters per seconds2). Write a program to evaluate
the distance travelled in 10 seconds for given values of u and
a.
Output:

4. Write a C program to accept two numbers from the user and


swaps them. (Swapping means interchanging of values)
Output:

5. Write a program that reads a temperature value in degrees


centigrade and then converts and displays the equivalent
temperature in Fahrenheit. The conversion formula is:
Fahrenheit = (Centigrade * 9.0 / 5.0) + 32.0
Output

2
6.
Algorithm: Flowchart:

Step 1: start

Step 2: read a, b, c

Step 3: avg = (a + b + c) /3

Step 4: display avg

Step 5: stop

Output:

You might also like