1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include<iostream.h> #include<conio.h> int value=1,p,i; int limit; class multiplication { public: void read() { cout<<"Enter limit of multiplication displayed\n"; cin>>limit; } void calculate() { for(i=1;i<=10;i++) { p=(value*i); cout<<i<<"x"<<value<<"="<<p<<"\n";; } } void next() { if(value<limit) { cout<<"\n"; value++; calculate(); next(); } } }; void main() { multiplication s; clrscr(); s.read(); s.calculate(); s.next(); getch(); } |
Search This Blog
Friday, 29 November 2013
DISPLAY MULTIPLICATION FROM 1 to ANY LIMIT.
CONVERT A MATRIX INTO NONE ZERO SPARSE MATRIX
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include<iostream.h> #include<stdio.h> #include<conio.h> void main() { int a[20][20],r,c,j,i; clrscr(); cout<<"ENTER ORDER\n"; cin>>r; cin>>c; cout<<"ENTER ELEMENT\n"; for(i=0;i<r;i++) { printf("\n"); for(j=0;j<c;j++) { cin>>a[i][j]; } } printf("ORIGINAL MATRIX\n"); for(i=0;i<r;i++) { printf("\n"); for(j=0;j<c;j++) { printf(" %d ",a[i][j]); } } printf("\n\n\n"); printf("NONE ZERO SPARSE MATRIX\n"); for(i=0;i<r;i++) { for(j=0;j<c;j++) { if(a[i][j]!=0) { printf("\n %d %d %d ",(i+1),(j+1),a[i][j]); } } } getch(); } |
Subscribe to:
Posts (Atom)