Posts

INNER REDUCING PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:  4 SAMPLE INPUT:   4 4 4 4 4 4 4                                    4 3 3 3 3 3 4                                     4 3 2 2 2 3 4                                     4 3 2 1 2 3 4                                     4 3 2 2 2 3 4                                     4 3 3 3 3 3 4                           ...

C PROGRAM TO PRINT THE REMAINING DAYS AND COMPLETED DAYS FROM A GIVEN DATE

Image
  Consider the following I/O samples.   SAMPLE INPUT:  23 08 2000 SAMPLE OUTPUT:    Remaining Days : 130                                 Completed Days : 236                 C PROGRAM:    #include <stdio.h> int main() {     int d,m,y,sum=0;     scanf("%d %d %d",&d,&m,&y);     if(d>31 || m>12)         printf("Invalid");     else     {         switch(m)         {             case 1: sum+=31;             case 2:                  if((y%4==0 && y%100!=0) || y%400==0)                     sum+=29;         ...

Design a way to sort the list of positive integers in the descending order according to frequency of elements. The elements with integers with higher frequency come before with lower frequency elements with same frequency come in the same order as they appear the values.

Image
          Consider the following I/O samples. SAMPLE INPUT:       6                                            2 2 4 9 9 9 SAMPLE OUTPUT:     9 9 9 2 2 4   C PROGRAM:    #include <stdio.h> #include<limits.h> #include<malloc.h> int * frequencySortArray( int *arr,int size) {      int** occurence = NULL;      int maxpos, count = 0, count_flag, o_row, index,max;      int newindex = 0, num, ctr;      occurence = (int**)calloc(1,sizeof(int*));      occurence[0] = (int*)calloc(2,sizeof(int));      occurence[0][0] = arr[0];      occurence[0][1]++;      count++;      for(index = 1 ; index < size ; index++)      {   ...

HOLLOW INVERTED PYRAMID STAR

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:      * * * * *                                               *     *                                                  *          C PROGRAM:    #include <stdio.h> int main() {     int row,col,spc,n;     scanf("%d",&n);     for(row=n; row>=1; --row)     {         for(spc=n; spc>row; spc--)         {             printf("  ");         }         for(col=1; col<2*row; col++)     ...

HOLLOW PYRAMID STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                      *                                           *     *                                         *         *                                       *             *                                     * * * * * * * * *           C PROGRAM:    #include <stdio.h> int main() {     int row,col,spc,n;   ...

HOLLOW SQUARE PATTERN

Image
     Consider the following I/O samples. SAMPLE INPUT:  4 SAMPLE OUTPUT:                                               * * * *                                                       *         *                                                                                 *       *                         ...

INVERTED PYRAMID STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                                                         * * *                                              *   *                                                 *                                                                                 ...