SlideShare ist ein Scribd-Unternehmen logo
1 von 3
left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />BTI 1022: COMPUTER PROGRAMMING<br />LAB EXERCISE 9 RECURSIVE and All-round  Recap<br />Exercise 1.0:  Compile and run the program below<br /># include<stdio.h><br /># include<conio.h><br />void recursiveFunction(int num) {<br />   if (num < 4)<br />      recursiveFunction(num + 1);<br />   printf(quot;
%dquot;
, num);<br />}<br />int main()<br />{<br />    int x = 2;<br />    recursiveFunction(x);<br />    <br />getch();<br />return 0;<br />}<br />,[object Object]
Edit the coding so that the value of x is keyed in by the userExercise 2.0:  Compile and run the program below<br /># include<stdio.h><br /># include<conio.h><br />int factorial(unsigned int number)<br />{<br />    if(number <= 1)<br />        return 1;<br />    return number * factorial(number - 1);<br />}<br />int main()<br />{<br />    int x = 5;<br />    printf(quot;
factorial of %d is %dquot;
,x,factorial(x));<br />getch();<br />return 0;<br />}<br />,[object Object]
Edit the coding so that the value of x is keyed in by the userLAB EXERCISE 10 All-round  Recap<br />Exercise 1.0: Compile and run the program below<br />int main(){int x,y=0; printf(quot;
Masukkan sebarang nombor quot;
);scanf(quot;
%dquot;
,&x); <br />while ( y <x){printf( quot;
%dquot;
, y );y++; }<br />getchar();}<br />,[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Functions & Procedures [7]
Functions & Procedures [7]Functions & Procedures [7]
Functions & Procedures [7]
ecko_disasterz
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...
hwbloom27
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
emailharmeet
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
moduledesign
 

Was ist angesagt? (20)

Functions & Procedures [7]
Functions & Procedures [7]Functions & Procedures [7]
Functions & Procedures [7]
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
 
Lab 2
Lab 2Lab 2
Lab 2
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
week-1x
week-1xweek-1x
week-1x
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
week-11x
week-11xweek-11x
week-11x
 
week-10x
week-10xweek-10x
week-10x
 
Prime number program in c
Prime number program in cPrime number program in c
Prime number program in c
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 

Andere mochten auch

Ud 0 final juani
Ud 0 final juaniUd 0 final juani
Ud 0 final juani
juanapardo
 
Conférence impôts alexandre lachance - audet bauduin girard - destinaiton q...
Conférence impôts   alexandre lachance - audet bauduin girard - destinaiton q...Conférence impôts   alexandre lachance - audet bauduin girard - destinaiton q...
Conférence impôts alexandre lachance - audet bauduin girard - destinaiton q...
Akova
 
Design_of_Machine_Elements_Spo
Design_of_Machine_Elements_SpoDesign_of_Machine_Elements_Spo
Design_of_Machine_Elements_Spo
ramiljayureta
 
Bahan kuiz p2 27 march
Bahan kuiz p2 27 marchBahan kuiz p2 27 march
Bahan kuiz p2 27 march
nm170209
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
alish sha
 
Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978
Stefano Merlo
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)
NattAA
 
Presentation1
Presentation1Presentation1
Presentation1
scorbi2
 

Andere mochten auch (20)

Ud 0 final juani
Ud 0 final juaniUd 0 final juani
Ud 0 final juani
 
Conférence impôts alexandre lachance - audet bauduin girard - destinaiton q...
Conférence impôts   alexandre lachance - audet bauduin girard - destinaiton q...Conférence impôts   alexandre lachance - audet bauduin girard - destinaiton q...
Conférence impôts alexandre lachance - audet bauduin girard - destinaiton q...
 
GEOG101 Chapter 4 Lecture
GEOG101 Chapter 4 LectureGEOG101 Chapter 4 Lecture
GEOG101 Chapter 4 Lecture
 
Design_of_Machine_Elements_Spo
Design_of_Machine_Elements_SpoDesign_of_Machine_Elements_Spo
Design_of_Machine_Elements_Spo
 
Biotecno
BiotecnoBiotecno
Biotecno
 
Bahan kuiz p2 27 march
Bahan kuiz p2 27 marchBahan kuiz p2 27 march
Bahan kuiz p2 27 march
 
Alma Media CMD 2013 Kai Telanne
Alma Media CMD 2013 Kai TelanneAlma Media CMD 2013 Kai Telanne
Alma Media CMD 2013 Kai Telanne
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Teaching Unity at Mind Candy
Teaching Unity at Mind CandyTeaching Unity at Mind Candy
Teaching Unity at Mind Candy
 
Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)
 
Literary Terms
Literary Terms Literary Terms
Literary Terms
 
Nuggets of wisdom
Nuggets of wisdomNuggets of wisdom
Nuggets of wisdom
 
Avastusõpe Tartu Kivilinna Gümnaasiumis
Avastusõpe Tartu Kivilinna GümnaasiumisAvastusõpe Tartu Kivilinna Gümnaasiumis
Avastusõpe Tartu Kivilinna Gümnaasiumis
 
Nha Tran Brand Brief
Nha Tran Brand BriefNha Tran Brand Brief
Nha Tran Brand Brief
 
Element 1 vocabulary cards
Element 1   vocabulary cardsElement 1   vocabulary cards
Element 1 vocabulary cards
 
Materiales
MaterialesMateriales
Materiales
 
υδραγωγεια
υδραγωγειαυδραγωγεια
υδραγωγεια
 
mettalurgy-12th sci cbse
mettalurgy-12th sci cbsemettalurgy-12th sci cbse
mettalurgy-12th sci cbse
 
Presentation1
Presentation1Presentation1
Presentation1
 

Ähnlich wie Bti1022 lab sheet 9 10

Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
alish sha
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
nayakq
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
alish sha
 
Here is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docxHere is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docx
trappiteboni
 

Ähnlich wie Bti1022 lab sheet 9 10 (20)

Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
7 functions
7  functions7  functions
7 functions
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Here is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docxHere is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docx
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Array Cont
Array ContArray Cont
Array Cont
 
Programming in C
Programming in CProgramming in C
Programming in C
 
C chap02
C chap02C chap02
C chap02
 
C chap02
C chap02C chap02
C chap02
 

Mehr von alish sha

Mehr von alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 

Bti1022 lab sheet 9 10