Category Archives: C Language

Check Palindrome String C Program

Check Palindrome String C Program – Input a string and check whether this string entered by the user is a Palindrome or Not. Source Code #include <stdio.h> #include <string.h> int main() { char str[100]; int i,size,palindrome=1; printf(“Enter the string : “); gets(str); size=strlen(str); for(i=0;i<size/2;i++) { if(str[i]!=str[size-i-1]) { palindrome=0; break; } } if(palindrome==1) printf(“%s string is… Read More »

Loading

C String Program Remove Blank Spaces

C Program Remove Blank Spaces from a given string entered by the user at run time. Code /* C Program to removing blank spaces from string easyCodeBook.com */ #include <stdio.h> int main() { char str1[100], str2[100]; int i, j, size = 100; printf(“Enter a string to remove spaces:\n”); gets(str1); j=0; for(i=0; str1[i] != ‘\0’; i++)… Read More »

Loading

Create Linux ls command C Program

Create Linux ls command C Program – Write a C program under Windows Operating System to create or simulate linux ls command.   Program code #include<stdio.h> #include<dirent.h> int main(int argc, char **argv) { DIR *dp; struct dirent *link; dp=opendir(argv[1]); printf(“\n contents of the directory %s are \n”, argv[1]); while((link=readdir(dp))!=0) printf(“%s\n”,link->d_name); closedir(dp); } Output contents of… Read More »

Loading

Using Linux System Calls Program Operating Systems Lab

Using Linux System Calls Program Operating Systems Lab – Write a C program Using Linux System Calls Program to create a child process using fork() system call. Display suitable message about parent process ID, child process or Error message if child process could not be created. Program Code using fork() getpid() and exit() #include<stdio.h> #include<unistd.h>… Read More »

Loading

Using Pointers Sort Array

Using Pointers Sort Array – Write a program in C Programming Language To input N numbers and arrange it in Ascending Order. Using Pointers Sort Array – C Source Code #include <stdio.h> void main() { int *ptr,a[100],i,j,temp,n; printf(“\n\n Using C Pointers : Sort an array using pointer :\n”); printf(“—————————————————-\n”); printf(” Enter the size of array… Read More »

Loading

Using Call by Reference Swap Numbers

Using Call by Reference Swap Numbers – Write a C program to swap two values by call by reference method of parameter passing. Program for Passing Parameters – Call By Reference #include <stdio.h> void swap2numbers(int *n1, int *n2); int main() { int num1,num2; printf(“\n\n Using C Pointers : Swap Numbers Using Call by Reference :\n”);… Read More »

Loading