Skip to content

Commit

Permalink
Merge pull request #2 from kornkaobat/CpptoC
Browse files Browse the repository at this point in the history
Converted from C++ to C.
  • Loading branch information
kornkaobat authored Jul 13, 2023
2 parents 3d66916 + 0759483 commit 6fd9d76
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 72 deletions.
8 changes: 4 additions & 4 deletions ChemAcidBaseCalculator.dev
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
OverrideOutputName=ChemAcidBaseCalculator.exe
HostApplication=
UseCustomMakefile=0
CustomMakefile=
Expand All @@ -28,7 +28,7 @@ Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000000
CompilerSettings=000000d000000000000001000
UnitCount=1

[VersionInfo]
Expand All @@ -39,14 +39,14 @@ Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileVersion=1.0.0.0
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
ProductVersion=1.0.0.0
AutoIncBuildNr=0
SyncProduct=1

Expand Down
Binary file modified ChemAcidBaseCalculator.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions ChemAcidBaseCalculator.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Order=0
Focused=0
[Editor_0]
CursorCol=34
CursorRow=82
TopLine=40
CursorCol=1
CursorRow=4
TopLine=1
LeftChar=1
6 changes: 3 additions & 3 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ CC = gcc.exe
WINDRES = windres.exe
OBJ = main.o
LINKOBJ = main.o
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -s
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++"
BIN = ChemAcidBaseCalculator.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
CXXFLAGS = $(CXXINCS) -Os
CFLAGS = $(INCS) -Os
RM = rm.exe -f

.PHONY: all all-before all-after clean clean-custom
Expand Down
95 changes: 33 additions & 62 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,85 +1,56 @@
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <conio.h>
#include <cmath>
#include <iomanip>
#include <ios>

using namespace std;

int main() {
cout << "Choose Start point..." << '\n';
cout << "1. [H+]\n2. [OH-]\n3. pH\n4. pOH\n";
printf("Choose Start point...\n");
printf("1. [H+]\n2. [OH-]\n3. pH\n4. pOH\n");
int choice;
cin >> choice;
scanf("%d",&choice);
system ("cls");
switch(choice)
{
case 1:
cout << "Convert [H+] to Scientific Notation of A*10^B and input A,B\n";
system ("pause");
cout << '\n';
printf("Convert [H+] to Scientific Notation of A*10^B and input A,B\n");
double A,B;
cout << "A:";
cin >> A;
cout << '\n';
cout << "B:";
cin >> B;
cout << '\n';
cout << "[H+]=" << A*pow(10,B) << '\n';
cout << "[OH-]=" << (1/A)*pow(10,((-14)-B)) << '\n';
cout << "[pH]=" << (-log10(A)-B) << '\n';
cout << "[pOH]=" << 14-(-log10(A)-B) << '\n';
scanf("%le,%le",&A,&B);
printf("\n");
printf("[H+]=%le\n",A*pow(10,B));
printf("[OH-]=%le\n",(1/A)*pow(10,((-14)-B)));
printf("[pH]=%le\n",(-log10(A)-B));
printf("[pOH]=%le\n",14-(-log10(A)-B));
break;
case 2:
cout << "Convert [OH-] to Scientific Notation of Z*10^Y and input Z,Y\n";
system ("pause");
cout << '\n';
printf("Convert [OH-] to Scientific Notation of Z*10^Y and input Z,Y\n");
double Z,Y;
cout << "Z:";
cin >> Z;
cout << '\n';
cout << "Y:";
cin >> Y;
cout << '\n';
cout << "[H+]=" << (1/Z)*pow(10,((-14)-Y)) << '\n';
cout << "[OH-]=" << Z*pow(10,Y) << '\n';
cout << "[pH]=" << 14-(-log10(Z)-Y) << '\n';
cout << "[pOH]=" << (-log10(Z)-Y) << '\n';
scanf("%le,%le",&Z,&Y);
printf("\n");
printf("[H+]=%le\n",(1/Z)*pow(10,((-14)-Y)));
printf("[OH-]=%le\n",Z*pow(10,Y));
printf("[pH]=%le\n",14-(-log10(Z)-Y));
printf("[pOH]=%le\n",(-log10(Z)-Y));
break;
case 3:
cout << "Input pH as X\n";
system ("pause");
cout << '\n';
double X;
cout << "X:";
cin >> X;
double W;
printf("Input pH as X\n");
double X,W;
scanf("%le",&X);
W = -X;
cout << '\n';
cout << "[H+]=" << pow(10,W) << '\n';
cout << "[OH-]=" << pow(10,X-14) << '\n';
cout << "[pH]=" << X << '\n';
cout << "[pOH]=" << 14-X << '\n';
printf("\n");
printf("[H+]=%le\n",pow(10,W));
printf("[OH-]=%le\n",pow(10,X-14));
printf("[pH]=%le\n",X);
printf("[pOH]=%le\n",14-X);
break;
case 4:
cout << "Input pOH as V\n";
system ("pause");
cout << '\n';
double V;
cout << "V:";
cin >> V;
double U;
printf("Input pOH as V\n");
double V,U;
scanf("%le",&V);
U = -V;
cout << '\n';
cout << "[H+]=" << pow(10,V-14) << '\n';
cout << "[OH-]=" << pow(10,U) << '\n';
cout << "[pH]=" << 14-V << '\n';
cout << "[pOH]=" << V << '\n';
printf("\n");
printf("[H+]=%le\n",pow(10,V-14));
printf("[OH-]=%le\n",pow(10,U));
printf("[pH]=%le\n",14-V);
printf("[pOH]=%le\n",V);
break;
}
system("pause");
Expand Down
Binary file modified main.o
Binary file not shown.

0 comments on commit 6fd9d76

Please sign in to comment.