Category Archives: Basic C Programs C Source Code

C Program Binary Search in Array

C Program Binary Search in Array #include <stdio.h> int main() { int i, first, last, middle, n, item, a[100]; printf("Enter number of elements in array[Maximum 100] = "); scanf("%d", &n); printf("Please, Enter %d elements in Ascending order in this array\n ", n); for (i = 0; i < n; i++) { printf("Enter Element number %d… Read More: C Program Binary Search in Array »

Loading

C Program Linear Search in Array

C Program Linear Search in Array #include <stdio.h> int main() { int a[100], item, i, n; printf(“Enter number of elements in array[Maximum 100]=”); scanf(“%d”, &n); for (i = 0; i < n; i++) { printf(“Enter Element Number %d in Array=”, i+1); scanf(“%d”, &a[i]); } printf(“Enter a number to search in array=”); scanf(“%d”, &item); for (i… Read More: C Program Linear Search in Array »

Loading

C Program Find N Power P

C Program Find N Power P Output Enter the number N=2 Enter the Power P=5 The number 2 raised to the power 5 is 32 #include<stdio.h> int main() { int n, i, p; long power=1; printf(“Enter the number N=”); scanf(“%d”, &n); printf(“Enter the Power P=”); scanf(“%d”, &p); for(i=1;i<=p;i++) power = power * n; printf(“The number… Read More: C Program Find N Power P »

Loading

C Program Find Factorial of N

C Program Find Factorial of N Output Enter n number to calculate factorial=5 Factorial of 5 is 120 C Code / C Program To Find Factorial of a number N #include<stdio.h> int main() { int n, i; long fact=1; printf(“Enter n number to calculate factorial=”); scanf(“%d”, &n); for(i=1;i<=n;i++) fact = fact * i; printf(“Factorial of… Read More: C Program Find Factorial of N »

Loading

C Program Print Numbers Between Starting and Ending

C Program Print Numbers Between Starting and Ending Numbers Output: Enter starting Number=51 Enter ending Number=70 All Numbers between 51 and 70 are: 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 C Code / C Program Print Numbers Between Starting and Ending Numbers… Read More: C Program Print Numbers Between Starting and Ending »

Loading

C Program Natural Numbers One to Ten

What are Natural Numbers? The natural numbers (i.e. counting numbers) are numbers which are used for counting and ordering. They can be expressed mathematically as: ℕ = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, … } . Some mathematicians consider 0 to be a natural number. C Source Code Natural Numbers from One To Ten Display #include<stdio.h> int… Read More: C Program Natural Numbers One to Ten »

Loading