Pages

ATM Programing in C

Sunday, 30 June 2013
‎                                          /*Note Pin code is 1234*/ #include<stdio.h> #include<conio.h> void main(void) {     unsigned long amount=2000,deposit,withdr​aw;     int...
Read more ...

To Calculate Sum of Natural Numbers

Saturday, 29 June 2013
#include <stdio.h> int main() {     int n, count;     int sum=0;       printf("Enter an integer: ");     scanf("%d",&n);     count=1;       while(count<=n)       /* while loop terminates if count>n */    {        sum+=count;      ...
Read more ...

To Convert Hexadecimal to Octal and Vice Versa

Saturday, 29 June 2013
#include <stdio.h> int main() { int n; printf("Enter an octal number: "); scanf("%o",&n); /*Takes number in octal format. */ /* %o and %x will display the number is octal format and hexadecimal form respectively. */ printf("%o in octal = %x in hexadecimal", n, n); printf("\nEnter an hexadecimal number: "); scanf("%x",&n);               /* Takes...
Read more ...

To Convert Decimal to Hexadecimal Number and Hexadecimal to Decimal Number

Saturday, 29 June 2013
#include <stdio.h>#include <math.h>#include <string.h>void decimal_hex(int n, char hex[]);int hex_decimal(char hex[]);int main(){    char hex[20],c;    int n;    printf("Instructions:\n");    printf("Enter h to convert decimal to hexadecimal:\n");    printf("Enter d to hexadecimal number to decimal:\n");    printf("Enter...
Read more ...

To Find Number of Consonants, Digits, Vowels and White Space Character

Saturday, 29 June 2013
#include<stdio.h>int main(){    char line[150];    int i,v,c,ch,d,s,o;    o=v=c=ch=d=s=0;        printf("Enter a line of string:\n");    gets(line);        for(i=0;line[i]!='\0';++i)    {        if(line[i]=='a' || line[i]=='e' || line[i]=='i' || line[i]=='o'...
Read more ...

To Find Largest Element Using Dynamic Memory Allocation

Saturday, 29 June 2013
#include <stdio.h>#include <stdlib.h>int main(){    int i,n;    float *data;    printf("Enter total number of elements(1 to 100): ");    scanf("%d",&n);    data=(float*)calloc(n,sizeof(float));                 /* Allocates the memory for 'n' elements */   ...
Read more ...

To Swap Elements Using Call by Reference

Saturday, 29 June 2013
#include<stdio.h>void cycle(int *x,int *y,int *z);int main(){    int x,y,z;    printf("Enter value of x, y and z respectively: ");    scanf("%d%d%d",&x,&y,&z);    printf("Value before swapping:\n");    printf("x=%d\ny=%d\nz=%d\n",x,y,z);    cycle(&x,&y,&z);    printf("Value after swapping numbers...
Read more ...

To Calculate Standard Deviation by Passing it to Function

Saturday, 29 June 2013
#include <stdio.h> #include <math.h> float standard_deviation(float data[], int n); int main() {     int n, i;     float data[100];     printf("Enter number of datas( should be less than 100): ");     scanf("%d",&n);     printf("Enter elements: ");     for(i=0; i<n; ++i)         scanf("%f",&data[i]);    ...
Read more ...

To Convert Binary to Octal and Vice Versa

Friday, 28 June 2013
#include <stdio.h>#include <math.h>int binary_octal(int n);int octal_binary(int n);int main(){    int n;    char c;    printf("Instructions:\n");    printf("Enter alphabet 'o' to convert binary to octal.\n");    printf("2. Enter alphabet 'b' to convert octal to binary.\n");    scanf("%c",&c);    if ( c=='o'...
Read more ...

To Convert Octal Number to Decimal and Vice Versa

Friday, 28 June 2013
#include <stdio.h> #include <math.h> int decimal_octal(int n); int octal_deciaml(int n); int main() {    int n;    char c;    printf("Instructions:\n");    printf("1. Enter alphabet 'o' to convert decimal to octal.\n");    printf("2. Enter alphabet 'd' to convert octal to decimal.\n");    scanf("%c",&c);    if (c =='d' || c == 'D')   ...
Read more ...

To Convert Binary Number to Decimal or Decimal Number to Binary

Friday, 28 June 2013
#include <stdio.h> #include <math.h> int binary_decimal(int n); int decimal_binary(int n); int main() {    int n;    char c;    printf("Instructions:\n");    printf("1. Enter alphabet 'd' to convert binary to decimal.\n");    printf("2. Enter alphabet 'b' to convert decimal to binary.\n");    scanf("%c",&c);    if (c =='d' || c == 'D')   ...
Read more ...

To Calculate Factorial Using Recursion

Friday, 28 June 2013
#include<stdio.h> int factorial(int n); int main() {     int n;     printf("Enter an positive integer: ");     scanf("%d",&n);     printf("Factorial of %d = %ld", n, factorial(n));     return 0; } int factorial(int n) {     if(n!=1)      return n*factorial(n-1);...
Read more ...

To Calculate Sum using Recursion

Friday, 28 June 2013
#include<stdio.h> int add(int n); int main() {     int n;     printf("Enter an positive integer: ");     scanf("%d",&n);     printf("Sum = %d",add(n));     return 0; } int add(int n) {     if(n!=0)     return n+add(n-1);  /* recursive call */...
Read more ...

To Calculate Power

Friday, 28 June 2013
/* C program to calculate the power of an integer*/ #include <stdio.h> int main() {   int base, exp;   long long int value=1;   printf("Enter base number and exponent respectively: ");   scanf("%d%d", &base, &exp);   while (exp!=0)   {       value*=base;       /* value = value*base; */       --exp;  ...
Read more ...

Write a C Program to Find Roots of Quadratic Equation

Friday, 28 June 2013
/* Library function sqrt() computes the square root. */ #include <stdio.h> #include <math.h>       /* This is needed to use sqrt() function.*/ int main() {   float a, b, c, determinant, r1,r2;   float real, imag;   printf("Enter coefficients a, b and c: ");   scanf("%f%f%f",&a,&b,&c);   determinant=b*b-4*a*c;   if (determinant>0)  ...
Read more ...

To Find ASCII value of a character entered by user

Friday, 28 June 2013
#include <stdio.h>int main(){   char c;   printf("Enter a character: ");   scanf("%c",&c);                 /* Takes a character from user */   printf("ASCII value of %c = %d",c,c);     return 0...
Read more ...

Computes the size of variable using sizeof operator

Friday, 28 June 2013
#include <stdio.h> int main() {   int a;   float b;   double c;   char d;   printf("Size of int: %d bytes\n",sizeof(a));   printf("Size of float: %d bytes\n",sizeof(b));   printf("Size of double: %d bytes\n",sizeof(c));   printf("Size of char: %d byte\n",sizeof(d));   return 0;...
Read more ...

To Add Two Numbers Using Pointers

Friday, 28 June 2013
#include <stdio.h>int main(){   int first, second, *p, *q, sum;   printf("Enter two integers to add\n");   scanf("%d%d", &first, &second);   p = &first;   q = &second;   sum = *p + *q;   printf("Sum of entered numbers = %d\n",sum);   return 0...
Read more ...

To Find Maximum Element in array using Pointers

Friday, 28 June 2013
#include <stdio.h>int main(){  long array[100], *maximum, size, c, location = 1;  printf("Enter the number of elements in array\n");  scanf("%ld", &size);  printf("Enter %ld integers\n", size);  for ( c = 0 ; c < size ; c++ )    scanf("%ld", &array[c]);  maximum  = array;  *maximum = *array;  for (c = 1; c < size; c++)  {    if...
Read more ...

To Find Maximum Element in array

