Category Archives: C Language

C Function Kilo Bytes to Bytes

C Function Kilo Bytes to Bytes – C Program to convert kilo bytes into bytes using a user defined function. Source Code   #include <stdio.h> int kb2byte(int kb) { return kb * 1024; } int main() { int k,b; printf(“Enter Kilo Bytes to convert into Bytes:”); scanf(“%d”,&k); b = kb2byte(k); printf(“%d KB = %d Bytes”,k,b);… Read More: C Function Kilo Bytes to Bytes »

Loading

Check Even Odd with Switch Statement

Check Even Odd with Switch Statement – C Program to input a number and check it for even or odd using a switch statement. Source Code #include <stdio.h> int main() { int n; printf(“Enter a number to check for Even/Odd:”); scanf(“%d”,&n); switch(n%2) { case 0: printf(“%d is Even”,n); break; case 1: printf(“%d is Odd”,n); break;… Read More: Check Even Odd with Switch Statement »

Loading

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: Check Palindrome String C Program »

Loading

Count Digits in String C Program

Count Digits in String C Program – Input a string containing both digits and alphabets. This program in C language will display the count of digits in the given string. Source Code /* * C program to count the digits present in the given string */ #include <stdio.h> void main() { char str[100]; int i,count=0;… Read More: Count Digits in String C Program »

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: C String Program Remove Blank Spaces »

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: Create Linux ls command C Program »

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: Using Linux System Calls Program Operating Systems Lab »

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: Using Pointers Sort Array »

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: Using Call by Reference Swap Numbers »

Loading