University Of Karachi C++ Assignment
DIFFUSIVITY EQUATION (PROGRAM AND FLOWCHART) STEEL GRADING (PROGRAM AND FLOWCHART) ZAKAT CALCULATION (PROGRAM AND FLOWCHART)
Syed Saad Ahmed B-0933040 B.E 3rd Year Chemical Engineering
Submitted To: Sir Javaid
C++ Assignment 2012 Program no. 1 (DIFFUSIVITY EQUATION)
#include<stdio.h> #include<conio.h> #include<math.h> void main() { clrscr(); float ma,mb,T,P,S,t,D; printf("Enter the Molecular mass of the gas(A) to be diffused:",ma); scanf("%f",&ma); printf("\nEnter the Molecular mass of the other gas(B):",mb); scanf("%f",&mb); printf("\nEnter the Temperature:",T); scanf("%f",&T); printf("\nEnter the Pressure:",P); scanf("%f",&P); S=sqrt((1/ma)+(1/mb)); t=pow(T,(3/2)); D=((10^-4)*(1.084-0.249*S)*t*S)/P; printf("\n\nThe Diffusivity of gas A in gas B is found to be:%0.3f",D); getch(); }
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering
C++ Assignment 2012 FLOWCHART
INPUT (Molecular mass, temperature, pressure)
STORE VARIABLE (Store values in the variable)
DECISION (Result is stored in the variable)
DECISION ID MADE BY CALCULATING THROUGH FORMULA CONTAINED IN THE CODING
OUTPUT (Print the result)
TERMINATE (Terminate the program)
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering
C++ Assignment 2012 Program no. 2 (STEEL GRADING)
#include<stdio.h> #include<conio.h> void main() { clrscr(); float H,C,T,G; printf("Enter the Hardness of the Steel:",H); scanf("%f",&H); printf("\nEnter the Carbon Content of the Steel:",C); scanf("%f",&C); printf("\nEnter the Tensile Stregth of the Steel:",T); scanf("%f",&T); if(H>50 && C<0.7 && T>5600) { G=10; } if(H>50 && C<0.7) { G=9; } if(C<0.7 && T>5600) { G=8; } if(H>50 && T>5600) { G=7; } if(H>50 || C<0.7 || T>5600) { G=6; } else { G=5; } printf("\n\nThe grade of the steel is:%0.3f",G); getch(); }
4
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering
C++ Assignment 2012 FLOW CHART
INPUT (Hardness, carbon content, strength)
STORE VARIABLE (Store values in the variable)
DECISION (Result is stored in the variable)
DECISION IS MADE IN GRADES
OUTPUT (Print the result)
TERMINATE (Terminate the program)
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering
C++ Assignment 2012 Program no. 2 (ZAKAT CALCULATION)
#include<stdio.h> #include<conio.h> #include<math.h> void main() { float C,G,S,T,Z,g; printf("Enter the amount of Cash:",C); scanf("%f",&C); printf("\nEnter the amount of Gold:",G); scanf("%f",&G); printf("\nEnter the amount of Silver:",S); scanf("%f",&S); T=(C+G+S); Z=(T*2.5); g=65000; if(T<7.5*g) { printf("\n\nYour are INELEGIBLE to pay Zakat"); goto end; } else { printf("\n\nThe amount of Zakat is:%0.3f",Z); } end: getch(); }
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering
C++ Assignment 2012
FLOWCHART
INPUT (Amount of gold, silver & cash)
STORE VARIABLE (Store values in the variable)
DECISION (Result is stored in the variable)
INELEGIBLE FOR PAYING ZAKAT
OUTPUT (Print the result)
TERMINATE (Terminate the program)
Prepared By: Syed Saad Ahmed | B.E Chemical Engineering