This document contains instructions for Lab 2 of the Computer Programming Basics course. The objectives are to learn to write pseudo code and draw flow charts. Students are asked to explain desirable program characteristics, determine the purpose and variables of sample C programs, analyze problems and represent the solutions using flow charts and pseudo code, and translate a sample compound interest program into a flow chart.
08448380779 Call Girls In Civil Lines Women Seeking Men
Lab 2
1. UNIVERSITI TUN HUSSEIN ONN MALAYSIA
FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
BTI 10202: COMPUTER PROGRAMMING
LAB 2 : Computer Programming Basics
NAME : _________________________________
MATRICS NO.: _______________ DATE : _________ (MARKS)
Objectives: 1. Learn to write pseudo code
2. Learn to draw flow chart
1. List and explain the 6 desirable program characteristics.
2. Determine the purpose of each of the following C programs. Identify all the
variables within each program. Identify all input and output statements, all
assignment statements and any other special features that you recognize.
(a) main( )
{
printf(“Welcome to this computer programming class!n”);
}
(b) #define MESSAGE “Welcome to this computer programming class!n”
main( )
{
printf(MESSAGE);
}
(c) main( )
{
float gross, tax, net;
printf(“Gross salary: “);
scanf(“%f”, &gross);
tax = 0.14*gross;
net = gross – tax;
2. printf(“Taxes withheld: %.2fn”, tax);
printf(“Net salary: %.2f”, net);
}
3. Analyze the problems below. Build up the algorithm using (1) flowchart
representation and (2) pseudo code representation.
a. Going to lecture from home. Whether by bus, own transport or by walk.
b. Starting the car engine. If the engine starts in 6s, release the key to its
ignition position. Otherwise, repeat by turning the key to ignition position.
If repetition is more than 5 times, call the mechanic.
4. Translate the following program into flowchart.
//simple compound interest problem
#include<stdio.h>
#include<math.h>
main()
{
float p, r, n, i, f;
//read input data (including prompts)
printf(“Please enter a value for the principal (p): “);
scanf(“%f”, &p);
printf(“Please enter a value for the interest rate (r): “);
scanf(“%f”, &r);
printf(“Please enter a value for the number of years (n): “);
scanf(“%f”, &n);
//calculate i, then f
i=r/100; //interest in decimal
f=p*pow((1+i),n); //future accumulation of money
//display the output
printf(“nThe final value (F) is: %.2fn”, f);
}