Posts

Showing posts with the label array concept

Q.Write a program to find palindrome string using string functions.

Image
Program: #include < stdio.h > #include < conio.h > #include < string.h > void main() {     char a[30];     int b,c=0,i=0,j;     clrscr();     printf (" Enter the String: ");     scanf ("%s",a);     b=strlen(a);     j=b-1;     while (a[i]==a[j])     {         ++c;         ++i;         --j;     }      if (c==b)          printf ("\n String is Palindrome ");     else         printf ("\n String is not a palindrome ");     getch() ; } Sample Output:      Note:     " Hi I am a Learner of C/C++. I have done this program with my own Knowledge. There may be an easy way to solve this program. So ...

Q. Write a C program to generate pascal triangle or Write a C program to print following number triangle :

Image
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Solution: #include< stdio.h > #include< conio.h > void main() {     int a,b,i,j,d[30],t[30];     clrscr();     printf (" Enter the max limit: ");          scanf ("%d",&a);     b=a;     for (i=0;i< a;i++)     { //Initialisation..         t[0]=1; t[i]=1; d[0]=1; //Spacing..          for (j=0;j< b-1;j++)             printf (" ");         b--; //Calculation..          for (j=1;j<=i;j++)         {         d[j]=t[j-1]+t[j];         }         d...

Q.Write a Program to perform array multiplication( C programming).

Image
Array Multiplication: Solution: #include < conio.h > #include < stdio.h > void main () {     int a[25][25],b[25][25],c[25][25],i,j,m,n,o,k;     clrscr();     printf ("\n Enter row & column in A: \n");         scanf("%d\n%d",&m,&n);     printf ("\n Enter the column value in B: \n");         scanf("%d",&o);     printf ("\ nEnter %d*%d value of A \n",m,n);     for (i=0; i< m; i++)         for (j=0; j< n; j++)             scanf("%d",&a[i][j]);     printf ("\n Enter %d*%d value of B \n",n,o);     for (i=0; i< n; i++)         for (j=0; j< o; j++)             scanf("%d",&b[i][j]);     printf ("\n A value...

Q. Write a program to get two different array values , merge them and finally produce the ascending order sorting of the result. (array Concept)-C programming

Image
Array Concept:   Program: #include < stdio.h > #include < conio.h > void main() {     int a[25],b[25],n,g=0,m,i,j,c,temp;     clrscr();     printf (" Enter the number of a: ");         scanf("%d",&n);     printf ("\n Enter the no of b: ");         scanf("%d",&m);     printf ("\n Enter a values \n");     for ( i=1; i<=n ; i++ )         scanf("%d",&a[i]);     printf ("\n Enter b values \n");     for ( j=1; j<=m ; j++ )     {         scanf("%d",&b[j]);         a[i]=b[j];         i++;     }     printf ("\n Merged values: \n");     c=n+m;     for ( i=1; i<=c; i++ )  ...