Skip to content

Instantly share code, notes, and snippets.

@cjoshmartin
Created October 28, 2016 07:36
Show Gist options
  • Save cjoshmartin/17ebfa76ba9aa93b60585a1628328fa3 to your computer and use it in GitHub Desktop.
Save cjoshmartin/17ebfa76ba9aa93b60585a1628328fa3 to your computer and use it in GitHub Desktop.
c programming homework
/*
*Name: Josh Martin
*Lab 7
*/
#include <stdio.h>
//quadratic function
void quad(double a,double b,double c);
//factorial function
void fact(long a);
int pyth(int a,int b,int c);
int main() {
int i;
do{
double a,b,c;
printf("****************************************************\nMake a choice \n1. Solve a quadratic eqation\n2. Find factorial of a number\n3. Check whether the number form a pyhagorean triplet\nPress 0 to quit!\n**************************************************** \n");
scanf("%d",&i);
if (i==1){
printf("Enter A,B, and C\n");
scanf("%lf",&a); printf("\n");
scanf("%lf",&b);printf("\n");
scanf("%lf",&c);printf("\n");
// printf("%lf %lf %lf\n",a,b,c);
quad(a,b,c);
}
if (i==2){
printf("Enter number Factorial\n");
//fix this shit
scanf("%lf\n",&a);
printf("%lf\n",a);
//fact(a,b,c);
}
if(i==3){
printf("Enter A,B, and C\n");
//fix this shit
scanf("%lf\n",&a);
scanf("%lf\n",&b);
scanf("%lf\n",&c);
printf("%lf %lf %lf\n",a,b,c);
//pyth(a,b,c);
}
}while(1);
return 0;
}
void quad(double a,double b,double c) {
if (a<=0) {
printf("A can't be zero\n");
}
else{
printf("hello hello %lf %lf %lf\n",a,b,c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment