C program to display odd numbers between 1 and 100

C program to display the odd digits present in integer

C program to display odd numbers between 1 and 100 #include<stdio.h> int main(){ int rem,i; printf(“\n The odd numbers between 1 and 100 are \n”); for(i=1; i<=100; ++i){ rem = i % 2; if(rem != 0) printf(“\n  %d”,i); } return 0; }  

C program to display the odd digits present in integer

C program to display the odd digits present in integer

C program to display the odd digits present in integer Odd number can not be divided by 2. The remainder after dividing an Odd number by 2 is one. For example . . . Odd digits of number 6547 are 5 and 7. #include<stdio.h> int main(){ int num,rem,odd=0,digit; printf(”  Enter an integer number: “); scanf(“%d”,&num); … Read more

C Program to Print names of all Files present in a Directory

C Program to Print names of all Files present in a Directory

C Program to Print names of all Files present in a Directory dirent.h header file contains variables and functions related to directory streams. #include<stdio.h> #include<dirent.h> int main(void) { DIR *d; struct dirent *dir; d = opendir(“.”); if (d) { while ((dir = readdir(d)) != NULL) { printf(“%s\n”, dir->d_name); } closedir(d); } return(0); } Output: testFile1.txt testFile2.txt … Read more

C Program for Dynamic Memory Allocation using malloc()

C Program for Dynamic Memory Allocation

C Program for Dynamic Memory Allocation using malloc() Below is a program on dynamic memory allocation using malloc() and clearing out memory space using free(). sizeof() returns the number of bytes occupied by any datatype, in this case by an integer. #include <stdio.h> int main() { printf(“\n\n\t\tEduguru – C Program Example\n\n\n”); int n, i, *ptr, sum = 0; printf(“\n\nEnter … Read more

C Program to find Deteminant of 2×2 Matrix

matrix program in c

C Program to find Deteminant of 2×2 Matrix #include<stdio.h> int main() { printf(“\n\n\t\tEduguru – C Program example\n\n\n”); int a[2][2], i, j; long determinant; printf(“\n\nEnter the 4 elements of the array\n”); for(i = 0; i < 2; i++) for(j = 0; j < 2; j++) scanf(“%d”, &a[i][j]); printf(“\n\nThe entered matrix is: \n\n”); for(i = 0; i … Read more

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

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