Skip to main content

Posts

Showing posts from April, 2021

Star Light....

Star Light The sky is colored purple It’s colder a night with the breeze There are familiar memories on my mind This night is full of you again I only remember thankful memories You and I, we were all laughing together I’m afraid you’ll disappear and turn into a star I’ll keep this heart in an empty place. When I closer my eyes, I see you clearer Because I miss you more In your place where you’ve spent a long night I’ll take a break and stay with you with a weary heart and tears When my song reaches the sky Come slowly like an eternal dream Please be a star by my side When your heart reaches me Sometimes the stars in the sky that shine on me are like Warmly covering my heart Thank you for your answer When I closer my eyes, I see you clearer Because I miss you more In your place where you’ve spent a long night I’ll take a break and stay with you with a weary heart and tears When my song reaches the sky Come slowly like an eternal dream Please be a star by my side The unforgettable days ...

Selection Sort in C

Selection Sort in C Selection sort  is a simple  sorting algorithm . This  sorting algorithm  is an in-place comparison-based  algorithm  in which the list is divided into two parts, the  sorted  part at the left end and the unsorted part at the right end. Initially, the  sorted  part is empty and the unsorted part is the entire list.  The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. In every iteration of selection sort, the minimum element (considering ascending order) from the unsorted subarray is picked and moved to the sorted subarray. Following example explains the above steps: arr[] = 64 25 12 22 11 // Find the minimum element in arr[0...4] // and place it at beginning 11 25 12 22 64 // Find the minimum element in arr[1...4] // and place it at beginning of arr[1...4] 11 12 25 22 64 // Find the minimum eleme...

Fibonacci Pattern/Series C program

C Program to print fibonacci pattern till N Input: 5 (N value) Output: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Solution:   #include <stdio.h> int Fibonacci(int num){     if(num<=1)         return num;     else     return Fibonacci(num-1)+Fibonacci(num-2) ;//2,1 } int main() { int n,f=1;     scanf("%d",&n);     for(int row=1;row<=n;row++,printf("\n")){         for(int col=1;col<=row;col++){             printf("%d\t",Fibonacci(f++));         }     }     return 0; } ___________________________________________________________ Please Like, Comment and Share! 😉

Nth fibbonacci term C program

Print the fibonacci term at nth position Input: 3  (testcases) 5 4 6 Output: 5 3 8 Solution: #include <stdio.h> int Fibonacci(int num){     if(num<=1)         return num;     else     return Fibonacci(num-1)+Fibonacci(num-2) ;//2,1 } int main() {     int n,result,t;     scanf("%d",&t);     while(t){     scanf("%d",&n);     result=Fibonacci(n);     printf("%d",result);     t--;     }     return 0;      } ________________________________________________________ Related Articles: Fibonacci Pattern in C Like, Comment and Share!😉

Sorting array in descending order C program

Sorting an array in descending order  Input:  7 3 4 2 6 8 10 40 Output: 40 10 8 6 4 3 2 Solution: C #include <stdio.h> void DescSortArray(int *arr,int n){     for(int outer=0;outer<n;outer++){     int temp;     int flag=0;         for(int i=0;i<n-1-outer;i++){           if(arr[i]<arr[i+1])           {           temp=arr[i];           arr[i]=arr[i+1];           arr[i+1]=temp;           flag=1;           }         }if(flag==0)             break;     } for(int i=0;i<n;i++){         printf("%d\t",arr[i]);     } } int main() {     int n,i;//size of the array     int arr[100];     scanf("%d",&n);   ...

Star pattern (right inverted)

PATTERN1 Input: 5 Output:         *       **     ***   **** ***** Solution: C #include<stdio.h> int main() {     int n;     scanf("%d",&n);     for(int i=1;i<=n;i++,printf("\n"))     {         for(int j=n;j>i;j--)         {             printf(" ");         }         for(int j=1;j<=i;j++)             printf("*");     }     return 0; } CPP #include<iostream> using namespace std; int main() {     int n;     cin>>n;     for(int i=1;i<=n;i++)     {         for(int j=n;j>i;j--)         {             cout<<" ";         }         for(int j=1;j<=i;j++) ...