30 Days has September April June and November
Here is the program for Gauss elimination method #include<iostream.h> #include<conio.h> #include<math.h> void main() {float a[6][6],b[6],x[6],t,s; int i,j,n,k; clrscr(); cout<<"Enter the maximum no. of matrix"<<endl; cin>>n; cout<<"Enter th elements of matrix"<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } cout<<"enter the right constant"<<endl; for(i=0;i<n;i++) { cin>>b[i]; } for(k=0;k<n-1;k++) { for(i=k+1;i<n;i++) { t=a[i][k]/a[k][k]; a[i][k]=0; for(j=k;j<n;j++) { a[i][j]=a[i][j]-(t*a[k][i]); } b[i]=b[i]-(t*b[k]); } } x[n-1]=b[n-1]/a[n-1][n-1]; for(i=n-1;i>=0;i--) { s=0; for(j=i+1;j<n;j++) {s=s+(a[i][j]*x[j]); } x[i]=(b[i]-s)/a[i][i]; } cout<<"the solution is"<<endl; for(i=0;i<n;i++) { cout<<"x["<<i<<"]="<<x[i]<<endl; } getch(); } C program for Gauss Jordan method: #include<iostream.h> #include<conio.h> #include<math.h> void main() {float a[6][6],b[6],x[6],t,s; int i,j,n,k; clrscr(); cout<<"Enter the maximum no. of matrix"<<endl; cin>>n; cout<<"Enter th elements of matrix"<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } cout<<"enter the right constant"<<endl; for(i=0;i<n;i++) { cin>>a[i][n]; } for(k=0;k<n;k++) { for(i=0;i<n;i++) if(i!=k) { for(j=k+1;j<n+1;j++) { a[i][j]=a[i][j]-(a[i][k]/a[k][k])*a[k][j]); cout<<"the solution is"<<endl; for(i=0;i<n;i++) { x[i]=(a[i][n]/a[i][i]); cout<<"x["<<i<<"]="<<x[i]<<endl; } getch(); }
#include<stdio.h> #define MAXVAL 1000 void sort1(int a[],int n); void median(int a[],int n); void mode(int a[],int n); int main() { int n; int arr[MAXVAL]; int i; printf("Enter the number of elements:"); scanf("%d",&n); printf("Enter the values:"); for(i=0;i<n;i++) { printf("a[%d]=",i); scanf("%d",&arr[i]); } sort1(arr,n); median(arr,n); mode(arr,n); } void sort1(int a[],int n) { int i; int j; int temp; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } } void median(int a[],int n) { int median; int mid; if((n%2)==0) { mid=n/2; median=(a[mid-1]+a[mid])/2; } else { mid=(n+1)/2; median=a[mid-1]; } printf("The median is:%d\n",median); } void mode(int a[],int n) { int i; int count1[MAXVAL]; for(i=0;i<n;i++) { count1[i]=0; } for(i=0;i<n;i++) { count1[a[i]]++; } i--; int mode=count1[0]; int j; int k; int flag=0; for(j=0;j<=a[i];j++) { if(count1[j]>count1[mode]) mode=j; } for(j=0;j<=a[i];j++) { for(k=j+1;k<=a[i];k++) { if(count1[j]=count1[k] && count1[j]>count1[mode]) { flag=1; } } } if(flag==1) { printf("Mode cannot be calculated"); } else printf("the Mode is:%d",mode); }
1.for j = 2 to length[A] c1 n 2. do key ¬ A[j] c2 n-1 3. //insert A[j] to sorted sequence A[1..j-1] 0 n-1 4. i ¬ j-1 c4 n-1 5. while i >0 and A[i]>key c5 Sum (j=2->n) tj 6. do A[i+1] ¬ A[i] c6 Sum (j=2->n) (tj -1) 7. i ¬ i-1 c7 Sum (j=2->n) (tj -1) 8. A[i+1] ¬ key c8 n -1 Sum j=2->n tj evaluates to (n(n+1)/2)-1 and j=2->(tj-1) evaluates to n(n-1)/2 thus the highest order term after droping constants becomes n2 thus the complexity is n2
#include <stdio.h> int main () { int n, i, j, k; printf ("2 "); for (i=3,n=2; n<=50; i+=2) { for (j=3,k=1; j<i-1; j+=2) { if (i % j 1) { printf ("%d ", i); n++; } } printf("\n"); return 0; }
#include<iostream.h> #include<conio.h> #include<string.h> class parse { int nt,t,m[20][20],i,s,n,p1,q,k,j; char p[30][30],n1[20],t1[20],ch,b,c,f[30][30],fl[30][30]; public: int scant(char); int scannt(char); void process(); void input(); }; int parse::scannt(char a) { int c=-1,i; for(i=0;i<nt;i++) { if(n1[i]==a) { return i; } } return c; } int parse::scant(char b) { int c1=-1,j; for(j=0;j<t;j++) { if(t1[j]==b) { return j; } } return c1; } void parse::input() { cout<<"Enter the number of productions:"; cin>>n; cout<<"Enter the productions one by one"<<endl; for(i=0;i<n;i++) cin>>p[i]; nt=0; t=0; } void parse::process() { for(i=0;i<n;i++) { if(scannt(p[i][0])==-1) n1[nt++]=p[i][0]; } for(i=0;i<n;i++) { for(j=3;j<strlen(p[i]);j++) { if(p[i][j]!='e') { if(scannt(p[i][j])==-1) { if((scant(p[i][j]))==-1) t1[t++]=p[i][j]; } } } } t1[t++]='$'; for(i=0;i<nt;i++) { for(j=0;j<t;j++) m[i][j]=-1; } for(i=0;i<nt;i++) { cout<<"Enter first["<<n1[i]<<"]:"; cin>>f[i]; } for(i=0;i<nt;i++) { cout<<"Enter follow["<<n1[i]<<"]:"; cin>>fl[i]; } for(i=0;i<n;i++) { p1=scannt(p[i][0]); if((q=scant(p[i][3]))!=-1) m[p1][q]=i; if((q=scannt(p[i][3]))!=-1) { for(j=0;j<strlen(f[q]);j++) m[p1][scant(f[q][j])]=i; } if(p[i][3]=='e') { for(j=0;j<strlen(fl[p1]);j++) m[p1][scant(fl[p1][j])]=i; } } for(i=0;i<t;i++) cout<<"\t"<<t1[i]; cout<<endl; for(j=0;j<nt;j++) { cout<<n1[j]; for(i=0;i<t;i++) { cout<<"\t"<<" "; if(m[j][i]!=-1) cout<<p[m[j][i]]; } cout<<endl; } } void main() { clrscr(); parse p; p.input(); p.process(); getch(); }
30 = Jumps in the Grand National
30 Joules is equivalent to 0.03 gigajoules.
Jumps in the Grand National
The work done is calculated by multiplying the force by the distance the object moves in the direction of the force. So, the work done would be 30 N * 30 m = 900 J.
30 days hath September, April, June, and November.
main (){int i,j,a,n,number[30];printf ("Enter the value of N\n");scanf ("%d", &n);printf ("Enter the numbers \n");for (i=0; i
/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i<N-1;i++) for(int j=i+1;j<N-1-i;j++) if(n[j]>n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i<N;i++) { v=n[j]; for(int j=i-1;j>0&&n[j]>v;j--) n[j+1]=n[j]; n[j+1]=v; } */
#include<stdio.h> int main() { int n,i,j,k,a[10][10]; printf("\nEnter the number of nodes: "); scanf("%d",&n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("\nEnter the distance between the host %d%d:", i+1,j+1); scanf("%d",&a[i][j]); } } for(i=0; i<n; i++) { for(j=0; j<n; j++) printf("%d\t",a[i][j]); printf("\n"); } for(k=0; k<n; k++) { for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(a[i][j]>a[i][k]+a[k][j]) a[i][j]=a[i][k]+a[k][j]; } } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { b[i][j]=a[i][j]; if(i==j) b[i][j]=0; } } printf("\nThe output matrix is:\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%d\t",b[i][j]); printf("\n"); } return 0; }
Days have September, April, June, and November
#include<iostream> #include<stdio.h> #include<conio.h> using namespace std; int main() { int a[20][20],b[20][20],c[20][20],i,j,k,m,n,f; cout << "Input row and column of A matrix \n\n"; cin >> n >> m; cout << "\n\nInput A - matrix \n\n"; for(i=0;i<n;++i) for(j=0;j<m;++j) cin >> a[i][j]; cout << "\n\nMatrix A : \n\n"; for(i=0;i<n;++i) { for(j=0;j<m;++j) cout << a[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;++i) for(j=0;j<n;++j) b[i][j]=a[j][i]; cout << "\n\nTranspose of matrix A is : \n\n"; for(i=0;i<m;++i) { for(j=0;j<n;++j) cout << b[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;i++) { for(j=0;j<m;j++){ c[i][j]=0; for(k=0;k<=m;k++) c[i][j]+=a[i][k]*b[k][j]; } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { if((int)c[i][i]==1&&(int)c[i][j]==0) f=1; } } cout<<"\n\n Matrix A * transpose of A \n\n"; for(i=0;i<m;i++) { for(j=0;j<m;j++) cout << c[i][j]; cout << "\n\n"; } if(f==1) cout << "\n\nMatrix A is Orthogonal !!!"; else cout << "\n\nMatrix A is NOT Orthogonal !!!"; getch(); return 0; } -ALOK
these letters stand for the months of the year january february march ... the next letters would be s o n d Hope i helped you lol xx:)
#include<stdio.h> #include<conio.h> void main() { int a[10][10],i,j,k,m,n; printf("enter the order"); scanf("%d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } for(k=0;k<m;k++) { for(i=0;i<=m-1;i++) { for(j=0;j<n-i-1;j++) { if(a[k][j]>a[k][j+1]) temp=a[k][j]; a[k][j]=a[k][j+1]; a[k][j+1]=temp; } } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("sorted matrix=%d",a[i][j]); } } getch(); }