Friday, 28 June 2013
#include <stdio.h>int main(){  int array[100];  int maximum, size, c;  int location = 1;  printf("Enter the number of elements in array\n");  scanf("%d", &size);  printf("Enter %d integers\n", size);  for (c = 0; c < size; c++)    scanf("%d", &array[c]);  maximum = array[0];  for (c = 1; c < size; c++)  {    if (array[c] >...
Read more ...

To Find minimum element in array

Friday, 28 June 2013
#include <stdio.h> int main() {     int array[100];     int minimum, size, c;     int location = 1;     printf("Enter the number of elements in array\n");     scanf("%d",&size);     printf("Enter %d integers\n", size);     for ( c = 0 ; c < size ; c++ )        scanf("%d", &array[c]);    ...
Read more ...

Linear search C program

Friday, 28 June 2013
#include <stdio.h>int main(){   int array[100];   int search, c, number;   printf("Enter the number of elements in array\n");   scanf("%d",&number);   printf("Enter %d numbers\n", number);   for ( c = 0 ; c < number ; c++ )      scanf("%d",&array[c]);   printf("Enter the number to search\n");   scanf("%d",&search);  ...
Read more ...

Binary Search Implementation in C

Friday, 28 June 2013
#include <stdio.h>int main(){   int c, first, last, middle, n, search;   int array[100];   printf("Enter number of elements\n");   scanf("%d",&n);   printf("Enter %d integers\n", n);   for ( c = 0 ; c < n ; c++ )      scanf("%d",&array[c]);   printf("Enter value to find\n");   scanf("%d",&search);  ...
Read more ...

To Reverse an array in C

Friday, 28 June 2013
#include <stdio.h>int main(){   int n, c, d;   int a[100], b[100];   printf("Enter the number of elements in array\n");   scanf("%d", &n);   printf("Enter the array elements\n");   for (c = 0; c < n ; c++)      scanf("%d", &a[c]);   /*    * Copying elements into array b starting from end of array a   ...
Read more ...

To Insert an element in an array

Friday, 28 June 2013
#include <stdio.h>int main(){   int array[100];   int position, c, n, value;   printf("Enter number of elements in array\n");   scanf("%d", &n);   printf("Enter %d elements\n", n);   for (c = 0; c < n; c++)      scanf("%d", &array[c]);   printf("Enter the location where you wish to insert an element\n");  ...
Read more ...

To Delete an element from an array

Friday, 28 June 2013
#include <stdio.h>int main(){   int array[100];   int position, c, n;   printf("Enter number of elements in array\n");   scanf("%d", &n);   printf("Enter %d elements\n", n);   for ( c = 0 ; c < n ; c++ )      scanf("%d", &array[c]);   printf("Enter the location where you wish to delete element\n");   scanf("%d",...
Read more ...

Bubble sort algorithm in c

Friday, 28 June 2013
#include <stdio.h>int main(){  int array[100];  int n, c, d, swap;  printf("Enter number of elements\n");  scanf("%d", &n);  printf("Enter %d integers\n", n);  for (c = 0; c < n; c++)    scanf("%d", &array[c]);  for (c = 0 ; c < ( n - 1 ); c++)  {    for (d = 0 ; d < n - c - 1; d++)    {      if...
Read more ...

To Merge two sorted arrays

Friday, 28 June 2013
#include <stdio.h>void merge(int [], int, int [], int, int []);int main(){    int a[100], b[100], sorted[200];    int m, n, c;    printf("Input number of elements in first array\n");    scanf("%d", &m);    printf("Input %d integers\n", m);    for (c = 0; c < m; c++)    {       scanf("%d",...
Read more ...

Insertion sort algorithm implementation in C

Friday, 28 June 2013
                                                 /* insertion sort ascending order */#include <stdio.h>int main(){  int n, c, d, t;  int array[1000];  printf("Enter number...
Read more ...

Selection Sort algorithm implementation in C

