Upcoming SlideShare
×

# Lab exe 2 dti 2143 dam31303

518 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
518
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
27
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Lab exe 2 dti 2143 dam31303

1. 1. left0UNIVERSITI TUN HUSSEIN ONN MALAYSIA<br />FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING <br />DTI 2143: COMPUTER PROGRAMMING<br />LAB EXERCISE 3<br /><ul><li>Type the following program and execute the instructions in the table in sequence
2. 2. (Ignore the bold numbering and undo each change you made before executing the next instruction)</li></ul>1#include <stdio.h>2#include <conio.h>34int main()5{6int sem_no,cad_no;7sem_no =3;8cad_no =2;9printf("%d", sem_no);10printf("Semester %d",sem_no);11printf("Semester %d, in Lab CAD %d",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 n before the word semester in line 10Add tt before the word Lab in line 11Add aaa before the word Lab in line 11<br /><ul><li>The following is an incomplete program. Debug the program and highlight your changes
3. 3. #inclue<stdio.h> int main(){Sloat salary , tax, net_salary;printf("Enter basic salary:");scanf("%f",salary);tax-0.14*salary;net-salary=salary-tax;printf("nYour tax is : %.2fn", tax);printf("nYour salary is: %.2f", net_salary);return 0;}
4. 4. Type the output and explain the calculation
5. 5. #include <stdio.h>#include <conio.h>int main(){int num= 20;printf ("%dnn", num);int val=30;printf ("%dnn", val);num=val+5; printf ("%dnn", num);val=num-val;printf ("%dnn", val);num=num+2;printf ("%dnn", num);val=30/7;printf ("%dnn", val);getch();return 0;}
6. 6. Type the output and explain the program</li></ul>#include <stdio.h>#include <conio.h>int main(){int num =5;num -=3;num +=4;printf ("%d", num);getch();return 0;}<br /><ul><li>Type the output and explain the program</li></ul>#include<stdio.h>#include<conio.h>int main(){ int x=6,y=6; printf("%d",x++); printf("%d",x); y--; printf("%d %d",x,y); getch (); return 0; }<br />