as

SMACO

Write a C program to SMACO

1. Addition of two numbers
2. Subtraction of two numbers,
3. Multiplication of two numbers
4. Division of two numbers
5. Find MOD
6. GCD of two numbers
7. LCM of two numbers
8. Factorial of given number
9. Square & Cube of given number.
10. Fibonacci series


Code :-
/********************************************************** Program Name - Program for SMACO **********************************************************/ #include #include void main() { long int no,mem[4000],acc,in; int i=0,inst,addr,c=0; char fname[20]; FILE *fp; clrscr(); printf("enter the file name : "); scanf(" %s",&fname); fp=fopen(fname,"r"); if(fp==NULL) { printf("\nFile not found"); exit(); } while(fscanf(fp,"%ld",&in)!=EOF) { mem[c]=in; printf("%ld\n",in); c++; } do { no=mem[i]; inst=no/1000000; addr=no%10000; switch(inst) { case 10: acc=acc+mem[addr]; break; case 11: acc=acc-mem[addr]; break; case 12: acc=acc*mem[addr]; break; case 13: acc=acc/mem[addr]; break; case 21: acc=mem[addr]; break; case 22: mem[addr]=acc; break; case 30: i=addr-1; break; case 31: if(acc>0) i=addr-1; break; case 32: if(acc==0) i=addr-1; break; case 33: if(acc<0 81:="" 82:="" 90:="" addr="" break="" case="" div="" fclose="" fp="" getch="" i="" inst="" ld="" mem="" printf="" scanf="" while="">