Posts

Showing posts from June, 2020

How To Print Given Star Pattern.

Image
What will be the solution of given star pattern? Fig:- 1 This program is executed on DEV C++ editor. You may use any C or C++ editor to execute the program logic will be same. Step that you have to follow for this programming logic. Step 1:- We have to draw a box which will contain 5 rows and 5 column. Fig:-2 Step 2:- We have drawn a box with rows and 5 columns. Now we have to think about its logic portion. Logic for printing star:- If column is smaller then or equal to 5 - row then only we have to print star. Other wise print blank space. Programming:- #include<stdio.h> #include<conio.h> int main() { int row,col;      //Variable deceleration  for (row=0;row<=4;row++)    //Loop for rows { for (col=0;col<=4;col++)  //Loop for column { if (col>=(4-row))      //Condition for printing star { printf(" *");     } else                ...

How To Print Alphabet E in Star Pattern

Image
What will be the solution for the given star pattern? Fig:-1 This program is executed on DEV C++ editor. You may choose any C or C++ editor to execute the program logic and programming will be same for all. For printing the above star pattern follows the step mentioned below. Step 1:- Draw a box of 4 column and 5 row. And insert star in such way that is form alphabet E as given in fig:-2 Fig :-2 Step 2:- Now we have divided fig :-2 in two part so that we can easily write the code. Fig :-3 Step 3:- Now time for logic part if you will see in fig :-3 part 1 then you will find that figure is like rectangle with one side open. 1st part logic:- if row =0 or row =4 or column = 0 then only print star. 2nd part logic:- if row = 2 and column % 3 != 0  then only print star. These are the 2 condition when we have to print star otherwise we have to print blank space. No time for programming. Programming #include<stdio.h> #include<conio.h> int main() { int row, col;    ...

C programming for Armstrong number.

Image
C program for printing Armstrong Number. What is Armstrong Number ? Armstrong Number are those number whose number of digit is the power of digit and there sum. If sum is equal to the number the that number is call Armstrong Number. Example:- If we assume three number 153,8208 and 123. 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 Another example. 8208 = 8^4 + 2^4 + 0^4 + 8^4 = 4096 + 16 + 0 + 4096 = 8208 So these numbers are example of Armstrong number. Another example but this number is not Armstrong Number. 123 = 1^3 + 2^3 + 3^3 = 1 + 8 + 27 = 36 Which is not equal to the original number so it is not a Armstrong Number.  So these numbers are example of Armstrong number. Let us look at programming of it. Programming #include<stdio.h> #include<conio.h> int main() { int num, count = 0 , temp, num_1; //Data type deceleration. /* num = user input number to check ether it is Armstrong Number or not. count = storing sum value. temp = Temporary variable for stori...

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...

How to print the alphabet pattern

Image
What will be the solution of alphabets pattern for right angle triangle? Fig:-1 This program is executed on DEV C++ you may choose any C or C++ editor to execute the program code will be same. Programming type 1:- #include<stdio.h> #include<conio.h> int main() { int row, col;    //data type deceleration  for(row=0;row<=4;row++)  // for row { for(col=0;col<=row;col++)  //for column { printf(" %c",'A'+row);      //printing the alphabet in pattern } printf("\n"); // for new line } getch(); return 0; } Output:- Fig:-2 Programming type 2:- #include<stdio.h> #include<conio.h> int main() { int row, col;    //data type deceleration  for(row=0;row<=4;row++)  // for row { for(col=0;col<=4;col++)  //for column { if(col<=row)  // condition for printing alphabets in pattern { printf(" %c",'A'+row);     //printing the alp...

How To Print Alphabet D in Star Pattern

Image
What will be the solution of given star pattern ? Fig:-1 This programming is executed on DEV C++ editor. You may choose any C or C++ editor to execute the program. Logic and the programming will be same. For printing above star pattern follow the step mention below. Step 1:- Draw a box of 4 column and 5 row.  In fig 2 I have inserted star in such a way that it form the D. Fig:-2 Step 2:-  It is same like  star pattern of alphabets C   but in this we have divided it into three part and figure are as follows. Fig :-3 Step 3:- Now we have divided it into three part and we have to write its logic for the programming. 1st part logic:- If column = 0  then only we have to print star. 2nd part logic:- If row = 0 or row =4 and column % 3!= 0  then we have to print star. 3rd part logic:- If column =3 but row != 0 and row !=4 then we have to print star. These are the 3 condition where we have to print star and rest place we have print the blank space. Now the programm...