Program to replace each string of one or more blanks by a single blank

Tuesday, September 6th, 2011  »  Posted By  »  Total 0 Comment

Here is the program to replace each string of one or more blanks by a single blank. #include “stdio.h” #include “conio.h” #include “string.h” void main() { char input[100],output[100],c; int i=0,j=0; clrscr(); printf(“Enter the string\n”); gets(input); for(i=0;i<strlen(input);i++) { if(input[i]==' '&&input[i+1]!=' ') output[j++]=input[i]; else if(input[i]!=' ') output[j++]=input[i]; } output[j]=''; printf("\noutput string is\n"); puts(output); getch(); } Output: Enter [...]

Program to match two given strings using function

Tuesday, September 6th, 2011  »  Posted By  »  Total 0 Comment

This is the program which makes use of function matchany(s1,s2) which returns the first location in the string s1 where any character from the string s2 occurs, or -1 if s1 contains no character from s2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [...]

Program to arrange the string in alphabetical order

Tuesday, August 30th, 2011  »  Posted By  »  Total 0 Comment

Here is the program to arrange the string in alphabetical order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #include "stdio.h" #include "conio.h" #include "string.h" void main() { char str[10],temp; int i,j; clrscr(); printf("\nEnter the string : "); scanf("%s",str); for(i=0;i<strlen(str);i++) for(j=0;j<strlen(str);j++) if(str[i]<str[j]) [...]

Program to delete n Characters from a given position in a given string using functions

Monday, August 29th, 2011  »  Posted By  »  Total 0 Comment

This C program uses function delchar to delete n characters from a given position in a given string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include "stdio.h" #include "conio.h" #include "string.h" [...]

To reverse the given string using pointer

To reverse the given string using pointer Thursday, December 4th, 2008  »  Posted By  »  Total 7 Comments

This is the program to reverse the given string and display. The program internally uses the logic of reversing the word. Logic: The approach here is to reverse the string using the pointers. Reversing the string includes the reversing the each and every words in it. After accepting a string from user, it calls a [...]

To reverse the given string

Thursday, December 4th, 2008  »  Posted By  »  Total 0 Comment

Here is the program to reverse the given string and display. The program internally uses the logic of reversing the word. Logic: Reversing the string includes the reversing the each and every words in it. After accepting a string from user, it calls a function “strev” with two string arguments, the source and destination. It [...]

To copy the contents of one string to another string using pointer

Thursday, December 4th, 2008  »  Posted By  »  Total 8 Comments

This is the simple implementation of the “Copy” function using the pointers. This program copies the content of one string to another. Logic : The program asks the user to input the string to copy and stores using the pointer str1. The inner function “stcpy” takes 2 string pointers as arguments. By keeping the length [...]

To copy the contents of one string to another string

Thursday, December 4th, 2008  »  Posted By  »  Total 1 Comment

This is the simple implementation of the “Copy” function of the computer world. This program copies the content of one string to another. Logic : The program asks the user to input the string to copy and stores this as str1. The inner function “stcpy” takes 2 strings as arguments. By keeping the length as [...]

To check whether the given string is palindrome-method 2

Thursday, December 4th, 2008  »  Posted By  »  Total 13 Comments

Here is  another program, advanced version of the previous program, to check if the entered string is a palindrome. Palindrome is a string segment, which reads same from both the directions. The same method is implemented here in the program also. Logic :  The given string is referred by two names, where one is traced [...]

To check whether the given string is palindrome-method 1

Thursday, December 4th, 2008  »  Posted By  »  Total 2 Comments

Here is  the program to check if the entered string is a palindrome or not. As we have seen in the earlier cases, Palindrome is a string segment, which reads same from both the directions. The same method is implemented here in the program also. Logic :  The given string is reversed using a method, [...]

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup