Wednesday, September 19, 2012

Code#106:c program to restrict mouse pointer in a circle

| |
0 comments
Basic C Language Program to restrict mouse pointer in a circle is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better  understandability to the user, leave a comment if you are satisfied with the code Click Read more for...
Read More

Code#105:c program to restrict mouse pointer in a rectangle

| |
0 comments
Basic C Language Program to restrict mouse in a rectangle is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understandability to the user, leave a comment if you are satisfied with the code          ...
Read More

Code#104:c program to determine which mouse button is clicked

| |
0 comments
Basic C Language Program to determine which mouse button is clicked   is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understandability to the user, leave a comment if you are satisfied with the code    ...
Read More

Code#103:C Program to get current position of mouse pointer

| |
0 comments
Basic C Language Program  to get current position of mouse pointer  is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understandability to the user, leave a comment if you are satisfied with the code    ...
Read More

Tuesday, September 18, 2012

Code#102:C Program to hide mouse pointer

| |
0 comments
Basic C Language Program  to hide mouse pointer  is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understandability to the user, leave a comment if you are satisfied with the code        ...
Read More

Code#101:C Program to display mouse pointer in graphics mode

| |
1 comments
#include<graphics.h>#include<conio.h>#include<dos.h>int initmouse();void showmouseptr();union REGS i, o;main(){   int status, gd = DETECT, gm;   initgraph(&gd,&gm,"C:\\TC\\BGI");   status = initmouse();   if ( status == 0 )      printf("Mouse support not available.\n");   else      showmouseptr();  ...
Read More

Code#100:C Program to display mouse pointer in textmode

| |
0 comments
#include<dos.h>#include<conio.h>int initmouse();void showmouseptr();union REGS i, o;main(){   int status;   status = initmouse();   if ( status == 0 )      printf("Mouse support not available.\n");   else      showmouseptr();   getch();   return 0;}int initmouse(){   i.x.ax = 0;   int86(0X33,&i,&o);  ...
Read More

Code#99:C Program to check if mouse support is available or not

| |
0 comments
#include<dos.h>#include<conio.h>int initmouse();union REGS i, o;main(){   int status;   status = initmouse();   if ( status == 0 )      printf("Mouse support not available.\n");   else      printf("Mouse support available.\n");   getch();   return 0;}int initmouse(){   i.x.ax = 0;   int86(0X33,&i,&o);  ...
Read More

Code#98:C program to shutdown or turn off computer for Windows 7

| |
0 comments
#include <stdio.h>#include <stdlib.h>main(){   char ch;   printf("Do you want to shutdown your computer now (y/n)\n");   scanf("%c",&ch);   if (ch == 'y' || ch == 'Y')      system("C:\\WINDOWS\\System32\\shutdown /s");   return 0...
Read More

Code#97:C program to shutdown or turn off computer for Windows XP

| |
0 comments
#include <stdio.h>#include <stdlib.h>main(){   char ch;   printf("Do you want to shutdown your computer now (y/n)\n");   scanf("%c",&ch);   if (ch == 'y' || ch == 'Y')      system("C:\\WINDOWS\\System32\\shutdown -s");   return 0...
Read More

Code#96:c program to print date

| |
0 comments
#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;}Output:Current system date is 23/09/20...
Read More

Code #95:c program to add two complex numbers

| |
0 comments
#include <stdio.h>struct complex{   int real, img;};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");   printf("c...
Read More

Code#94:C programming code using random function

| |
0 comments
#include<stdio.h>#include<conio.h>#include<stdlib.h>main(){   int n, max, num, c;   printf("Enter the number of random numbers you want ");   scanf("%d",&n);   printf("Enter the maximum value of random number ");   scanf("%d",&max);   printf("%d random numbers from 0 to %d are :-\n",n,max);   randomize();   for ( c = 1 ;...
Read More

Code#93:c program to delete a file

| |
0 comments
#include<stdio.h>main(){   int status;   char file_name[25];   printf("Enter the name of file you wish to delete\n");   gets(file_name);   status = remove(file_name);   if( status == 0 )      printf("%s file deleted successfully.\n",file_name);   else   {      printf("Unable to delete the file\n");     ...
Read More

Code#92:c program to list files in directory

| |
0 comments
#include<stdio.h>#include<conio.h>#include<dir.h>main(){   int done;   struct ffblk a;   printf("Press any key to view the files in the current directory\n");   getch();   done = findfirst("*.*",&a,0);   while(!done)   {      printf("%s\n",a.ff_name);      done = findnext(&a);  ...
Read More

Code#91:c program to merge two files

| |
0 comments
#include<stdio.h>#include<conio.h>#include<stdlib.h>main(){   FILE *fs1, *fs2, *ft;   char ch, file1[20], file2[20], file3[20];   printf("Enter name of first file ");   gets(file1);   printf("Enter name of second file ");   gets(file2);   printf("Enter name of file which will store contents of two files ");   gets(file3);  ...
Read More

Code#90:c program to copy files

| |
0 comments
#include <stdio.h>#include <stdlib.h>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");      exit(EXIT_FAILURE);  ...
Read More

Code#89:c program to read a file

| |
0 comments
C program to read a file :- This program reads a file entered by the user and displays it's contents on the screen, fopen function is used to open a file, it returns a pointer to structure FILE. FILE is a predefined structure in stdio.h . If the file is successfully opened then fopen returns a pointer to file and if it is unable to open...
Read More

Code#88:C Program to check for Anagrams

| |
0 comments
Anagram in c: c program to check whether two strings are anagrams or not, string is assumed to consist of alphabets only. Two words are said to be anagrams of each other if the letters from one word can be rearranged to form the other word. From the above definition it is clear that two strings are anagrams if all characters in both strings occur same number of times. For example "abc" and "cab" are anagram strings, here every...
Read More

Code#87:c program to find frequency of characters in a string

| |
1 comments
#include<stdio.h> #include<string.h> main() {    char string[100], ch;    int c = 0, count[26] = {0};    printf("Enter a string\n");    gets(string);    while ( string[c] != '\0' )    {       /* Considering characters from 'a' to 'z' only...
Read More

Code# 86:c program to swap two strings

| |
0 comments
#include<stdio.h>#include<string.h>#include<malloc.h>#include<conio.h>main(){   char first[100], second[100], *temp;   printf("Enter the first string ");   gets(first);   printf("Enter the second string ");   gets(second);   printf("\nBefore Swapping\n");   printf("First string: %s\n",first);   printf("Second string: %s\n\n",second);  ...
Read More

Code#85:C Program Change string to lower case without strlwr

| |
1 comments
#include<stdio.h>void lower_string(char*);main(){   char string[100];   printf("Enter a string to convert it into lower case\n");   gets(string);   lower_string(string);   printf("Entered string in lower case is \"%s\"\n", string);   return 0;}void lower_string(char *string){   while(*string)   {      if ( *string >=...
Read More

Code#84:C Program To Change string to upper case without strupr

| |
0 comments
#include<stdio.h>void upper_string(char*);main(){   char string[100];   printf("Enter a string to convert it into upper case\n");   gets(string);   upper_string(string);   printf("Entered string in upper case is \"%s\"\n", string);   return 0;}void upper_string(char *string){   while(*string)   {       if ( *string...
Read More

Code#83:c program remove spaces, blanks from a string using pointers

| |
0 comments
#include<stdio.h>#include<string.h>#include<stdlib.h>#define SPACE ' 'main(){   char string[100], *blank, *start;   int length, c = 0, d = 0;   printf("Enter a string\n");   gets(string);   length = strlen(string);   blank = string;   start = (char*)malloc(length+1);   if ( start == NULL )      exit(EXIT_FAILURE);  ...
Read More

Code# 82:c program to remove spaces, blanks from a string

| |
0 comments
#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];        d++;     ...
Read More

Code# 81:c program to sort a string in alphabetic order

| |
0 comments
Basic C Language Program  to sort a string in alphabetic order  is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understandability to the user, leave a comment if you are satisfied with the code #include <stdio.h>#include...
Read More

Code# 80:C Program To Find All Substrings Of String

| |
0 comments
#include <stdio.h>#include <string.h>#include <malloc.h>char* substring(char*, int, int);main() {   char string[100], *pointer;   int position = 1, length = 1, temp, string_length;   printf("Enter a string\n");   gets(string);   temp = string_length = strlen(string);   printf("Substring of \"%s\" are\n", string);   while (position <= string_length)  ...
Read More

Code#79:C Program To Find Substring

| |
0 comments
#include <stdio.h>#include <malloc.h>char* substring(char*, int, int);main() {   char string[100], *pointer;   int position, length;   printf("Enter a string\n");   gets(string);   printf("Enter the position and length of substring\n");   scanf("%d%d",&position, &length);   pointer = substring( string, position, length);   printf("Required...
Read More

Code#78:C Program TO Delete Vowel From Given String Using Pointers

| |
0 comments
#include<stdio.h> #include<stdlib.h> #include<string.h> #define TRUE 1 #define FALSE 0   int check_vowel(char);   main() { char string[100], *temp, *pointer, ch, *start;   printf("Enter a string\n"); gets(string);   temp = string; pointer = (char*)malloc(100);   if( pointer == NULL ) { printf("Unable to allocate memory.\n"); exit(EXIT_FAILURE); }   ...
Read More

Code#77:C Program To delete Vowels from Given String

| |
0 comments
#include <stdio.h>#include <string.h>int check_vowel(char);int main(){  char s[100], t[100];  int i, j = 0;  printf("Enter a string to delete vowels\n");  gets(s);  for(i = 0; s[i] != '\0'; i++) {    if(check_vowel(s[i]) == 0) {       //not a vowel      t[j] = s[i];      j++;   ...
Read More

Monday, September 17, 2012

Code#76:C program to check string is palindrome or not without using string functions

| |
0 comments
#include <stdio.h> #include <string.h> main() {    char text[100];    int begin, middle, end, length = 0;    gets(text);    while ( text[length] != '\0' )       length++;    end = length - 1;    middle = length/2;    for( begin = 0 ; begin < middle ; begin++ )    {       if ( text[begin] != text[end]...
Read More

Code#75:C program to check string is palindrome or not

| |
0 comments
#include <stdio.h> #include <string.h> main() {    char a[100], b[100];    printf("Enter the string to check if it is a palindrome\n");    gets(a);    strcpy(b,a);    strrev(b);    if( strcmp(a,b) == 0 )       printf("Entered string is a palindrome.\n");    else       printf("Entered string is not a palindrome.\n");  ...
Read More

Code# 74:C program to reverse a string using recursion

| |
0 comments
#include<stdio.h> #include<string.h> void reverse(char*,int,int); main() {    char a[100];    gets(a);    reverse(a, 0, strlen(a)-1);    printf("%s\n",a);    return 0; } void reverse(char *x, int beg, int end) {    char a, b, c;    if ( beg >= end )       return;       c = *(x+beg);    *(x+beg)...
Read More

Code#73:C program to reverse a string using pointers

| |
0 comments
#include<stdio.h> int string_length(char*); void reverse(char*); main()  {    char string[100];    printf("Enter a string\n");    gets(string);    reverse(string);    printf("Reverse of entered string is \"%s\".\n", string);    return 0; } void reverse(char *string)  {    int length, c;    char *begin, *end, temp;  ...
Read More

Code#72:C Program To Reverse a String

| |
0 comments
Basic C Language Program  To Reverse a String is explained below with a detailed explanation,you will find it easy to go through this program, Sample input and output screen shots has been provide for the better understand ability to the user, leave a comment if you are satisfied with the code            ...
Read More

Code#71:c program to concatenate strings Without Using strcat()

| |
0 comments
#include<stdio.h> void concatenate_string(char*, char*); main() {     char original[100], add[100];     printf("Enter source string\n");     gets(original);     printf("Enter string to concatenate\n");     gets(add);     concatenate_string(original, add);     printf("String after concatenation is \"%s\"\n", original);     return 0; } void...
Read More

Code#70:c program to concatenate strings

| |
0 comments
#include<stdio.h> #include<conio.h> #include<string.h> main() {    char a[100], b[100];    printf("Enter the first string\n");    gets(a);    printf("Enter the second string\n");    gets(b);    strcat(a,b);    printf("String obtained on concatenation is %s\n",a);    getch();    return 0; } Output: Enter the first...
Read More

Code#69:c program to copy a string using pointers

