SlideShare a Scribd company logo
1 of 3
left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />BTI 1022: COMPUTER PROGRAMMING<br />LAB EXERCISE 3- Input and output formatting<br />Exercise 1:<br />,[object Object]
(Ignore the bold numbering and undo each change you made before executing the next instruction)1#include <stdio.h>2#include <conio.h>34int main()5{6int sem_no,cad_no;7sem_no =3;8cad_no =2;9printf(quot;
%dquot;
, sem_no);10printf(quot;
Semester %dquot;
,sem_no);11printf(quot;
Semester %d, in Lab CAD %dquot;
,sem_no, cad_no);12getch();13return 0;14}<br />InstructionObservationCompile and run the programType // before #include<stdio.h> in line 1Change the word int to INT in line 4Type // before sem_no=3 in line 7Add  before the word semester in line 10Add   before the word Lab in line 11Add  before the word Lab in line 11<br />Exercise 2:<br />Run (execute) the following program:<br />#include <stdio.h>#include <conio.h>int main(){     int semester;   float CPA; printf(quot;
Enter the semester : quot;
); scanf(quot;
%dquot;
, &semester); printf(quot;
Enter your CPA : quot;
); scanf(quot;
%lfquot;
,&CPA); printf(quot;
Your CPA for semester %d is %fquot;
,semester,CPA);getch();return 0;}<br />,[object Object]
Debug and highlight your correctionExercise 3:<br />Run (execute) the following program:<br />#include <stdio.h>#include <conio.h>int main(){     printf(quot;
%d quot;
,123);   printf(quot;
%3d quot;
,123);    printf(quot;
%5d quot;
,123);    printf(quot;
%10dquot;
,123);    printf(quot;
%-6dquot;
,123);    printf(quot;
%-4d%dquot;
,123,456);    getch();    return 0;}<br />,[object Object]

More Related Content

What's hot (8)

Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
PHPUnit Myth
PHPUnit MythPHPUnit Myth
PHPUnit Myth
 
Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8Dti2143 dam31303 lab sheet 8
Dti2143 dam31303 lab sheet 8
 
Overriding abstract in java
Overriding abstract in javaOverriding abstract in java
Overriding abstract in java
 
PIZZA HUT C program
PIZZA HUT C programPIZZA HUT C program
PIZZA HUT C program
 
11 1 포인터
11 1 포인터11 1 포인터
11 1 포인터
 
Pdf creation using python
Pdf creation using pythonPdf creation using python
Pdf creation using python
 
Tugas alpro
Tugas alproTugas alpro
Tugas alpro
 

Viewers also liked

Ance_Gallesio_24052011
Ance_Gallesio_24052011Ance_Gallesio_24052011
Ance_Gallesio_24052011Rèdais
 
How to turn Facebook 'likes' into leads and customers on auto-pilot.
How to turn Facebook 'likes' into leads and customers on auto-pilot.How to turn Facebook 'likes' into leads and customers on auto-pilot.
How to turn Facebook 'likes' into leads and customers on auto-pilot.Julia Bramble
 
Necesidades de comunicación e información en el paciente refworks uniform
Necesidades de comunicación e información en el paciente refworks uniformNecesidades de comunicación e información en el paciente refworks uniform
Necesidades de comunicación e información en el paciente refworks uniformMercedes Bueno
 
Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Rodan + Fields Dermatologists
 
The Krass Family 2010
The Krass Family 2010The Krass Family 2010
The Krass Family 2010Mike Krass
 
Tarot: Card Interpretation
Tarot: Card InterpretationTarot: Card Interpretation
Tarot: Card InterpretationJohnna Russell
 
Klimato kaitos pavojai
Klimato kaitos pavojaiKlimato kaitos pavojai
Klimato kaitos pavojaibiomokykla
 
Chapter 3 dti2143
Chapter 3 dti2143Chapter 3 dti2143
Chapter 3 dti2143alish sha
 
Síntese de proteínas 2008 09
Síntese de proteínas 2008 09Síntese de proteínas 2008 09
Síntese de proteínas 2008 09juanapardo
 
Fotosintese 2009 new
Fotosintese 2009 newFotosintese 2009 new
Fotosintese 2009 newjuanapardo
 
A history of lemonade
A history of lemonadeA history of lemonade
A history of lemonadeLemonadeDay
 
Câu chuyệ sức khoẻ 21
Câu chuyệ sức khoẻ 21Câu chuyệ sức khoẻ 21
Câu chuyệ sức khoẻ 21vinhtungdk
 
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014新一 佐藤
 
Rèdais & IED_De Maio
Rèdais & IED_De MaioRèdais & IED_De Maio
Rèdais & IED_De MaioRèdais
 
מעברים ורצפים לאתר
מעברים ורצפים לאתרמעברים ורצפים לאתר
מעברים ורצפים לאתרpisgariel
 
Rèdais & IED_Gokcek
Rèdais & IED_GokcekRèdais & IED_Gokcek
Rèdais & IED_GokcekRèdais
 
Presentatie Altijd Mooi en Altijd Mooi Natuurlijk
Presentatie Altijd Mooi en Altijd Mooi NatuurlijkPresentatie Altijd Mooi en Altijd Mooi Natuurlijk
Presentatie Altijd Mooi en Altijd Mooi NatuurlijkAltijdMooi
 

Viewers also liked (20)

Ance_Gallesio_24052011
Ance_Gallesio_24052011Ance_Gallesio_24052011
Ance_Gallesio_24052011
 
How to turn Facebook 'likes' into leads and customers on auto-pilot.
How to turn Facebook 'likes' into leads and customers on auto-pilot.How to turn Facebook 'likes' into leads and customers on auto-pilot.
How to turn Facebook 'likes' into leads and customers on auto-pilot.
 
Necesidades de comunicación e información en el paciente refworks uniform
Necesidades de comunicación e información en el paciente refworks uniformNecesidades de comunicación e información en el paciente refworks uniform
Necesidades de comunicación e información en el paciente refworks uniform
 
Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01Businesssystempresentation101409 100107132037 Phpapp01
Businesssystempresentation101409 100107132037 Phpapp01
 
The Krass Family 2010
The Krass Family 2010The Krass Family 2010
The Krass Family 2010
 
Tarot: Card Interpretation
Tarot: Card InterpretationTarot: Card Interpretation
Tarot: Card Interpretation
 
Klimato kaitos pavojai
Klimato kaitos pavojaiKlimato kaitos pavojai
Klimato kaitos pavojai
 
Chapter 3 dti2143
Chapter 3 dti2143Chapter 3 dti2143
Chapter 3 dti2143
 
Síntese de proteínas 2008 09
Síntese de proteínas 2008 09Síntese de proteínas 2008 09
Síntese de proteínas 2008 09
 
GEOG101 Chapter 4 Lecture
GEOG101 Chapter 4 LectureGEOG101 Chapter 4 Lecture
GEOG101 Chapter 4 Lecture
 
Fotosintese 2009 new
Fotosintese 2009 newFotosintese 2009 new
Fotosintese 2009 new
 
A history of lemonade
A history of lemonadeA history of lemonade
A history of lemonade
 
Câu chuyệ sức khoẻ 21
Câu chuyệ sức khoẻ 21Câu chuyệ sức khoẻ 21
Câu chuyệ sức khoẻ 21
 
žYdėjimas
žYdėjimasžYdėjimas
žYdėjimas
 
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
CPIのACE01サーバーでマルチドメイン運用をやってみた:MTDDC Meetup TOKYO 2014
 
Rèdais & IED_De Maio
Rèdais & IED_De MaioRèdais & IED_De Maio
Rèdais & IED_De Maio
 
מעברים ורצפים לאתר
מעברים ורצפים לאתרמעברים ורצפים לאתר
מעברים ורצפים לאתר
 
تعليمات السلامة
تعليمات السلامةتعليمات السلامة
تعليمات السلامة
 
Rèdais & IED_Gokcek
Rèdais & IED_GokcekRèdais & IED_Gokcek
Rèdais & IED_Gokcek
 
Presentatie Altijd Mooi en Altijd Mooi Natuurlijk
Presentatie Altijd Mooi en Altijd Mooi NatuurlijkPresentatie Altijd Mooi en Altijd Mooi Natuurlijk
Presentatie Altijd Mooi en Altijd Mooi Natuurlijk
 

Similar to Bti1022 lab sheet 3

Similar to Bti1022 lab sheet 3 (20)

Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
 
Dti2143 lab sheet 8
Dti2143 lab sheet 8Dti2143 lab sheet 8
Dti2143 lab sheet 8
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
Lab 2
Lab 2Lab 2
Lab 2
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
Bti1022 lab sheet 7
Bti1022 lab sheet 7Bti1022 lab sheet 7
Bti1022 lab sheet 7
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C chap02
C chap02C chap02
C chap02
 
C chap02
C chap02C chap02
C chap02
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
 
c programing
c programingc programing
c programing
 
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
 
C
CC
C
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Design problem
Design problemDesign problem
Design problem
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 

More from 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
 

More from 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 3

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Change line 11 to gets(ayat1); (Input:bagan lalang) Explain the output differences. <br />