C Solutions: Heap sort
C Solutions: Insertion Sort
C Solutions: Bubble Sort
C Solutions: To Display numbers(FLOYD) in a triangle
C Solutions: To check whether a Palindrome Number or not
More Topics
Multiple Choice in C: Set 1
QUESTION 1. Choose the correct answer Use of goto enhances the logical clarity of a code Use of goto makes the debugging task easier Use goto when you want to jump out of a nested loop Never user goto QUESTION 2. The minimum number of temporary variables needed to swap the contents of two ...
Full Article +- RSSMore from this category
- Category Archive
Mistakes to avoid: Excessive Commenting
Many comments are unnecessary. They generally make source code hard to maintain. Consider the following statement: a = b; // assign b to a The comment can’t communicate the meaning of the statement more clearly than the code itself, and so is useless.The comment distracts the reader from the code, increasing the volume of text ...
Full Article- RSSMore from this category
- Category Archive
C Solutions: Heap sort
#include<stdio.h> #include<conio.h> void manage(int *, int); void heap_sort(int *, int, int); int main() { int a[50]; int i,j,size,temp,k; printf(“\n\t——- Heap sort ——-\n\n”); printf(“Enter the number of elements to be sorted : “); scanf(“%d”,&size); for(i=1; i<=size; i++) { printf(“Enter %d element : “,i); scanf(“%d”,&a[i]); manage(a,i); } j=size; for(i=1; i<=j; i++) { temp=a[1]; a[1]=a[size]; a[size]=temp; size–; heap_sort(a,1,size); ...
Full Article- RSSMore from this category
- C Solutions: Insertion Sort
- C Solutions: Bubble Sort
- C Solutions: To Display numbers(FLOYD) in a triangle
- C Solutions: To check whether a Palindrome Number or not
- c program to find Combination and Permutation
- C Solutions: To find LCM and HCF/GCD
- C solutions: linear search (sequential search)
- C Solutions: binary search (Interpolation search)
- C Solutions: To find the factorial of a number
- C Solution: To print all even numbers between two input numbers
- Category Archive
Spot the difference — oranges and lemons
A computer recognition system that is 99-percent accurate can identify different fruits and vegetables, even the particular strain of apples or plums, for instance. New research explains how challenging this issue has been until now and shows how it co…
Full Article- RSSMore from this category
- New flex-grid system prevents optical network ‘traffic jams’
- Netradar reveals the quality of mobile Internet connections
- Short algorithm, long-range consequences
- Big data: Searching large amounts of data quickly and efficiently
- Pixels guide the way for the visually impaired
- Creating your own animated 3-D characters and scenes for the web
- Quantum algorithm breakthrough: Performs a true calculation for the first time
- Taking the gamble out of DNA sequencing: How much can be learned in a large-scale experiment
- Embracing social coding: Software development by the people, for the people
- Insects inspiring new technology: Autonomous navigation of mobile robots based on locust vision
- Category Archive
- None found
C Solutions: Heap sort
#include<stdio.h> #include<conio.h> void manage(int *, int); void heap_sort(int *, int, int); int main() { int a[50]; int i,j,size,temp,k; printf(“\n\t——- Heap sort ——-\n\n”); printf(“Enter the number of elements to be sorted : “); scanf(“%d”,&size); for(i=1; i<=size; i++) { printf(“Enter %d element : “,i); scanf(“%d”,&a[i]); manage(a,i); } j=size; for(i=1; i<=j; i++) { temp=a[1]; a[1]=a[size]; a[size]=temp; size–; heap_sort(a,1,size); ...
Full ArticleC Solutions: Insertion Sort
#include<stdio.h> #include<conio.h> main() { int array[20], n, temp, i, j, v; printf(“\n\n\t Enter the number of terms…: “); scanf(“%d”, &n); printf(“\n Enter the value of v: “); scanf(“%d”, &v); if(v<n) { printf(“\n\t Enter the elments…:”); for(i=0; i<n; i++) scanf(“\n\t\t%d”, &array[i]); for(i=1; i<n; i++) { temp = array[i]; j = i-1; while(array[j]>temp && j>=0) { array[j+1] ...
Full ArticleC Solutions: Bubble Sort
#include<stdio.h> #include<conio.h> main() { int array[20], n, temp, i, j; printf(“\n\n\t Enter The No. of Terms : “); scanf(“%d”,&n); printf(“\n\t Enter The Elements :”); for(i=0; i<n; i++) { scanf(“\n\t\t%d”, &array[i]); } for(i=0; i<n-1; i++) for(j=i; j<n-i-1;j++) if(array[j]>array[j+1]) { temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } printf(“\n\tThe ascending order list is…:\n”); for(i=0; i<n; ...
Full ArticleC Solutions: To Display numbers(FLOYD) in a triangle
/* To Display numbers(FLOYD) in a triangle */ main() { int n,i,j,k=0; clrscr(); printf(“Enter the number of lines: “); scanf(“%d”,&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { k=k+1; printf(“%d “,k); } printf(“\n”); } }
Full ArticleC Solutions: To check whether a Palindrome Number or not
A palindrome number is a number such that if we reverse it, it will not change. For example some palindrome numbers examples are 121, 282, 14941, #include<stdio.h> main() { int n, rev = 0, temp; printf(“Enter a number:\n”); scanf(“%d”,&n); temp = n; while( temp != 0 ) { rev = rev * 10; rev = ...
Full Articlec program to find Combination and Permutation
C program to find Combination (nCr) and Permutation (nPr) : nCr = n!/(r!*(n-r)!) and nPr = n!/(n-r)! #include<stdio.h> long factorial(int); long find_ncr(int, int); long find_npr(int, int); main() { int n, r; long ncr, npr; printf(“Enter the values of n and r: \n”); scanf(“%d%d”,&n,&r); ncr = find_ncr(n, r); npr = find_npr(n, r); printf(“%dC%d = %ld\n”, n, ...
Full ArticleC Solutions: To find LCM and HCF/GCD
Following is the code: #include <stdio.h> int main() { int a, b, x, y, t, gcd, lcm; printf(“Enter the two integers: \n”); scanf(“%d%d”, &x, &y); a = x; b = y; while (b != 0) { t = b; b = a % b; a = t; } gcd = a; lcm = (x*y)/gcd; printf(“GCD ...
Full ArticleC solutions: linear search (sequential search)
#include<stdio.h> #include<conio.h> main() { int array[20],pos,n,key,linear_search(int,int *,int); printf(“\n\n Enter the no. of elements: “); scanf(“%d”,&n); printf(“\n\n Enter the elements: \n”); for(int i=0;i<n;i++) scanf(“%d”,&array[i]); printf(“\n\n Enter the no. to be search: “); scanf(“%d”,&key); pos=linear_search(n,array,key); if(pos==0) printf(“\n %d is not found “,key); else printf(“\n %d is found at %d position “,key,pos); return 0; getch(); } int linear_search(int ...
Full ArticleC Solutions: binary search (Interpolation search)
#include<stdio.h> #include<conio.h> main() { int array[20],pos,n,binary_search(int,int *,int),key; printf(“\n\n Enter the no. of elements: “); scanf(“%d”,&n); printf(“\n\n Enter the elements: \n”); for(int i=0;i<n;i++) scanf(“%d”,&array[i]); printf(“\n\n Enter the no. to be search: “); scanf(“%d”,&key); pos=binary_search(n,array,key); if(pos==0) printf(“\n %d is not found “,key); else printf(“\n %d is found at %d position “,key,pos); return 0; } int binary_search(int n,int ...
Full ArticleC Solutions: To find the factorial of a number
Here is the code in C to find out the Factorial of any positive integer number: #include<stdio.h> int main() { int n,i,fact=1; printf(“Enter the value of n: “); scanf(“%d”,&n); for(i=1;i<=n;i++) { fact=fact*i; } printf(“the value for %d! is %d”,n,fact); return 0; }
Full Article