Upcoming SlideShare
×

comp2

207 views
175 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
207
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide

comp2

1. 1. http://eglobiotraining.com
2. 2. The first programming source code will show us the sum or difference or product of two integers by using C language programming. http://eglobiotraining.com
3. 3. #include<stdio.h>#include<conio.h>int main(){ int num1,num2,ans,ch;printf("enter 1st integer: ");scanf("%d", &num1);printf("enter 2nd integer: ");scanf("%d", &num2);printf(" press 1 for ADD, 2 for DIFFERENCE and 3 for PRODUCT:");scanf("%d", &ch);switch(ch){ case 1: ans=num1+num2; break; case 2: ans=num1-num2; break; case 3: ans=num1*num2; break; default: printf("you entered wrong number!"); } printf("answer is %d", ans); getch(); } http://eglobiotraining.com
4. 4. For example on this programming source code:The user input 3 as the 1st integer while 4 as the 2nd integer. The user then chooses to add them so the programming output is 7. http://eglobiotraining.com
5. 5. The second programming source code will determine whether to solve for volume of a irregular prism or volume of a pyramid by using C language programming. http://eglobiotraining.com
6. 6. #include <stdio.h>#include<conio.h>main(){ int opcode; int a, b,c=3; int result; printf("Enter Your Choice: 1 - Volume of irregular prism , 2 - Volume of pyramid: "); scanf("%d", &opcode); printf("Enter Base:"); scanf("%d", &a); printf("Enter Height:"); scanf("%d", &b); switch(opcode) { case 1: result = a * b; printf("%d * %d = %d", a, b, result); break; case 2: result = a*b/c; printf("%d *%d/%d = %d", a, b,c, result); break; } getch();} http://eglobiotraining.com
7. 7. For example on this programming source code:The user like to solve for the volume of a pyramid. The user input 4 as the base and 6 as the height. The programming output of the volume of the pyramid is 8. http://eglobiotraining.com
8. 8. The 3rdprogramming source code will determine the area of a rectangle or a triangle by using C language programming. http://eglobiotraining.com
9. 9. #include <stdio.h>#include<conio.h>main(){ int opcode; int a, b,c=2; int result; printf("Enter Your Choice: 1 - Area of parallelogram, 2 - Area of triangle: "); scanf("%d", &opcode); printf("Enter Base:"); scanf("%d", &a); printf("Enter Height:"); scanf("%d", &b); switch(opcode) { case 1: result = a * b; printf("%d * %d = %d", a, b, result); break; case 2: result = a*b/c; printf("%d *%d/%d = %d", a, b,c, result); break; } getch(); http://eglobiotraining.com}
10. 10. For example on this programming sourcecode:The user wants to know the area of the parallelogram and he input 6 as the base and 3 as the height. So the programming output of the area of a parallelogram is 24. http://eglobiotraining.com
11. 11. The 4 th programming source code will show the addition, subraction, multiplication and division of 2 numbers by using C language programming. http://eglobiotraining.com
12. 12. #include <stdio.h>#include<conio.h>main(){ int opcode; int a, b; int result; printf("Program for Addition, Subtraction, Multiplication and Divisionn"); printf("Enter Your Choice: 1 - Add, 2 - Sub, 3 - Mul, 4 - Div: "); scanf("%d", &opcode); printf("Enter First Number:"); scanf("%d", &a); printf("Enter Second Number:"); scanf("%d", &b); switch(opcode) { case 1: result = a + b; printf("%d + %d = %d", a, b, result); break; case 2: result = a - b; printf("%d - %d = %d", a, b, result); break; case 3: result = a * b; printf("%d * %d = %d", a, b, result); break; case 4: result = a / b; printf("%d / %d = %dn ", a, b, result, a, b, a % b); break; } getch();} http://eglobiotraining.com
13. 13. For example on this programming sourcecode:The user wants to know the quotient of two numbers. Let 100 be the 1st number while 20 will be the 2nd number. So the programming output of this program is 5. http://eglobiotraining.com
14. 14. The fifth programming source code will determine the square or cube of a number by using C language programming. http://eglobiotraining.com
15. 15. #include<stdio.h>#include<conio.h>int main(){ int num1,ans,ch;printf("enter 1st integer: ");scanf("%d", &num1);printf(" press 1 for SQUARE, 2 for CUBE:");scanf("%d", &ch);switch(ch){ case 1: ans=num1*num1; break; case 2: ans=num1*num1*num1; break; default: printf("you entered wrong number!"); } printf("answer is %d", ans); getch(); } http://eglobiotraining.com
16. 16. For example on this programming sourcecode:The user input 20 as the number. The user wants to know what is the square of 20. So the programming output is 400. http://eglobiotraining.com
17. 17. http://www.slideshare.net/franzneri/comp2 http://eglobiotraining.com
18. 18. SUBMITTED TO: MR. ERWIN GLOBIOSUBMITTED BY: FRANZ NERI CLEMEÑAFM09205 W-S 10:30AM-12:00PMOfficial Website is http://eglobiotraining.com/ http://eglobiotraining.com