Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <conio.h>
- #define SIZE 50
- int readFile(char array[]);
- void menu(char choice,char array[]);
- int main(){
- char array[SIZE];
- char choice;
- int flag=1;
- while(flag){
- readFile(array);
- menu(choice,array);
- system("CLS");
- }
- getch();
- return 0;
- }
- /* A function that reads the polynomials from file (sample.txt) */
- /* INSIDE THE sample.txt is:
- 8x^9 + 5x^8 - 5x^6 + 2x^4 - 6x + 10
- 5x^9 - 7x^7 + 18x^6 - 4x^3 - 3x - 15
- */
- int readFile(char array[]){
- int i;
- FILE *textFile;
- textFile=fopen("sample.txt","r");
- if(textFile !=NULL){
- while(!feof(textFile)){
- fgets(array,50,textFile);
- printf("First polynomial: %s",array);
- fgets(array,50,textFile);
- printf("Second polynomial: %s",array);
- }
- fclose(textFile);
- }
- else{
- printf("error!");
- }
- printf("\n");
- }
- /* just displaying menu and calling other functions */
- void menu(char choice,char array[]){
- int sum=0;
- float average;
- printf("\n*****************************\n");
- printf("* [A] Addition *\n");
- printf("* [S] Subtraction *\n");
- printf("* [D] Derivative *\n");
- printf("*****************************\n");
- scanf("%c",&choice);
- switch(choice)
- {
- // i still haven't figure out how to extract the polynomial correctly that's why i can't make the functions
- case 'A':
- //polyaddition();
- getch();
- break;
- case 'S':
- //polysubtraction();
- getch();
- break;
- case 'D':
- //firstpolyderivative();
- //secondpolyderivative();
- getch();
- break;
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement