Search Results for: label/String

C program to concatenate two strings without using strcat() function

#include<stdio.h> #include<conio.h> void main() { char s1[30],s2[30],s3[60]; int i,j; clrscr(); printf(“Enter first string:”); gets(s1); printf(“Enter second string:”); gets(s2); for(i=0;s1[i]!=’’;++i) s3[i]=s1[i]; for(j=0;s2[j]!=’’;++j) s3[i+j]=s2[j]; s3[i+j]=’’; printf(“nThe concatenated string is: %s”,s3); getch(); }

C program to read a string and print it in alphabetical order

#include<stdio.h> #include<conio.h> #include<string.h> void main() { int i,j,n,ch1,ch2; char a[50],temp; clrscr(); printf(“Enter any string:”); scanf(“%s”,a); n=strlen(a); for(i=1;i<n;++i) for(j=0;j<(n-i);++j) { ch1=a[j]; ch2=a[j+1]; if(ch1>ch2) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } printf(“String after arranging %s”,a); getch(); }