Posts

Showing posts with the label Number Pattern

How to Print The Given Pattern

Image
What will be the solution of the given pattern in c programming language? Fig:-1 This program is executed on DEV C++ editor. You may use any C or C++ editor to execute the program. logic and programming will be same. For this programming there are many type of programming solution. But I will discus only two of them one the best solution and one the common solution which you found on Internet. 1st type of solution and it's logic. Programming:- #include<stdio.h> #include<conio.h> int main() { int row,col;          //variable deceleration.  for (row= 1 ;row<= 5 ;row++)        // For row { for (col= 1 ;col<=row;col++)      //For  column { printf( " %d" ,col);        //Printing Number pattern   } printf( "\n" );                    //For new line }          getch();    ...

How To Print Number Pattern.

Image
What will be the solution of number pattern for right angle triangle? Fig :-1 Programming #include<stdio.h> #include<conio.h> int main() { int row, col,count,diff;  //Data type deceleration for(row=1;row<=5;row++)   //For row { diff=5-1;             //this is difference for number pattern   count=row;            //count is equal to row for(col=1;col<=row;col++)  // for column { printf(" %d",count);    //printing number pattern count+=diff;            //adding difference in count to print number pattern fro 2nd column and onward diff--;                // decreasing difference by 1. } printf("\n");              //for new line } getch(); return 0; } Output Fig:-2 If you did not understand this code then go to my...