| |
0 comments
#include<stdio.h> void copy_string(char*, char*); main() {     char source[100], target[100];     printf("Enter source string\n");     gets(source);     copy_string(target, source);     printf("Target string is \"%s\"\n", target);     return 0; } void copy_string(char *target, char *source) {    while(*source)    {      ...
Read More

Code#68:C program to copy a string

| |
0 comments
#include<stdio.h> #include<string.h> main() {    char source[] = "C program";    char destination[50];    strcpy(destination, source);    printf("Source string: %s\n", source);    printf("Destination string: %s\n", destination);    return 0; ...
Read More

Code#67:C program to compare two strings using pointers

| |
0 comments
#include<stdio.h> int compare_string(char*, char*); main() {     char first[100], second[100], result;     printf("Enter first string\n");     gets(first);     printf("Enter second string\n");     gets(second);     result = compare_string(first, second);     if ( result == 0 )        printf("Both strings are same.\n");  ...
Read More

Code#66:C program to compare two strings using strcmp

| |
0 comments
#include<stdio.h> #include<string.h> main() {    char a[100], b[100];    printf("Enter the first string\n");    gets(a);    printf("Enter the second string\n");    gets(b);    if( strcmp(a,b) == 0 )       printf("Entered strings are equal.\n");    else       printf("Entered strings are not equal.\n");  ...
Read More

Code# 65:C Program To Find Length of String Without Using strlen()

| |
0 comments
#include<stdio.h> main() {    char array[100], *pointer;    int length = 0;    printf("Enter a string\n");    gets(array);    pointer = array;    while(*(pointer+length))       length++;    printf("Length of entered string = %d\n",length);    return 0; ...
Read More

Code# 64:C Program To Find Length of String

| |
0 comments
#include<stdio.h> #include<string.h> 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; } Output: Enter a string to calculate it's length c programming Length of entered string is =...
Read More

Code#63:C Program To Print String

| |
0 comments
#include <stdio.h> main() {     char array[100];     printf("Enter a string\n");     scanf("%s", array);     printf("You entered the string %s\n",array);     return 0;...
Read More

Code#62:C Program To Find Transpose Of Matrix

| |
0 comments
This c program prints transpose of a matrix. It is obtained by interchanging rows and columns of a matrix. For example if a matrix is 1 2 3 4 5 6 then transpose of above matrix will be 1 3 5 2 4 6 When we transpose a matrix then the order of matrix changes, but for a square matrix order remains same. #include<stdio.h> main() {    int m, n, c, d, matrix[10][10], transpose[10][10];    printf("Enter...
Read More

Code# 61:C Program To Multiply two Matrices

| |
0 comments
#include <stdio.h> int main() {   int m, n, p, q, c, d, k, 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++ )       scanf("%d",...
Read More

Code# 60:C Program To Subtract two Matrices

| |
0 comments
#include<stdio.h> int main() {   int m, n, c, d, first[10][10], second[10][10], difference[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++)       scanf("%d", &first[c][d]);   printf("Enter the...
Read More

Code# 59:C Program To Add two Matrices

| |
0 comments
#include <stdio.h> main() {    int m, n, c, d, first[10][10], second[10][10], sum[10][10];    printf("Enter the number of rows and columns of matrix ");    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++ )          scanf("%d",...
Read More

Code#58:C Program To Implement Selection Sort

| |
0 comments
#include<stdio.h> main() {    int array[100], 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++ )    {       position = c;  ...
Read More

Code#57:C Program To Perform Insertion Sort

| |
0 comments
/* insertion sort ascending order */ #include <stdio.h> int main() {   int n, array[1000], c, d, t;   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 = 1 ; c <= n - 1; c++) {     d = c;     while ( d > 0 && array[d]...
Read More

Code# 56:C Program for Bubble sort

| |
0 comments
/* Bubble sort code */ #include <stdio.h> int main() {   int array[100], 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...
Read More

Code# 55:C Program To Merge Two Arrays

| |
0 comments
#include <stdio.h> void merge(int [], int, int [], int, int []); int main() {   int a[100], b[100], m, n, c, sorted[200];   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", &a[c]);   }   printf("Input number of elements...
Read More
Powered by Blogger.