SlideShare una empresa de Scribd logo
1 de 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]

Más contenido relacionado

La actualidad más candente

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
 
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-2Dr. Loganathan R
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4emailharmeet
 
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-3Dr. Loganathan R
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translationShobhit Saxena
 
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-1Dr. Loganathan R
 
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-3Dr. Loganathan R
 
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 pointersDr. Loganathan R
 
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-1Dr. Loganathan R
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 
Prime number program in c
Prime number program in cPrime number program in c
Prime number program in cHitesh Kumar
 

La actualidad más candente (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
 

Destacado

Ud 0 final juani
Ud 0 final juaniUd 0 final juani
Ud 0 final juanijuanapardo
 
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_Sporamiljayureta
 
Bahan kuiz p2 27 march
Bahan kuiz p2 27 marchBahan kuiz p2 27 march
Bahan kuiz p2 27 marchnm170209
 
Alma Media CMD 2013 Kai Telanne
Alma Media CMD 2013 Kai TelanneAlma Media CMD 2013 Kai Telanne
Alma Media CMD 2013 Kai TelanneRauno Heinonen
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8alish sha
 
Teaching Unity at Mind Candy
Teaching Unity at Mind CandyTeaching Unity at Mind Candy
Teaching Unity at Mind CandyMark Baker
 
Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978Allenamento tecnico atletico anno 1978
Allenamento tecnico atletico anno 1978Stefano Merlo
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)NattAA
 
Avastusõpe Tartu Kivilinna Gümnaasiumis
Avastusõpe Tartu Kivilinna GümnaasiumisAvastusõpe Tartu Kivilinna Gümnaasiumis
Avastusõpe Tartu Kivilinna GümnaasiumisPiret Jõul
 
Nha Tran Brand Brief
Nha Tran Brand BriefNha Tran Brand Brief
Nha Tran Brand BriefErnest Chan
 
Presentation1
Presentation1Presentation1
Presentation1scorbi2
 

Destacado (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
 

Similar a UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 1022 LAB EXERCISES

Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
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.docxtristans3
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
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.docxvrickens
 
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 typesimtiazalijoono
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6alish sha
 
C Language Programs
C Language Programs C Language Programs
C Language Programs Mansi Tyagi
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
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 .docxtrappiteboni
 
C chap02
C chap02C chap02
C chap02Kamran
 

Similar a UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 1022 LAB EXERCISES (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
 

Más de alish sha

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 9alish sha
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)alish sha
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation alish sha
 
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) - sharifahalish sha
 
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) - sharifahalish sha
 
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)alish sha
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaboratealish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1alish sha
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Attn list test
Attn list testAttn list test
Attn list testalish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303alish sha
 

Más de 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
 

UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI 1022 LAB EXERCISES