PUTAS

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _____________


DEC20012 : PROGRAMMING FUNDAMENTAL

Build programs written in C language for assigned mini project during


CLO2
practical work session ( P4 , PLO 5 )
PRACTICAL WORK 3 : Looping Statement Part 1
PRACTICAL WORK DATE :
LECTURER’S NAME:
NAME :
STUDENT ID :
NAME : TOTAL
STUDENT ID : MARKS
NAME :
STUDENT ID :
1. Fixes
2. Complete
3. Manipulates
Practical Skill 4. Builds
Assessment 5. Display
[CLO2] 6. Lab Participation
7. Efficiency
Total Practical Skill Assessment
A. Total Practical Skill Assessment (80%) =. /35*80
1. Theory
Report 2. Discussion
Assessment 3. Conclusion
Total Report Assessment
B. Total Report Assessment (20%) =. /15*20
Total A+B(100%)
DATE SUBMIT : DATE RETURN :
1 LEARNING OUTCOMES (LO):
1. Understand the looping statements.
2. Apply looping statements.
2 OBJECTIVE
1. To fixes, Complete and Manipulates the looping statement.
2. To build flowcharts of looping statement.
3. To display the output of looping statement.
3 THEORY
1. Looping Statement
2. Types of Looping Statements.
3. Structure of FOR, Nested FOR ,WHILE and DO-WHILE statements.
4 EQUIPMENT / TOOLS
Computer , C Programming Language (Dev-cpp, Codeblock etc)
Preparation before Practical Work 3 (Independent Learning (NF2F)
(Student should be prepare before Lab Session)

Define Looping Statement in C Programming Language


Answer :
• The repetition (or iteration) structure permits a sequence of the instructions to be executed
repeatedly until certain condition is reached.

List types of Looping Statement in C Programming Language

Answer :
• FOR
The ‘for loop’ loops from 1 number to another number and increases by a specific value each time.
• WHILE
The ‘while loop’ can be used if you don’t know how many times a loop must run
• DO-WHILE
The ‘do-while loop’ do something first and then test if we have to continue. The result is that the loop
always runs once.

Deference between conditional and looping statement


Answer :
Conditional statement will execute only once if condition is true whereas loop will
execute repeatedly till the condition becomes false. Conditional Statements: ... If it
is true go here or if it is false go there

Explain how nested loop work

Answer :
A nested loop is a loop within a loop, an inner loop within the body of an outer one.
How this works is that the first pass of the outer loop triggers the inner loop, which
executes to completion. Then the second pass of the outer loop triggers the
inner loop again. This repeats until the outer loop finishes.

Draw Loop Flowchart Structure


Answer :

Practical Assignments 1 (Fixed Program)

Complete the following source code by referring the given output :

We are learning
DEC20012 - PROGRAMMING FUNDAMENTAL
DEC20012 - PROGRAMMING FUNDAMENTAL
DEC20012 - PROGRAMMING FUNDAMENTAL
DEC20012 - PROGRAMMING FUNDAMENTAL
DEC20012 - PROGRAMMING FUNDAMENTAL

Answer :

#________ <stdio.h>

int ______
{
int i=0;
printf(“We are learning\n”);
for (i = 1; i <= ____ ; i___)
{
printf( "___DEC20012 - PROGRAMMING FUNDAMENTAL\n");
}
return 0;
}

Answer (Output) :

Practical Assignment 2 (Complete Program)

Identify and fix the missing syntax in this following statements


#include <stdio.h>
int main()
{
int j=0;
for
{
printf( Value of variable j is: %d\n", j);
j+*;
}
while (j>=3);
return 0;

Answer :

Write down errors:


1.int
2.do
3.(value of variable j is ; %d/n,j)
4j+*
5.(j>=3)

Answer (Correct Output) :


Practical Exercise 1 : Manipulates Program 1

Figure 3.1 DC Serial Circuit

Build a C programming by using FOR Statement to shows the value of Current at R1, I R1 when Vdc
increase from 1V to 9V if R1 fixed = 5K

Answer (Flowchart) :
Answer (Source code) :
Answer (Output) :

Practical Exercise 2 : Manipulates Program 2

Figure 3.1 DC Parallel Circuits

Build a C programming by using WHILE Statement to shows the value of Current at R1, I R1 when Vdc
increase from 1V to 9V if R1 fixed = 5K

Answer (Flowchart ):
Answer (Sourcecode) :

Answer (Output) :
Discussion :

Conclusion

You might also like