formated code and renamed index.c to gui.c

This commit is contained in:
superdimensional 2021-04-18 15:31:26 -04:00
parent d53b048b9f
commit 34aae499f8
4 changed files with 163 additions and 157 deletions

View file

@ -1,5 +1 @@
# cli-algebra-calculator
cli-algebra-calculator
Make into apple store ios app and run ads on it?
Make into linux app

View file

@ -1,33 +1,37 @@
#include <math.h>
#include <stdio.h>
double exponent( double par){
double exponent(double par)
{
double raisedNum;
raisedNum = par * par;
return raisedNum;
};
double hypotenuse(double par, double par2){
double hypotenuse(double par, double par2)
{
double sideC;
sideC = sqrt( exponent(par) + exponent(par2) );
sideC = sqrt(exponent(par) + exponent(par2));
return sideC;
};
void quadratic(double numA, double numB, double numC, double *awn1ptr, double *awn2ptr){
void quadratic(double numA, double numB, double numC, double *awn1ptr, double *awn2ptr)
{
double awn1 = (-numB) + sqrt( exponent(numB) - 4 * numA * numC);
double awn1 = (-numB) + sqrt(exponent(numB) - 4 * numA * numC);
double awn1F = awn1 / (2 * numA);
double awn2 = (-numB) - sqrt( exponent(numB) - 4 * numA * numC);
double awn2 = (-numB) - sqrt(exponent(numB) - 4 * numA * numC);
double awn2F = awn2 / (2 * numA);
*awn1ptr = awn1F;
*awn2ptr = awn2F;
};
double areaOfCircle(double radius){
double areaOfCircle(double radius)
{
double area;
area = acos(-1) * exponent(radius);
@ -42,18 +46,18 @@ int buildMatrix(int numRows, int numColumns)
printf("Enter elements in matrix of size %dx%d \n", numRows, numColumns);
for(int i = 0; i < numRows; i++)
for (int i = 0; i < numRows; i++)
{
for(int j = 0; j < numColumns; j++)
for (int j = 0; j < numColumns; j++)
{
scanf("%d", &matrix[i][j]);
}
}
printf("\nElements in matrix are: \n");
for(int i = 0; i < numRows; i++)
for (int i = 0; i < numRows; i++)
{
for(int j = 0; j < numColumns; j++)
for (int j = 0; j < numColumns; j++)
{
printf("%d ", matrix[i][j]);
}

View file

@ -3,7 +3,7 @@
#include <stdbool.h>
//import C libraries
//gcc -Wall -Werror -pedantic -std=c11 index.c `pkg-config --cflags --libs gtk+-3.0`
//gcc -Wall -Werror -pedantic -std=c11 gui.c `pkg-config --cflags --libs gtk+-3.0`
//using GTK+ 3.0
/* Function called when the user clicks the show button. */
@ -36,7 +36,8 @@ void on_show_button_4_clicked(GtkWidget *show_button4, GtkWidget *hello_display)
gtk_label_set_markup(GTK_LABEL(hello_display),
"<span font='Italic 30'>4</span>");
}void on_show_button_5_clicked(GtkWidget *show_button5, GtkWidget *hello_display)
}
void on_show_button_5_clicked(GtkWidget *show_button5, GtkWidget *hello_display)
{
printf("5 has been clicked\n");
@ -50,7 +51,8 @@ void on_show_button_6_clicked(GtkWidget *show_button6, GtkWidget *hello_display)
gtk_label_set_markup(GTK_LABEL(hello_display),
"<span font='Italic 30'>6</span>");
}void on_show_button_7_clicked(GtkWidget *show_button7, GtkWidget *hello_display)
}
void on_show_button_7_clicked(GtkWidget *show_button7, GtkWidget *hello_display)
{
printf("7 has been clicked\n");
@ -64,7 +66,8 @@ void on_show_button_8_clicked(GtkWidget *show_button8, GtkWidget *hello_display)
gtk_label_set_markup(GTK_LABEL(hello_display),
"<span font='Italic 30'>8</span>");
}void on_show_button_9_clicked(GtkWidget *show_button9, GtkWidget *hello_display)
}
void on_show_button_9_clicked(GtkWidget *show_button9, GtkWidget *hello_display)
{
printf("9 has been clicked\n");
@ -197,7 +200,8 @@ void build_window(void)
}
/* main() function called when program starts. */
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
/* Call the gtk initialization function */
gtk_init(&argc, &argv);

12
main.c
View file

@ -3,7 +3,10 @@
#include <stdlib.h>
#include "functions.h"
int main (){
// to compile use "gcc main.c -lm"
int main()
{
system("clear");
printf("Welcome to Calculator Collection™.\nPlease select which calculator you would like to use.");
printf("\n\n 1. Hypotenuse calculator");
@ -18,7 +21,8 @@ int main (){
int userInput;
scanf("%i", &userInput);
switch(userInput){
switch (userInput)
{
case 1:
system("clear");
printf("\n ~~ Hypotenuse calculator ~~");
@ -87,9 +91,7 @@ int main (){
default:
printf("\n Incorrect input, try again.\n");
};
return 0;
};
};