Professional Documents
Culture Documents
String To Float Converter (MIXED)
String To Float Converter (MIXED)
Oleh:
UNIVERSITAS BRAWIJAYA
FAKULTAS TEKNIK
JURUSAN TEKNIK ELEKTRO
Juni 2014
String to Float Converter
I. Flowchart
a. Flowchart Fungsi Main
Yes
A
character_angka[i]==’0'; Yes float angka[i]=0;
No A
A
character_angka[i]==’1'; Yes float angka[i]=1;
A
character_angka[i]==’2'; Yes float angka[i]=2;
No A
No A
No
A
B
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int x;
int size;
char character_angka[100];
float angka[100],total=0;
intro();
system("PAUSE");
system("cls");
printf("================================================================================");
printf("Enter the desired string that will be converted to float data type \n");
gets(character_angka);
printf("String Size = %d \n",strlen(character_angka));
size= strlen(character_angka) - 1;
printf ("Loop Control = %d \n",size);
printf("================================================================================");
printf("Array of Float's Memory State after Each Number Has Been Assigned as: \nWhole Decimal \n(Sub-
Function converter_1) \n");
converter_1();
memory_tester();
printf("================================================================================");
printf("Array of Float's Memory State after Each Number Has Been Assigned as: \nDecimal Fraction \n(Sub-
Function converter_2) \n");
converter_2();
memory_tester();
printf("================================================================================");
printf("Final Result as Float Number \n(Sub-Function sum)\n");
sum();
printf("%.3f \n",total);
printf("================================================================================");
system("PAUSE");
return 0;
if (character_angka[i]=='0') angka[i]= 0;
else if (character_angka[i]=='1') angka[i]= 1;
else if (character_angka[i]=='2') angka[i]= 2;
else if (character_angka[i]=='3') angka[i]= 3;
else if (character_angka[i]=='4') angka[i]= 4;
else if (character_angka[i]=='5') angka[i]= 5;
else if (character_angka[i]=='6') angka[i]= 6;
else if (character_angka[i]=='7') angka[i]= 7;
else if (character_angka[i]=='8') angka[i]= 8;
else if (character_angka[i]=='9') angka[i]= 9;
}
}