Simple Program to remove Duplicate Element in an Array

Simple Program to remove Duplicate Element in an Array

Simple Program to remove Duplicate Element in an Array   #include<stdio.h> #include<conio.h> void main() { int a[20], i, j, k, n; clrscr(); printf(“\nEnter array size: “); scanf(“%d”, &n); printf(“\nEnter %d array element: “, n); for(i = 0; i < n; i++) { scanf(“%d”, &a[i]); } printf(“\nOriginal array is: “); for(i = 0; i < n; … Read more

C Program example to Find Quotient and Remainder

c prgram avoid goto

C Program example to Find Quotient and Remainder #include<stdio.h> int main() { printf(“\n\n\t\tEduguru – C prgram example\n\n\n”); int c, d, n, a[100], b[100]; printf(“\n\nEnter number of elements in array :”); scanf(“%d”, &n); printf(“\n\nEnter %d elements\n”, n); for(c = 0; c < n; c++) scanf(“%d”, &a[c]); /* temporarily storing elements into array b starting from end … Read more

C Program to find the Sum of First n Natural numbers using for loop

C Program to find the Sum of First n Natural numbers

C Program to find the Sum of First n Natural numbers using for loop   #include <stdio.h> int main() { int n, count, sum = 0; printf(“Enter the value of n(positive integer): “); scanf(“%d”,&n); for(count=1; count <= n; count++) { sum = sum + count; } printf(“Sum of first %d natural numbers is: %d”,n, sum); … Read more

C Program to print the Multiplication Table of any Number

multiplication table program in c

C Program to print the Multiplication Table of any Number #include<stdio.h> int main() { printf(“\n\n\t\tEduguru – C Program Example\n\n\n”); int n,i; printf(“Enter an integer you need to print the table of: “); scanf(“%d”, &n); printf(“\n\n\n”); for(i = 1; i <= 10; i++) { printf(“\n\t\t\t%d * %d = %d \n”, n, i, n*i); } printf(“\n\n\n\n\t\t\tAll Done … Read more

Program to check if input Number is int or float

pointer program example in c

Program to check if input Number is int or float #include<stdio.h> #include<conio.h> #include<string.h> int main() { printf(“\n\n\t\tEduguru – C Program example\n\n\n”); char number[10]; int flag = 0; int length, i = 0; printf(“\n\nEnter a number: “); scanf(“%s”, number); length = strlen(number); // till string does not end while(number[i++] != ‘\0’) // same as while(length–>0) { … Read more

C Program to calculate Power of N using Recursion

c program to add 2 numbers

C Program to calculate Power of N using Recursion   #include<stdio.h> // function prototype declaration int power(int n1, int n2); int main() { printf(“\n\n\t\tStudytonight – Best place to learn\n\n\n”); int base, exp; printf(“Enter base number: “); scanf(“%d”, &base); printf(“\n\nEnter Power factor: “); scanf(“%d”, &exp); printf(“\n\n\n\t\t\t%d^%d = %d”, base, exp, power(base, exp)); printf(“\n\n\t\t\tCoding is Fun !\n\n\n”); … Read more

Program to find Palindrome using Recursion

palindrome program in c

Program to find Palindrome using Recursion A Palindrome is a sequence that if reversed looks identical to the original sequence Eg : abba, level, 999 etc. #include<stdio.h> // declaring the recursive function int isPal(int ); /* global declaration to use the same value in both the functions */ int n; int main() { printf(“\n\n\t\tStudytonight – … Read more

Program to print Fibonacci Series using Recursion

fibonacci-sequence

Program to print Fibonacci Series using Recursion A Fibonacci series is defined as a series in which each number is the sum of the previous two numbers with 1, 1 being the first two elements of the series. #include<stdio.h> // declaring the function void printFibo(int ); int main() { printf(“\n\n\t\tEduguru – Recursion program in c\n\n\n”); … Read more

Program to find Factorial of a Number using Recursion

Program to find Factorial of a Number using Recursion

Program to find Factorial of a Number using Recursion #include<stdio.h> // declaring the function int fact(int); int main() { printf(“\n\n\t\tEduguru – Recursion Program Example\n\n\n”); int num, f; printf(“\n\nEnter a number: “); scanf(“%d”, &num); f= fact(num); printf(“\n\nFactorial of %d is %d\n\n”, num, f); printf(“\n\n\t\t\tCoding is Fun here !\n\n\n”); return 0; } int fact(int aj) { if(aj==1 … Read more

C Program for Adding Two Numbers Using Recursion

c program to add 2 numbers

C Program for Adding Two Numbers Using Recursion #include<stdio.h> int y; /* Function to add two numbers and return the result */ int add(int m, int n) { if(n == 0) return m; /* Recursion: adding 1, n times and then at the end adding m to it */ y = add(m, n-1) + 1; … Read more