Electrical engineering department
DEC2012 – FUNDAMENTAL PROGAMMING
PRACTICAL WORK ASSESSMENT
SESSION:DEC 2017
TITLE For Statement
PRACTICAL NUMBER 5
Item \ Student
1. Documentation/ Theory /8
Practical Skill 2. Flowchart /12
Assessment
[CLO3] 3. Program /12
5. Record the result//output /8
Total Practical Skill Assessment /40
Report 1. Conclusion /10
Assessment
Total Report Assessment /10
TOTAL
STUDENT’S NAME REG. NUMBER
MARKS/50
S1
LECTURER’S NAME DATE
NAMA : ___________________________________ NO.PEND: _____________ KELAS:_________
Practical 5 : Looping Statements
Practical Objectives:
To explore the concept of looping in a programming language, in general, and to study
some looping constructs available in C.
Define Looping statement.
List types of Looping Statement.
Define FOR loop statements.
Write the syntax for nested FOR Statement
Describe BREAK Statement
Describe CONTINUE Statement
Describe GOTO Statement
Practical Assignments 01: ( save file lab5a_no.pend)
This program will illustrate the working of a for loop.
/* nama: no.pend: tajuk: */
#include <stdio.h>
int main(){
int n, count, sum=0;
printf("Enter the value of n.\n");
scanf("%d",&n);
for(count=1;count<=n;++count) //for loop terminates if count>n
{
sum+=count; /* this statement is equivalent to sum=sum+count */
}
printf("Sum=%d",sum);
return 0;
}
Output
Flowchat 1 :Practical Assignments 01
Practical Assignments 02: ( save file lab5b_no.pend)
Program to illustrate the use of the decrement operator to print the numbers from 1 to 5 in the
reverse order.
/* nama: no.pend: tajuk: */
#include <stdio.h>
main()
{
int array[100], n, c;
printf("Enter the number of elements in array\n");
scanf("%d", &n);
printf("Enter %d elements\n",
n); for ( c = 0 ; c < n ; c++ )
scanf("%d", &array[c]);
printf("Array elements entered by you are:\n");
for ( c = 0 ; c < n ; c++ )
printf("array[%d] = %d\n", c, array[c]);
return 0;
}
Output
Flowchat 1 :Practical Assignments 02
Practical Assignments 03: ( save file lab5c_no.pend)
Program to illustrate the use of the decrement operator to print the numbers from 1 to 5 in the
reverse order.
/* nama: no.pend: tajuk: */
#include
<stdio.h> main()
{
int n, first = 0, second = 1, next, c;
printf("Enter the number of terms\n");
scanf("%d",&n);
printf("First %d terms of Fibonacci series are :-
\n",n); for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 ) next
= c;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d\n",next);
}
return 0;
}
Output
Flowchat 1 :Practical Assignments 03
conclusion