User talk:Mjbri

--- 1)\*sum of digits*\

void main { int n,s; clrscr; printf("\n enter the +ve integer"); scanf("%d",&n); s=0; for(n>=1;) { s=s+n%10; n=n/10; } printf("\n sum of digit is:%d",s); getch; } - 2. \*reverse of digit*\
 * 1) include
 * 2) include

void main { int n,s; clrscr; printf("\n enter the n integer"); scanf("%d",&n); s=0; for(n>=1;) { s=(s*10)+n%10; n=n/10; } printf("\n reverse is:%d",s); getch; } --- 3. \*smallest and largest of three numbers*/
 * 1) include
 * 2) include

void main { int x,y,z; int small,large; printf("\n enter the three integer:"); scanf("%d%d%d",&x,&y,&z); small=((xy)&&(x>z))?x:(y>z?y:z); printf("\n smaller is:%d",small); printf("\n larger is:%d",large); getch; } - 4. \* sum and average of n numbers*\
 * 1) include
 * 2) include

void main { int s=0,i,n; float avg; clrscr; printf("\n enter the value of n:"); scanf("%d",&n); for(i=1;i<=n;i++) { s=s+i; } avg=s/(float)n; printf("\n sum is :%d",s); printf("\n avg is:%f",avg); }
 * 1) include
 * 2) include

5. \* biggest of four numbers*/ void main { int a,b,c,d,small,large; clrscr; printf("\n enter the four integers:"); scanf("%d%d%d%d",&a,&b,&c,&d); small=((ab)&&(a>c)&&(a>d))?a:((b>c&&(b>d))?b:(c>d?c:d)); printf("\n smaller is :%d",small); printf("\n larger is:%d",large); getch; } --- 6. \*biggest of four numbers using loops*/ void main { int a,b,c,d; printf("\n enter the 4 integers"); scanf("%d%d%d%d",&a,&b,&c,&d); if(a>b&&a>c&&a>d) printf("\n larger is %d",a); else if(b>c&&b>d) printf("\n larger is %d",b); else if(c>d) printf("\n larger is %d",c); else printf("\n larger is %d",d); getch; } --- 7. \* exponent series*/
 * 1) include
 * 2) include
 * 1) include
 * 2) include

void main { float x,n,s,nr,dr,i; clrscr; printf("\n enter x to evaluate power x"); scanf("%f",&x); printf("\n enter the last term:"); scanf("%f",&n); s=nr=dr=1.0; for(i=1;i<=n;i++) { nr=nr*x; dr=dr*i; s=s+nr/dr; } printf("\n e power %f is:%f",x,s); getch; } --- 8. \*fibonaci series*\
 * 1) include
 * 2) include

void main { int x,y,z,c,n; scanf("%d",&n); x=0; y=1; printf("\n fibonaci series"); printf("%d%d",x,y); for(c=3;c<=n;c++) { z=x+y; printf("%d",z); x=y; y=z; } getch; }
 * 1) include<stdio.h>
 * 2) include<conio.h>

9. \*prime or not*/

void main { int n,c,j,s; clrscr; printf("\n enter the positive integers n"); scanf("%d",&n); for(c=2;c<=n/2;c++) { if(n%c==0) { printf("\n %d is not prime!",n); exit(1); } } printf("\n %d prime",n); getch; } --- 10. \*sine series*/
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * 3) include<process.h>

void main { float x,n,nr,f,s,i,sign=-1.0; clrscr; printf("\n enter the x and n"); scanf("%f%f",&x,&n); x=x*3.14159/180.0; f=1.0; s=x;nr=x; for(i=1;i<=n;i++) { nr=nr*x*x; f=f*(2.0*i)*(2.0*i+1.0); s=s+nr/f*sign; sign=-sign; } printf("\n sin(%f)is:%f",x*180.0/3.14159,s); getch; } --- 11.
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * \ compute xN*\

void main { int i,n; float x,y=1; clrscr; printf("\n enter the a and n ,integer n>0"); scanf("%f%d",&x,&n); for(i=1;i<=n;i++) y=y*x; printf("\n%f power %d is:%f",x,n,y); getch; }
 * 1) include<stdio.h>
 * 2) include<conio.h>

12. \* sum,avg,sd using one dimensionalarray*/

void main { int x[50],n,i; float s=0,s1=0,avg,sd; printf("\n enter the value of n"); scanf("%d",&n); printf("\n enter %d integers:",n); for(i=0;i<n;i++) scanf("%d",&x[i]); for(i=0;i<n;i++) s=s+x[i]; printf("\n sum is:%f",s); avg=s/(float)n; printf("\n average is:%f",avg); for(i=0;i<n;i++) s1=s1+(x[i]-avg)*(x[i]-avg); sd=sqrt(s1/n); printf("\n sd is:%f",sd); getch; }
 * 1) include<stdio.h>
 * 2) include<math.h>
 * 3) include<conio.h>