Friday, 28 June 2013
#include <stdio.h>int main(){   int array[100];   int n, c, d, position, swap;   printf("Enter number of elements\n");   scanf("%d", &n);   printf("Enter %d integers\n", n);   for ( c = 0 ; c < n ; c++ )      scanf("%d", &array[c]);   for ( c = 0 ; c < ( n - 1 ) ; c++ )   {     ...
Read more ...

To Add Two matrix

Friday, 28 June 2013
#include <stdio.h>int main(){   int m, n, c, d;   int first[10][10], second[10][10], sum[10][10];   printf("Enter the number of rows and columns of matrix\n");   scanf("%d%d", &m, &n);   printf("Enter the elements of first matrix\n");   for ( c = 0 ; c < m ; c++ )      for ( d = 0 ; d < n ; d++ )        ...
Read more ...

C program to transpose a matrix

Friday, 28 June 2013
#include <stdio.h>int main(){   int m, n, c, d;   int matrix[10][10], transpose[10][10];   printf("Enter the number of rows and columns of matrix ");   scanf("%d%d",&m,&n);   printf("Enter the elements of matrix \n");   for( c = 0 ; c < m ; c++ )   {      for( d = 0 ; d < n ; d++ )     ...
Read more ...

Matrix multiplication in c

Friday, 28 June 2013
#include <stdio.h>int main(){  int m, n, p, q, c, d, k;  int sum = 0;  int first[10][10], second[10][10], multiply[10][10];  printf("Enter the number of rows and columns of first matrix\n");  scanf("%d%d", &m, &n);  printf("Enter the elements of first matrix\n");  for (  c = 0 ; c < m ; c++ )    for ( d = 0 ; d < n ; d++ )     ...
Read more ...

Reverse String in C

Friday, 28 June 2013
#include <stdio.h>#include <string.h>int main(){   char arr[100];   printf("Enter a string to reverse\n");   gets(arr);   strrev(arr);   printf("Reverse of entered string is \n%s\n",arr);   return 0...
Read more ...

To Find String Length

Friday, 28 June 2013
#include <stdio.h>#include <string.h>int main(){   char a[100];   int length;   printf("Enter a string to calculate it's length\n");   gets(a);   length = strlen(a);   printf("Length of entered string is = %d\n",length);   return 0...
Read more ...

Remove Vowels From a String in C using Pointers

Friday, 28 June 2013
#include<stdio.h>#include<stdlib.h>#include<string.h>#define TRUE 1#define FALSE 0int check_vowel(char);main(){   char string[100], *temp, *pointer;   char ch, *start;   printf("Enter a string\n");   gets(string);   temp = string;   pointer = (char*)malloc(100);   if( pointer == NULL )   {      printf("Unable...
Read more ...

Remove Vowels From a String in C

Friday, 28 June 2013
Remove vowels string  C : C program to remove vowels from a string, or to remove, if the input string is "C programming language" so the output will be "C Programming". The program will establish us a new string and processing input string character by character, and if a vowel is something new Finder Series confirms otherwise added character in the new series, ends after the string we copy new string convoys string. A...
Read more ...

Sort a String in alphabetic order

Friday, 28 June 2013
#include <stdio.h> #include <stdlib.h> #include <string.h> void sort_string(char*); int main() {    char string[100];    printf("Enter some text\n");    gets(string);    sort_string(string);    printf("%s\n", string);    return 0; } void sort_string(char *s) {    int c, d = 0;    int length;    char *pointer, *result,...
Read more ...

Remove spaces, blanks from a string in C

Friday, 28 June 2013
#include <stdio.h>int main(){   char text[100], blank[100];   int c = 0, d = 0;   printf("Enter some text\n");   gets(text);   while (text[c] != '\0')   {      if (!(text[c] == ' ' && text[c+1] == ' '))     {        blank[d] = text[c];       ...
Read more ...

Swap Two Strings

