0% found this document useful (0 votes)
94 views

Merlimau Polytechnic Electrical Engineering Department Ec201 - Fundamental Programming Laboratory 1 Title

This document provides an introduction to a laboratory session on C programming language for an electrical engineering course. The objectives of the lab are to define programming terms, identify suitable languages for applications, analyze problems to determine input, process, output, and describe design tools like flowcharts and pseudocode. Students will use Turbo C++ software to write programs, identify any errors, and state if they are syntax or logic errors. They will create flowcharts, pseudocode and structured charts for problems like calculating international call costs and Fibonacci numbers. They will also run sample programs to find errors.

Uploaded by

Ezat Sulaiman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Merlimau Polytechnic Electrical Engineering Department Ec201 - Fundamental Programming Laboratory 1 Title

This document provides an introduction to a laboratory session on C programming language for an electrical engineering course. The objectives of the lab are to define programming terms, identify suitable languages for applications, analyze problems to determine input, process, output, and describe design tools like flowcharts and pseudocode. Students will use Turbo C++ software to write programs, identify any errors, and state if they are syntax or logic errors. They will create flowcharts, pseudocode and structured charts for problems like calculating international call costs and Fibonacci numbers. They will also run sample programs to find errors.

Uploaded by

Ezat Sulaiman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MERLIMAU POLYTECHNIC

ELECTRICAL ENGINEERING DEPARTMENT


EC201 – FUNDAMENTAL PROGRAMMING

Laboratory 1

Title:

Introduction to C Programming Language

Introduction:

C is a structured programming language. It is considered a high level language because it


allows the programmer to concentrate on the problem at hand and not to worry about the
machine. C is powerful and flexible language. C is used for projects as diverse as operating
systems, word processors, graphic, spreadsheets, and even compiler for other languages. C is
a portable language. It means that a C program written for one operating system can be
moved to a machine running Linux with little or no modification. C is a language of few
words, containing only a handful of terms called keywords such as if, else, for, do and while.

Objectives :

After the end of teaching and learning, should be able to:

i. Define the terms , program, programmer and programming language


ii. Identify the suitable programming language for certain application
iii. Compare the advantages and disadvantages between three types of programming
techniques
iv. Analyze and sort the input, process, and output for given problems
v. Describe about the four design tools
vi. Analyze and design a pseudocode, a flowchart and a structured chart for given problems
vii. Write a program, investigate the errors and explain the types of errors

Apparatus:

    i. Laboratory sheet


    ii. Borland Turbo C++ 4.5 software

Procedure:

1. Answer the following questions:

      i) Define the following terms:

                a) Program
                b) Programmer
                c) Programming language

ii) Give one example of programming language that is specially used for the following
application:
Application Programming Language
Scientific application
Business application
Artificial intelligence
Systems programming
Web software

iii) Complete the table below:

Programming technique Advantages Disadvantages


Structured
Modular
Object oriented

2. Identify the inputs, processes, and outputs (IPO) for the following problems. Use the
following diagram.

                                     Input ---> Process ------> Output

     i) A program will create a customer’s bill for a company. The company


       sells only five different products: TV, VCR, Remote Controller, CD
       Player, and Tape Recorder. The unit price is RM400, RM220, RM35.20,
       RM300 and RM150, respectively. The program must read the quantity of
       each piece of equipment purchased from the keyboard. It then 
       calculates the cost of each item, the subtotal, and the total cost after a 
       5% sales tax.

    ii) A hypermarket gives a 50% discount for each product purchased by its
        customers due to Hari Raya Aidilfitri and Deepavali celebration. A
        program will calculate the new price for a product and the total price
        of all products purchased by the customers.

3. Dsecribe briefly about the design tools below:

        i) flowchart
        ii) pseudocode
        iii) IPO chart 
        iv) Structured chart

4. For each problem below, create a pseudocode, a flowchart and a


    structured chart.

     i) A program will calculate the cost of an international call from Malaysia
        to Indonesia. The connection fee is RM10, RM3 for the first three
        minutes and RM0.50 for each additional minute. Your program should
        get the number of minutes the call lasted and the total cost.

    
ii) A Fibonacci number is a member of set in which each number is the
         sum of the previous two numbers. The series begins:

                             0, 1, 1, 2, 3, 5, 8, 13, 21 ……

         A program will calculates and prints the next three numbers in the
         Fibonacci series.

      iii) A program that can act as a calculator. The calculator program should
           received two integers and the operation to be performed. It should
           then output the numbers, the operator, and the result.

5. Using the Turbo C++, type the program below, compile and run the program. Students are
required to identify whether there are errors and state (if applicable) whether the errors are
syntax errors or logic errors
___________________________________________________________________________
____________________________________________
i)

/*calculate the average of the numbers*/

include <stdio.h>
int main()

int n, count;
float y, average, sum=0;

/*initialize and read in a value for n*/

printf ("How many numbers?");


scanf("%d", &n);

/*read in the numbers*/

for(count=1; count<=n;++count)

    printf("x=");
    scanf("%f", &x);
    sum+=x;
}

/*calculate the average and display the answer*/


average=sum/z;
printf("\nThe average is %f\n",average);

return 0;
}

___________________________________________________________________________
______________________________________________
ii)
#include <stdio.h>

int main()
{
int sum;

sum = 500 + 15;


printf("The sum of 500 and 15 is %d\n", sum)
}

___________________________________________________________________________
________________________________________________
iii)
#include <stdio.h>

main()
{
int value1, value2, sum;

value3 = 35;
value2 = 18;
sum = value1 * value2;

printf(The sum of %d and %d is %d\n", value1, value2, sum);


}

You might also like