Posts

Showing posts with the label c code

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

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

Use of few mathematical 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 .

Use of all string handling functions.

Image
In this post we are going to see use of string handling functions. strcat():- strcpy( ):- For notes and extra reference download pdf

Develop and execute C Program to Add Two Distances given in kilometer-meter Using Structures.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:-  Step 1:- start. Step 2:- declare structure for km and meter.( struct Distance {    int km;    float m; } d1, d2, result;) Step 3:- take input of both distances. Step 4:- add distances. Step 5:- convert meter to km if greater than 1000 Step 5:- print the result. Step 6:- END. Flowchart :- C code:- Output:-  Try it yourself:- online c compiler Download pdf notes

Perform addition of 3x3 matrix.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2 :- declare variables int a[10]10],b[10][10],c[10][10],i,j; Step 3:- take input for two matrices. printf(“enter all elements of first matrix : \n”);        for(i=0;i<3;i++) {         for(j=0;j<3;j++) {         scanf(“%d”,&a[i][j]); } }        printf(“enter all elements of second matrix : \n”);        for(i=0;i<3;i++) {         for(j=0;j<3;j++) { scanf(“%d”,&b[i][j]); } } Step 4:- add the both matrix. printf(“sum of matrices are: \n”);         for(i=0;i<3;i++) {        for(j=0;j<3;j++)  {         c[[i][j]=a[i][j]+b[i][j];         printf(“%d \t ”,c[i][j]); }        printf(“\n”); } Step 5:- END. Flowchart:- C code:- Output...

Sort list of 10 numbers.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm :- Step 1:- start. Step 2:- declare array = int array[MAXSIZE];  And variable= int i, j, num, temp;   Step 3 :- take input of array. Step 4:- sort arr . As follow:- Bubble sorting      for (i = 0; i < num; i++)     {         for (j = 0; j < (num - i - 1); j++)         {             if (array[j] > array[j + 1])             {                 temp = array[j];                 array[j] = array[j + 1];                 array[j + 1] = temp;             }         } Step 5 :- Print sorted array. Step 6:- END. Flowchart:- C code:- Output:- Try it yourself:- Online c compiler Down...

Produce the following output:

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable int i,j,k, count=1; Step 3:- make the for Loop for all the rows. for(i=1;i<=4;i++)     {         //add left space for pattern         for(j=1;j<=4-i;j++)         {             printf("*");         } Step 4:- add element after space. for(k=1;k<=i;k++)         {             printf(" %d",count);             count++;         }     printf("\n"); Step 5:- END. Flowchart:- C code:- Output:- Try it yourself:- Online c compiler Download pdf notes

Find Fibonacci series for a given number.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable num. Step 3:- print Fibonacci series. As follow:- for(i=2;i<number;++i)     {       n3=n1+n2;       printf(" %d",n3);       n1=n2;       n2=n3;      }     Step 4:- END. Flowchart:- C code:- Output:- Try it yourself:- Online c compiler Download pdf notes

Generate multiplication table up to 10 for numbers 1 to 5.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable num. Step 3:- print the table using for Loop. As follow:- for(int j=1;j<=5;j++) { for(int i=1;i<=10;i++) {     printf("%d * %d = %d\n",j,i,j*i); } printf("\n"); } Step 4:- END. Flowchart:- C code:- Output:- Try it yourself:- Online c compiler Download pdf notes

Find sum of digits of a given number.

Image
This post content:- Algorithm Flowchart C code Output Pdf notes Algorithm:- Step 1:- start. Step 2:- declare variable num. Step 3:- make a function to get a sum. As follow:- int getSum(int n) {     int sum = 0;     while (n != 0) {         sum = sum + n % 10;         n = n / 10;     }     return sum; } Step 4:- end. Flowchart:- C code:- Output:-  Try it yourself:- Online c compiler Download pdf notes

Check whether the triangle is isosceles, equilateral, scalene or right angled triangle.

Image
This post content:- Algorithm Flowchart C code Output PDF notes Algorithm:- Step 1:- start. Step 2:- Declare three sides of the triangle. Step 3: Enter three sides at run time. Step 4:    if(side1 == side2 && side2 == side3)       printf("The Given Triangle is equilateral\n");    else if(side1 == side2 || side2 == side3 || side3 == side1)       printf("The given Triangle is isosceles\n");    else       printf("The given Triangle is scalene\n"); Step 5:- end. Flowchart:- C code:- Output:-  Try it yourself:- Online c compiler Download pdf notes