PR
PR
void add()
{ 7. void prime(int m)
int a,b,i; {
printf("enter the value of a and b int i,c=1;
(a+b):\n"); for(i=2;i<=squrt(m);i++)
scanf("%d%d",&a,&b); {
for(i=1;i<=b;i++) if(m%i==0)
a++; {
printf("sum=%d",a); c=0;
} break;
}
2. void sub() }
{ if(c==0)
int a,b,i; printf("the number is a prime
printf("enter the value of a and b number");
(a-b):\n"); if(c==1)
scanf("%d%d",&a,&b); printf("the number is not a prime
for(i=1;i<=b;i++) number");
a--; }
printf("answer=%d",a);
} 8. void swap_m()
{
3. void mul() int a,b;
{ printf("enter the two
int a,b,c=0,i; numbers:\n");
printf("enter the value of a and b scanf("%d%d",&a,&b);
(a*b):\n"); printf("a=%d and b=%d",a,b);
scanf("%d%d",&a,&b); a=a*b;
for(i=1;i<=b;i++) b=a/b;
c=c+a; a=a/b;
printf("answer=%d",c); printf("\nnow\na=%d and
} b=%d",a,b);
}
4. void div()
{ 9. void swap_a()
int a,b,c=0,i; {
printf("enter the value of a and b int a,b;
(a/b):\n"); printf("enter the two
scanf("%d%d",&a,&b); numbers:\n");
while(a>=b) scanf("%d%d",&a,&b);
{ printf("a=%d and b=%d",a,b);
a=a-b; a=a+b;
c++; b=a-b;
} a=a-b;
printf("quocient=%d and printf("\nnow\na=%d and
remainder=%d",c,a); b=%d",a,b);
} }
5. int fib(int n)
{
if(n==1) 10. void swap_x()
return 0; {
else if(n==2) int a,b;
return 1; printf("enter the two
else numbers:\n");
return(fib(n-1)+fib(n-2)); scanf("%d%d",&a,&b);
} printf("a=%d and b=%d",a,b);
a=a^b;
6. int fact(int n) b=a^b;
{ a=a^b;
if(n==0) printf("\nnow\na=%d and
return 1; b=%d",a,b);
else }
return(n*fact(n-1));
}
11. int gcd(int a,int b)
{ 15. void pali()
if(a==0) {
return b; int a,b,c,r=0;
else printf("enter the data:\n");
return(gcd(b%a,a)); scanf("%d",&a);
} c=a;
while(a!=0)
{
12. int power(int a,int b) b=a%10;
{ r=(r*10)+b;
if(b==0) a=a/10;
return 1; }
else if(c==r)
return(a*power(a,b-1)); printf("\nthe number is a
} palindrome");
else
printf("\nthe number is not a
13. void quad() palindrome");
{ getch();
float a,b,c,d,x1,x2; }
printf("enter the value of a,b and
c(ax^2+bx+c):\n");
scanf("%f%f%f",&a,&b,&c); 16. int stringl(char c[100])
d=((b*b)-(4*a*c)); {
if(d>=0) int l;
{ for(l=0;c[l]!='\0';l++);
printf("\nthe roots are real"); return l;
x1=((-b+sqrt(d))/(2*a)); }
x2=((-b-sqrt(d))/(2*a));
printf("\nthe roots are %f and
%f",x1,x2); 17. void revs()
} {
else int l,i;
{ char s[100],c;
printf("\nthe roots are complex"); fflush(stdin);
x1=1/(2*a); printf("enter the string:\n");
x2=sqrt(-d); gets(s);
printf("the roots are %f(%f+i%f) for(l=0;s[l]!='\0';l++);
and l--;
%f(%f-i%f)",x1,b,x2,x1,b,x2); for(i=0;i<=l/2;i++)
} {
} c=s[i];
s[i]=s[l-i];
s[l-i]=c;
14. void pals() }
{ printf("\nnow the string is\t");
char s[20]; puts(s);
int i,j,c=0; }
fflush(stdin);
printf("enter the string:\n");
gets(s); 18. void revi()
for(i=0;s[i]!='\0';i++); {
for(j=0,k=i-1;j<=i/2;j++,k--) int n,a,r=0;
{ printf("enter the number:\n");
if(s[j]!=s[k]) scanf("%d",&n);
{ printf("\nthe number before
c=1; reversal is=%d",n);
break; while(n!=0)
} {
} a=n%10;
if(c==0) r=(r*10)+a;
printf("\nthe string is a n=n/10;
palindrome"); }
else printf("\nthe number after
printf("\nthe string is not a reversal
palindrome"); is=%d",r);
} }
19. int min(int a[],int n,int min_no)
{
if(n!=0)
{
if(min_no>a[n])
{
min_no=a[n];
return(min(a,n-1,min_no));
}
else
return(min(a,n-1,min_no));
}
else
return(min_no);
}
//min_no=a[n];