








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









#include<stdio.h> #include<conio.h> #include<math.h> /******************PROTOTYPES*********************/
void addition(); void subtraction(); void multiplication(); void division(); void remainder(); void factorial(); void square(); void cube(); void power(); void table(); void average(); void prime(); void percentage(); void sine(); void cosine(); void tangent(); void cosec(); void sec(); void cotangent(); void menu(); void main() { menu();
void addition(void) { float no=0,ans=0; char ch; do { printf("\n\t\t\tEnter no "); scanf("%f",&no); ans+=no; printf("Press y or n to add another no or not"); ch=getch(); } while(ch=='y'); printf("\t\t\tANSWER=%f\n\n",ans); }
void subtraction(void) { float no=0,ans=0,num=0; char ch; printf("\t\t\tEnter first no "); scanf("%f",&no); ans=no; printf("Press y or n for another no or not\n"); ch=getch(); if(ch=='n') printf("\t\t\t ANSWER=%f\n\n",ans); else { do { printf("Enter second no "); scanf("%f",&num); ans-=num; printf("Press y or n for another no or not\n"); ch=getch(); } while(ch=='y'); printf("\t\t\tANSWER=%f\n\n",ans); } }
void division(void) { { float no=0,ans=0,num=0; char ch; printf("\nEnter first no "); scanf("%f",&no); ans=no; printf("\nPress y or n for another no or not\n"); ch=getch(); if(ch=='n') printf("\t\t\tANSWER=%f\n\n",ans); else { do { printf("\nEnter second no "); scanf("%f",&num); ans/=num; printf("Press y or n for another no or not\n"); ch=getch();
while(ch=='y'); printf("\t\t\tANSWER=%f\n\n",ans); } } }
void remainder(void) {
double z; int n; printf("\t\t\t*****REMAINDER***** \n"); printf("\t\t\t ENTER n="); scanf("%d",&n);
z=n%2; printf("\t\t\t REMAINDER=%f \n ",z);
void factorial(void) { int i,fact; printf("\t\t\t*****FACTORIAL*****\n"); printf("\t\t\t fact="); scanf("%d",&fact); for(i=(fact-1);i>0;i--)
fact=fact*i;
printf("\t\t\t fact=%d\n",fact);
void square(void) { float u,v; printf("\t\t\t*****SQUARE*****\n"); printf("\t\t\t ENTER NO="); scanf("%f",&u); v=u*u; printf("\t\t\t SQUARE=%f \n",v); }
void cube(void) { float u,v; printf("\t\t\t*****CUBE*****\n"); printf("\t\t\t ENTER NO="); scanf("%f",&u); v=uuu; printf("\t\t\t CUBE=%f\n ",v);
void average(void) {
int avg,sum=0; int i,n,c; int arr[30]; printf("\t\t\t*****AVERAGE*****\n"); printf("\t\t\t HOW MANY NUMBERS n="); scanf("%d",&n); c=n+1; for(i=0;i<=(n-1);i++) { printf("\t\t\t ENTER NUMBER="); scanf("%d",&arr[i]);
for(i=0;i<=(n-1);i++) sum=sum+arr[i]; avg=sum/c; printf("\t\t\t AVERAGE IS=%d \n",avg); }
void prime(void) {
int a,c,b; c=0; printf("\t\t\t*****PRIME NO CHECK*****\n"); printf("\t\t\t ENTER NO="); scanf("%d",&b); for(a=1;a<b;a++) { if(b%a==0) { c++; } }
if(c==1||c==0) { printf("\t\t\t NO. IS PRIME \n");
else printf("\t\t\t NO. IS NOT PRIME \n"); }
void cosine(void) { double angle,radian,value,total; printf("\t\t\t*****COSINE*****"); printf("\n\t\t\t ENTER ANGLE="); scanf("%lf",&angle); radian=(3.141592654/180); total=radian*angle; value=cos(total); printf("\t\t\tvalue=%lf\n",value); }
void tangent() {
double angle,radian,value,total; printf("\t\t\t*****TANGENT*****"); printf("\n\t\t\t ENTER ANGLE="); scanf("%lf",&angle);
radian=(3.141592654/180); total=radian*angle; value=tan(total); printf("\t\t\t VALUE=%lf\n",value); }
void cosec(void) {
double angle,radian,value,total; printf("\t\t\t*****COSEC*****"); printf("\n\t\t\t ENTER ANGLE="); scanf("%lf",&angle); radian=(3.141592654/180); total=radian*angle; value=1/sin(total); printf("\t\t\t VALUE=%lf\n",value); }
void sec(void) { double angle,radian,value,total; printf("\t\t\t*****SEC*****"); printf("\n\t\t\t ENTER ANGLE="); scanf("%lf",&angle); radian=(3.141592654/180); total=radian*angle; value=1/cos(total); printf("\t\t\t VALUE=%lf\n",value); }
void cotangent(void) { double angle,radian,value,total; printf("\t\t\t*****COTANGENT*****"); printf("\n\t\t\t ENTER ANGLE="); scanf("%lf",&angle); radian=(3.141592654/180); total=radian*angle; value=1/tan(total); printf("\t\t\t VALUE=%lf\n",value); }
if(n==1) { addition(); } else if(n==2) { subtraction(); } else if(n==3) { multiplication(); } else if(n==4) { division(); } else if(n==5) { remainder(); } else if(n==6) { factorial(); } else if(n==7) { square(); } else if(n==8) { cube(); } else if(n==9) { power(); } else if(n==10) { table(); } else if(n==11) { average();
else if(n==12) { prime();
else if(n==13) { percentage(); } else if(n==14) { sine(); } else if(n==15) { cosine(); } else if(n==16) { tangent(); } else if(n==17) { cosec(); } else if(n==18) { sec(); } else if(n==19) { cotangent(); } else if(n==20) { break; } }}}