Posts

Search a data using binary search

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare a sorted array. Step 3:- declare the size of the given array. Step 4:- declare the variable to find the number in the given array. Step 5:- make a function for binary search algorithm. int binarysearch(int arr[],int size,int element) {     int low=0;     int high=size -1;          while(low<=high)     {         int mid = (low + high)/2;         if (arr[mid]==element)         {             return mid;         }         if (arr[mid]< element)         {             low = mid+1;         }         if (arr[mid]> element)         {             high = mid-1;         }     }     return -1; } Step 6:- print result. Step 7:- END. Flowchart:- C code:- Output:- Try it yourself :- Online c compiler Download pdf notes

Search a Data Using Linear Search

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm :- Step 1:- start. Step 2:- declare an array. Step 3:- declare variable and assign size of array to it. (int size = sizeof(arr)/sizeof(int);) Step 4:- give the value to find in the array. Step 5:- make the function for linear search     for(int i= 0;i<=size;i++)     {         if(arr[i]==element)         {           return i;         }     }      return -1; }(End of function) Step 6:- assign output to the variable result. Step 7:- print result. Step 8:- end. Flowchart:- C code:- Output:- Try it yourself:- online c compiler Download pdf notes

Develop a c program to find the sum of all elements stored in a given array using a pointer.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable I, n, sum. Step 3:- Create a pointer variable, which points to an integer. Step 4:- Take a size of the array as input. Step 5:- create space for array. Step 6:- take elements of array as input, using for Loop. Step 7:- add all elements in a given array using pointer and for loop. Step 8:- print the sum of all elements. Step 9:- END. Flowchart :-  C code:- Output:- Try it yourself:- online c compiler Download pdf notes

Develop a program to print values of variable and their addresses.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable num. Step 3:- take input for variable num. Step 4:- create pointer and Store address of num variable. Step 5:- print the value and address of variable num using pointer. Step 6:- END. Flowchart:- C code:- Output:-  Try it yourself:- online c compiler Download pdf notes

Find Factorial of given number using recursion.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare fact function. Step 3:- declare variable num. Step 4:- take input for num. Step 5:- call fact function. Step 6:- define function. Step 7:- END Flowchart:- C code:- Output:- Try it yourself:- online c compiler Download pdf notes

Create a function to find GCD of a given number. Call this function in a program.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare gcd function. Step 3:- declare variable int num1,num2; Step 4:- take input for two numbers. Step 5:- call gcd function. Step 6:- define gcd function. Step 7:- END. Flowchart:-  C code:- Output:- Try it yourself:- online c compiler Download pdf notes

Use of few other miscellaneous functions.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:-  Step 1:- start. Step 2:- use the given function properly. Step 3:- print the result. Step 4:- END. Flowchart:- C code:- Output:- For better understanding:- check this Try it yourself :- online c compiler Download pdf notes