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

II EC-8 (Lab III)

The document is a lab report for an electronic engineering course at Naypyitaw State Polytechnic University, focusing on programming concepts using MATLAB. It includes two main experiments: one for calculating account balances over ten years using a for loop, and another for counting letter grades using switch statements. Each experiment outlines objectives, required equipment, and programming procedures.

Uploaded by

p2w9p956cs
Copyright
© © All Rights Reserved
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)
8 views7 pages

II EC-8 (Lab III)

The document is a lab report for an electronic engineering course at Naypyitaw State Polytechnic University, focusing on programming concepts using MATLAB. It includes two main experiments: one for calculating account balances over ten years using a for loop, and another for counting letter grades using switch statements. Each experiment outlines objectives, required equipment, and programming procedures.

Uploaded by

p2w9p956cs
Copyright
© © All Rights Reserved
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/ 7

Naypyitaw State Polytechnic University

Department of Electronic Engineering


2024~2025 Academic Year –First Semester

EcE -21014 Lab Report:

Technical Programming Experiment no. ( III )

Student :Mg Thura Naing Date: 10 .2.2025

Roll no : II EC-8

Experiment III
FOR REPETITION STATEMENTS

Objectives: To learn for loop statements


Required Equipment:
➢ Matlab software ➢
PC

Page 1 of 7
1. Write a program for calculating the amount of money in the account at the end of each
year for 10 years.
Create a main file as follows:

#include <stdio.h>

#include <math.h>

int main( void )

{ double amount; double principal = 1000.0; double

rate = .05; int year; printf( "%4s%21s\n", "Year",

"Amount on deposit" ); for ( year = 1; year <= 10;

year++ )

{ amount = principal * pow( 1.0 + rate, year

); printf( "%4d%21.2f\n", year, amount );

}
return 0;

PROCEDURE:

(i) Firstly, write a program


(ii) Check the error (iii) Testing
the result
.

Page 2 of 7
Page 3 of 7
SWITCH MULTIPLE SELECTION STATEMENTS
Objectives: To learn switch statements
Required Equipment:
➢ Matlab software
PC
2. Write a program for counting the letter grades.
Create a main file as follows:

#include <stdio.h>

#include <math.h> int

main( void )

{ int grade; int

aCount = 0;

int bCount = 0;

int cCount = 0;

int dCount = 0;

int fCount = 0;

printf( "Enter

the letter

grades.\n" );

printf( "Enter

the EOF

character to

end input.\n" );

while ( (grade

Page 4 of 7
= getchar() ) !=

EOF ) { switch

( grade )

{ case 'A':

case 'a':

++aCount;

break; case

'B': case

'b': +

+bCount;

break; case

'C': case

'c':

++cCount;

break; case

'D': case

'd':

++dCount;

break;

case 'F':

case 'f':

++fCount;

Page 5 of 7
case '\n':

case '\t':

case ' ':

break;

default:

printf( "Incorrect letter grade entered." );

printf( " Enter a new grade.\n" ); break;

} } printf( "\nTotals for each letter grade

are:\n" ); printf( "A: %d\n", aCount );

printf( "B: %d\n", bCount ); printf( "C: %d\

n", cCount ); printf( "D: %d\n", dCount );

printf( "F: %d\n", fCount ); getch(); return 0;

PROCEDURE:

(i) Firstly, write a program


(ii) Check the error
(iii) Testing the result

Page 6 of 7
Page 7 of 7

You might also like