Friday, 28 June 2013
 Write a C Program to Swap Two Strings. #include <stdio.h>#include <string.h>#include <malloc.h>int main(){   char first[100], second[100];   char *temp;   printf("Enter the first string\n");   gets(first);   printf("Enter the second string\n");   gets(second);   printf("\nBefore Swapping\n");   printf("First string: %s\n",first);  ...
Read more ...

To Find Frequency of characters in a string in C

Friday, 28 June 2013
This program calculates the frequency of characters in a string, that is to say, the characters are present, how many times in a row. For example, the string "code" each of the character 'c', 'o',  'd' and 'e' appeared once. Considering all lowercase, ignoring other characters (special characters). You can easily program this large and special characters to deal with.#include <stdio.h>#include <string.h>int...
Read more ...

Anagram in C

Friday, 28 June 2013
Anagram c: C program to check whether two strings are anagrams or not, it is assumed that only the string alphabets. Two words are anagrams of each other, is removed when the letters of a word, re-form. 'S another word above definition shows that two strings anagrams that all the characters of the two strings as often. For example, "abc" and "cab" an anagram strings, here each character 'a', 'b' and 'c' only once in the two...
Read more ...

To Read a File in C

Friday, 28 June 2013
C program to read a file: This program reads a file entered by the user, and displays the contents of the screen, a file structure again fopen function to open a file pointer. FILE is a predefined structure stdio.h. If the file has been opened fopen as a pointer back to the file and if it is not able to open a file so that it returns NULL. fgetc function read a character from the file and close the file fclose function. Opening...
Read more ...

To Copy Files in C

Friday, 28 June 2013
 Write a Program Copy Files in C. #include <stdio.h>#include <stdlib.h>int main(){   char ch, source_file[20], target_file[20];   FILE *source, *target;   printf("Enter name of file to copy\n");   gets(source_file);   source = fopen(source_file, "r");   if( source == NULL )   {      printf("Press any key to exit...\n");     ...
Read more ...

To Merge Two Files in C

Friday, 28 June 2013
This C program adds two files and stores the contents of another file. The files are merged and are for reading the file that contains the contents of the two files, open and opened in a write mode. To merge two files first, to open a file and read character by character and content store to read it in another file, and then we read the content of a file and stores it in a file, you can read until EOF (two files the end of the...
Read more ...

To list files in directory in C

Friday, 28 June 2013
This program lists all the files in a library / folder where the executable file is present. For example, if the executable file is present in C: \ \ TC \ \ BIN then displays all the files in C: \ \ TC \ \ BIN. #include <stdio.h> #include <conio.h> #include <dir.h> int main() {       int done;       struct ffblk a;       printf("Press...
Read more ...

To Delete a File in C

Friday, 28 June 2013
The C program to delete a file that is entered by the user, the file will be deleted, be present in the directory where the executable file of the program is available. The file extension must contain, remove the macro used to delete the file. If there is an error to delete the file, an error message will be displayed with perror function.#include<stdio.h>main(){   int status;   char file_name[25];  ...
Read more ...

To Print Date in C

Friday, 28 June 2013
#include <stdio.h>#include <conio.h>#include <dos.h>main(){   struct date d;   getdate(&d);   printf("Current system date is %d/%d/%d",d.da_day,d.da_mon,d.da_year);   getch();   return 0...
Read more ...

To add two complex numbers in C program

Friday, 28 June 2013
#include <stdio.h> struct complex {    int real, img; }; int main() {    struct complex a, b, c;    printf("Enter a and b where a + ib is the first complex number.\n");    printf("a = ");    scanf("%d", &a.real);    printf("b = ");    scanf("%d", &a.img);    printf("Enter c and d where c + id is the second complex number.\n");   ...
Read more ...

To generate random numbers in c program

Friday, 28 June 2013
#include <stdio.h> #include <stdlib.h> int main() {   int c;   int n;   printf("Ten random numbers in [1,100]\n");   for (c = 1; c <= 10; c++)   {     n = rand()%100 + 1;     printf("%d\n", n);   }    return 0; ...
Read more ...