13. void main { int x[50],i,min,max,n; clrscr; printf("\n enter n (n<=50)"); scanf("%d",&n); printf("\n enter %d integers:"); for(i=0;i<n;i++) scanf("%d",&x[i]); min=max=x[0]; for(i=1;i<n;i++) { if(x[i]<min) min=x[i]; if(x[i]>max) max=x[i]; } printf("\n min is :%d\t max is:%d",min,max); getch; } -- 14. void main { float x,nr,n,f,s,i,sine=-1.0; clrscr; printf("\n enter x and n:/n"); scanf("%f%f",&x,&n); x=x*3.14159/180.0; s=x; for(i=1;i<n;i++) { nr=nr*x*x; f=f*(2.0*i)*(2.0*i+1.0); s=s+nr/f*sine; sine=-sine; } printf("\n sine is %f is :%f:",x*180.0/3.14159,s); getch; } -- 15. void main { int i,n,r,j,temp; int x[50]; clrscr; printf("\n enter n(n<=50)"); scanf("%d",&n); printf("\n enter %d integers:"); for(i=0;i<n;i++) scanf("%d",&x[i]); for(i=0;i<(n-1);i++) { for(j=r+1;j<n;j++) { if(x[i]>x[j]) { temp=x[i]; x[i]=x[j]; x[j]=temp; } } } printf("\n sorted order is:"); for(i=0;i<n;i++) printf("\t%d",x[i]); getch; } --- 16. void main { int A[10][10],B[10][10],c[10][10],m,n1,n2,p,n,i,j,k; clrscr; printf("enter the order of matrix A:m X n1\n"); scanf("%d%d",&m,&n1); printf("enter the order of matrix b:n2 X p\n"); scanf("%d%d",&n2,&p); if(n1!=n2) { printf("\n matrix multiplication is not possible!"); exit(1); } else { n=n1; printf("\n enter matrix a:%d %d",m,n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&A[i][j]); } } printf("\n enter matrix b:%d %d",n,p); for(i=0;i<n2;i++) { for(j=0;j<p;j++) { scanf("%d",&B[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<p;j++) { c[i][j]=0; for(k=0;k<n;k++) c[i][j]=c[i][j]+A[i][k]*B[k][j]; } } } printf("\n\n"); for(i=0;i<m;i++) { for(j=0;j<p;j++) { printf("\t%d",c[i][j]); } printf("\n"); getch; } } --- 17. void leap_check(int); main { int a,b,i; clrscr; printf("enter an interval(a,b):a>0,b>=a"); scanf("%d%d",&a,&b); for(i=a;i<=b;i++) leap_check(i); getch; } void leap_check(int x) { if(x%4==0&x%100!=0||x%400==0) printf("\t leap year:%d",x); } --- 18. struct student { int regno; int m[5]; float avg; char name[25]; }; main { int i,sum=0.0; struct student s1; clrscr; { printf("\*******************************"); printf("\n enter the student details \n"); printf("*******************************"); printf("\n enter name\n"); scanf("%s",&s1.name); printf("enter regno:"); scanf("%d",&s1.regno); for(i=0;i<5;i++) { printf("\n enter mark:%d \n",i+1); scanf("%d",&s1.m[i]); } for(i=0;i<5;i++) sum+=s1.m[i]; s1.avg=sum/5.0; for(i=0;i<1;i++) { printf("\n************************"); printf("\n name:%s",s1.name); printf("\n regno:%d",s1.regno); printf("\n average:%f",s1.avg); printf("\n************************"); getch; } } } -- 19: merge void main {	int a[max],b[max],c[2*max],i,j,k,n,m; clrscr; printf("size of array a:"); scanf("%d",&n);
 * \ bigest of n num*\
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * \cosin series*/
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * \conventional sorting*/
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * \matrix multi-single array*\
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * 3) include<stdlib.h>
 * \leapyear or not/*
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * \student marksheet/*
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * 1) include<stdio.h>
 * 2) include<conio.h">
 * 3) define max 10

printf("enter a elements: \n"); for(i=0;i<n;i++)

scanf("%d", &a[i]);

printf("size of array b:"); scanf("%d",&m);

printf("enter a elements: \n"); for(i=0;i<m;i++)

scanf("%d", &b[i]); for(i=0,j=0,k=0; i<n && j<m; k++)

if(a[i]<b[j])

c[k] = a[i++];

else

c[k]=b[j++];

while(i<n)

c[k++] = a[i++];

while(j<m)

c[k++] = b[j++]; for(i=0;i<m+n-1;i++) //place each element in to correct position { for(j=i+1;j<m+n;j++) {   if(c[i]>c[j])   //swapping {		temp=c[i]; c[i]=c[j]; c[j]=temp; } } }

printf("\n array c:\n"); for(i=0;i<(m+n); i++) printf("%d", c[i]); getch;

}

---

20)// Simphson's 1/3rd Rule

float fn(float); main { int n,i,j; float a,f,b,k,v,h,y0,yn,sum1,sum2,r; clrscr; printf("\nEnter The Lower Limit & The Upper Limit\n"); scanf("%f%f",&a,&b); printf("\nEnter The No Of Intervals\n"); scanf("%d",&n); h=(b-a)/n; y0=fn(a); yn=fn(b); if (n%2==0) {	for(i=1;i<n;i=i+2)              // a i h k	{                               // 0 1 1 1   a=0,h=1 k=a+i*h;                    // 0 3 1 3 sum1=sum1+fn(k);            // 0 5 1 5 }
 * 1) include<stdio.h>              // S 1/3=h/3((y0+yn)+4(y1+y3+..)+2(y2+y4+..))
 * 2) include<conio.h>
 * 3) include<math.h>

for(j=2;j<n;j=j+2) {		v=a+j*h; sum2=sum2+fn(v); }	r=h/3*((y0+yn)+sum1*4+sum2*2); printf("The Value Is %f",r); } else { printf("The Simphson 1/3 Condition Is Not Satisfied"); } getch; } float fn(float x) { float f; f=1.0/(1+x*x); return f; }

21 //simpson3/8 rule:

float fn(float); main { int n,i,j; float a,f,b,k,v,h,y0,yn,sum1,sum2,r; clrscr; printf("\nEnter The Lower Limit & The Upper Limit\n"); scanf("%f%f",&a,&b); printf("\nEnter The No Of Intervals\n"); scanf("%d",&n); h=(b-a)/n; y0=fn(a); yn=fn(b); if (n%3==0) {	for(i=1;i<n;i++) {		if (i%3!=0) {			k=a+i*h; sum1=sum1+fn(k); }	}	for(j=3;j<n;j+=3) {			v=a+j*h; sum2=sum2+fn(v); }
 * 1) include<stdio.h>        // =3h*8(y0+yn)+3(y1+y2+y4+..)+2(y3+y6)
 * 2) include<conio.h>
 * 3) include<math.h>

r=(3*h/8)*((y0+yn)+sum1*3+sum2*2); printf("The Value Is %f",r); } else { printf("The Simphson 3/8 Condition Is Not Satisfied"); } getch; } float fn(float x) { float f; f=1.0/(1+x*x); return f; } -

22)Trapezoidal Rule: float f(float x) { return(1/(1+(x*x))); } void main { int i,n; float a,b,z,s=0,t; clrscr; printf("\n integration by trapezoidal method"); printf("\n enter the lower limit:\n"); scanf("%f",&a); printf("\n enter the upper limit:\n"); scanf("%f",&b); printf("\n enter the sub interval:\n"); scanf("%d",&n); z=(b-a)/n; for(i=0;i<=n;i++) { s=s+f(a+(i*z)); } t=(z/2)*(f(a)+z*s+f(b)); printf("the result is :%f",t); getch; }
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * 3) include<math.h>

\\\\\\\\\\\\\\\\\\\\\\\\\\ int stack[max],top=-1,count=0; void spush; void spop; void slist; void main { int ch; while(1) { clrscr; printf("\n stack operation:"); printf("\n 1.push"); printf("\n 2.pop"); printf("\n 3.list"); printf("\n 4.exit"); printf("\n enter your choice:"); scanf("%d",&ch); switch(ch) { case 1: spush; break; case 2: spop; break; case 3: slist; break; case 4: printf("\n program in terminated"); getch; } } } void spush { if(count==max) { printf("\n stack overflow"); } else { top++; printf("\n enter number:"); scanf("%d",&stack[top]); count++; printf("\n added value %d",stack[top]); } getch; } void spop { if(top==0) { printf("\n stack underflow"); } else { printf("\n deleted value %d",stack[top]); top--; count--; } getch; } void slist { int ptr; if (top==0) { printf("Empty"); } for(ptr=0;ptr<count;ptr++)
 * 1) include<stdio.h>
 * 2) include<conio.h>
 * 3) define max 4

printf("\n stack=%d",stack[ptr]);

getch; }