Image To Text Converter Portable ( Ascii generator v2.0.0 )
You can convert your image easily as text by this software.
Click Here To Download
Saturday, 28 March 2015
Friday, 27 March 2015
Thursday, 26 March 2015
Fibonacci series using Function & Pointer in C
#include<stdio.h> void fibonacci(int *r) { int a = 0, b = 1, display = 0; printf("fibonacci series: %d %d ", a, b); display = a + b; while (display < *r) { printf("%d ",display); a = b; b = display; display = a + b; } printf("\n"); } int main() { int m; printf("Enter number for fibonacci: "); scanf_s("%d", &m); fibonacci(&m); return 0; }
Friday, 20 March 2015
Character and Word count ingnoring Space
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<stdio.h> int main() { char A[]={"We feel proud to be a Bangladeshi"}; char *p=A; int character=0,word=0; for(int i=0;A[i]!='\0';i++) { if((*(p+i)>='a'&&*(p+i)<='z')||(*(p+i)>='A'&&*(p+i)<='Z')) { character++; } if(((*(p+i)>='a' && *(p+i)<='z') && (*(p+i+1)==' '|| *(p+i+1)=='\0'))||((*(p+i)>='A' && *(p+i)<='Z') && (*(p+i+1)==' '|| *(p+i+1)=='\0'))) { word=word+1; } printf("%c",A[i]); } printf("\n\n\ntotal character in this sentence : %d\n\n",character); printf("\ntotal word in this sentence : %d\n\n\n",word); } |
Triangle of Numeric Number
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 | #include<stdio.h> void fact(int num); int main(void) { int n; printf("enter your number : "); scanf("%d", &n); fact(n); return 0; } void fact(int num) { for(int i=1; i<=num; i++) { for(int j=1;j<=i;j++) { printf("%d", j); } printf("\n"); } return ; } |
String Reverse using Pointer
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 46 47 48 49 | #include<stdio.h> int string_length(char*); void reverse(char*); int main() { char string[100]; printf("Enter a string\n"); gets(string); reverse(string); printf("Reverse of entered string is \"%s\".\n", string); return 0; } void reverse(char *string) { int length, c; char *begin, *end, temp; length = string_length(string); begin = string; end = string; for ( c = 0 ; c < ( length - 1 ) ; c++ ) end++; for ( c = 0 ; c < length/2 ; c++ ) { temp = *end; *end = *begin; *begin = temp; begin++; end--; } } int string_length(char *pointer) { int c = 0; while( *(pointer+c) != '\0' ) c++; return c; } |
String Reverse in C
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 | #include<stdio.h> void boss(char *p) { char a; int i,j; for(j=0;p[j]!='\0';j++) { for(i=0;i<j;i++) { a = p[i]; p[i]=p[j]; p[j]=a; } } return; } int main() { char s[20]; printf("Enter The string to be reverse: "); gets(s); boss (s); printf("The Reversed string is: %s \n",s); return 0; } |
Odd Number Series
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 | #include<stdio.h> void series(int num); int main(void) { int n; printf("enter your number : "); scanf("%d", &n); printf("\n"); series(n); return 0; } void series(int num) { for(int i=1; i<=2*num; i+=2) { for(int j=1;j<=i;j+=2) { printf("%d+", j); } } printf("\n"); return ; } |
Maximum and Minimum Number
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 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include<stdio.h> void main( void ) { int i ,m, q; int *j , *k,*l; j = &i; k=&m;l=&q; printf("Insert first number: "); scanf("%d", j); printf("\nInsert second number: "); scanf("%d", k); printf("\nInsert third number: "); scanf("%d", l); printf("\n"); if(*j>*k) { if(*j>*l) { if(*k>*l) { printf("Maximum number is: %d\n", i); printf("Minimum number is: %d\n", q); } else { printf("Maximum number is: %d\n", i); printf("Minimum number is: %d\n", m); } } else { printf("Maximum number is: %d\n", q); printf("Minimum number is: %d\n", m); } } else if(*k>*l) { if(*j>*l) { printf("Maximum number is: %d\n", m); printf("Minimum number is: %d\n", q); } else { printf("Maximum number is: %d\n", m); printf("Minimum number is: %d\n", i); } } else { printf("Maximum number is: %d\n", q); printf("Minimum number is: %d\n", i); } printf("\n"); } |
Matrix Multiplication using 2D Array
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include<stdio.h> int main() { int A[3][3]; printf("enter your [3]*[3]matrix =9 elements: \n"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { scanf("%d",&A[i][j]); } } printf("\nA matrix is: \n"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { printf("%d ",A[i][j]); } printf("\n"); } int B[3][3]; printf("enter your [3]*[3] matrix =9 elements: \n"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { scanf("%d",&B[i][j]); } } printf("\nB matrix is: \n"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { printf("%d ",B[i][j]); } printf("\n"); } printf("\nC=AxB matrix is: \n"); int C[3][3]; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { int temp=0; for(int k=0;k<3;k++) { temp+=A[i][k]*B[k][j]; } C[i][j]=temp; } } for(int i=0;i<3;i++) { for(int k=0;k<3;k++) { printf("%d ",C[i][k]); } printf("\n"); } } |
Subscribe to:
Posts (Atom)