SlideShare ist ein Scribd-Unternehmen logo
1 von 4
left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />DTI 2143: COMPUTER PROGRAMMING<br />LAB EXERCISE 7  FUNCTION AND GOTO<br />Exercise 1.0:<br />#include<stdio.h><br />long fibonacci(long);<br />int main()<br />{<br />int proceed=1;<br />long result, number;<br />while (proceed==1)<br />{<br />printf(quot;
Enter an interger:quot;
);<br />scanf(quot;
%ldquot;
,&number);<br />result=fibonacci(number);<br />printf(quot;
Fibonacci(%ld)= %ldquot;
,number,result);<br />printf(quot;
Anymore item? Enter 1 for yes or else for no :quot;
);<br />scanf(quot;
%dquot;
,&proceed);<br />}<br />return 0;<br />}<br />long fibonacci(long n)<br />{<br />if (n==0||n==1)<br />return n;<br />else<br />return fibonacci(n-1)+fibonacci(n-2);<br />}<br />Study program 1.0 carefully, then compile and execute it.<br />,[object Object]
Explain how the coding works
How many arguments passed from function to main program?Exercise 2.0:<br />Write a program to calculate student’s mark. Section the program with function. <br />,[object Object]
the output should be similar as:Exercise 3.0:<br />#include<stdio.h><br />int maximum(int,int,int);<br />int main()<br />{<br />int a,b,c;<br />printf(quot;
Enter three(3) intergers:quot;
);<br />scanf(quot;
%d%d%dquot;
,&a,&b,&c);<br />printf(quot;
Maximum is %dquot;
,maximum(a,b,c));<br />return 0;<br />}<br />int maximum(int x, int y, int z)<br />{<br />int max=x;<br />if (y>max)<br />max = y;<br />if (z>max)<br />max = z;<br />return max;<br />}<br />Study program 3.0 carefully, then compile and execute it.<br />,[object Object]

Weitere ähnliche Inhalte

Andere mochten auch

Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Rodan + Fields Dermatologists
 
Chapter 3 dti2143
Chapter 3 dti2143Chapter 3 dti2143
Chapter 3 dti2143alish sha
 
Sustainable Reading - Concept Workshop
Sustainable Reading - Concept WorkshopSustainable Reading - Concept Workshop
Sustainable Reading - Concept Workshopstoryofxu
 
愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会新一 佐藤
 
การนำเสนอ..
การนำเสนอ..การนำเสนอ..
การนำเสนอ..NattAA
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)NattAA
 
UNI-Joint Story Telling
UNI-Joint Story TellingUNI-Joint Story Telling
UNI-Joint Story Tellingstoryofxu
 
Books to Read
Books to ReadBooks to Read
Books to Readnplisko
 
Transcricion e traducion new
Transcricion e traducion newTranscricion e traducion new
Transcricion e traducion newjuanapardo
 
Tarot: Card Interpretation
Tarot: Card InterpretationTarot: Card Interpretation
Tarot: Card InterpretationJohnna Russell
 
Components of a computer
Components of a computerComponents of a computer
Components of a computerTechTeacher803
 
データセンターコンファレンス2014Spring_Niscom
データセンターコンファレンス2014Spring_Niscomデータセンターコンファレンス2014Spring_Niscom
データセンターコンファレンス2014Spring_NiscomTakeshi Mitsuishi
 
The Many Faces Of Maddie
The  Many  Faces Of  MaddieThe  Many  Faces Of  Maddie
The Many Faces Of MaddieAngie Hopkins
 
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014新一 佐藤
 

Andere mochten auch (20)

Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01
 
Chapter 3 dti2143
Chapter 3 dti2143Chapter 3 dti2143
Chapter 3 dti2143
 
Sustainable Reading - Concept Workshop
Sustainable Reading - Concept WorkshopSustainable Reading - Concept Workshop
Sustainable Reading - Concept Workshop
 
Advert
AdvertAdvert
Advert
 
愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会
 
การนำเสนอ..
การนำเสนอ..การนำเสนอ..
การนำเสนอ..
 
โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)โครงงานครั้งที่ 2 (Guava Cake)
โครงงานครั้งที่ 2 (Guava Cake)
 
General presentation
General presentationGeneral presentation
General presentation
 
UNI-Joint Story Telling
UNI-Joint Story TellingUNI-Joint Story Telling
UNI-Joint Story Telling
 
Books to Read
Books to ReadBooks to Read
Books to Read
 
Transcricion e traducion new
Transcricion e traducion newTranscricion e traducion new
Transcricion e traducion new
 
Mobile phone
Mobile phoneMobile phone
Mobile phone
 
Tarot: Card Interpretation
Tarot: Card InterpretationTarot: Card Interpretation
Tarot: Card Interpretation
 
Presentation2
Presentation2Presentation2
Presentation2
 
Components of a computer
Components of a computerComponents of a computer
Components of a computer
 
Romantikken
RomantikkenRomantikken
Romantikken
 
データセンターコンファレンス2014Spring_Niscom
データセンターコンファレンス2014Spring_Niscomデータセンターコンファレンス2014Spring_Niscom
データセンターコンファレンス2014Spring_Niscom
 
The Many Faces Of Maddie
The  Many  Faces Of  MaddieThe  Many  Faces Of  Maddie
The Many Faces Of Maddie
 
2011
20112011
2011
 
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
 

Ähnlich wie UTM FACULTY OF MECHANICAL ENGINEERING LAB EXERCISE ON FUNCTIONS AND GOTO STATEMENTS

Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8alish sha
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7alish sha
 
Wildlife conservation project management adri jovin
Wildlife conservation project management  adri jovinWildlife conservation project management  adri jovin
Wildlife conservation project management adri jovinAdri Jovin
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8alish sha
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8alish sha
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2alish sha
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovinAdri Jovin
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdfMOJO89
 
E1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxE1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxjacksnathalie
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in cBUBT
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
Workbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdfWorkbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdfDrDineshenScientist
 
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
 

Ähnlich wie UTM FACULTY OF MECHANICAL ENGINEERING LAB EXERCISE ON FUNCTIONS AND GOTO STATEMENTS (20)

Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
 
Wildlife conservation project management adri jovin
Wildlife conservation project management  adri jovinWildlife conservation project management  adri jovin
Wildlife conservation project management adri jovin
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Ch5(loops)
Ch5(loops)Ch5(loops)
Ch5(loops)
 
Presentation1
Presentation1Presentation1
Presentation1
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovin
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 
E1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docxE1 – FundamentalsPlease refer to announcements for details about.docx
E1 – FundamentalsPlease refer to announcements for details about.docx
 
Introduction to c part -1
Introduction to c   part -1Introduction to c   part -1
Introduction to c part -1
 
SPL 8 | Loop Statements in C
SPL 8 | Loop Statements in CSPL 8 | Loop Statements in C
SPL 8 | Loop Statements in C
 
Chapter 5 exercises Balagurusamy Programming ANSI in c
Chapter 5 exercises Balagurusamy Programming ANSI  in cChapter 5 exercises Balagurusamy Programming ANSI  in c
Chapter 5 exercises Balagurusamy Programming ANSI in c
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
Workbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdfWorkbook_2_Problem_Solving_and_programming.pdf
Workbook_2_Problem_Solving_and_programming.pdf
 
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
 
Looping
LoopingLooping
Looping
 
C programming
C programmingC programming
C programming
 

Mehr von 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
 

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
 

UTM FACULTY OF MECHANICAL ENGINEERING LAB EXERCISE ON FUNCTIONS AND GOTO STATEMENTS