• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Program Based On String
1. write a program to find out the length of a given string. Then displaythe same string with its length.
#include<stdio.h>#include<conio.h>#include<string.h>void main(){char str[25];int i=0,len=0;clrscr();printf("Enter Any String : ");scanf("%[^\n]s",&str);while(str[i]!='\0'){i++;len++;}clrscr();printf("Entered String : %s.",str);printf("\nLength Of String : %d.",len);getch();}
Path :- F:\MCA I Sem\FOP\Final\String - 1 - Roll No :- 04MCA54
 
Program Based On String
2.
 
Write a program to accomplish the followings:-Read any two string. Say sti and st2.-Compare sti and st2 and display the corresponding messageaccording to the following criteria:If (sti =st2) thendisplay “Both strings are equal”elsedisplay “Both strings are not equal”
 
#include<stdio.h>#include<conio.h>#include<string.h>void main(){char str1[25],str2[25];int i=0,flag;clrscr();printf("Enter String-1 : ");scanf("%[^\n]s",&str1);printf("Enter String-2 : ");scanf("%[^\n]s",&str2);while(str1[i]!='\0'){if(str1[i]==str2[i]){flag=1;}else{flag=0;}i++;}if(flag==0){printf("Both Strings Are Equal.");}else{printf("Both Strings Are Not Equal.");}getch();}
Path :- F:\MCA I Sem\FOP\Final\String - 2 - Roll No :- 04MCA54
 
Program Based On String
3. Write a program to copy one string to another and count the number of character copied.
#include<stdio.h>#include<conio.h>#include<stdlib.h>void main(){char strsrc[20],strdest[20];int i=0;clrscr();printf("Enter String To Be Copied : ");scanf("%s",strsrc);while(strsrc[i]!='\0'){strdest[i]=strsrc[i];i++;}printf("Copied String Is : %s.",strdest);printf("\nLength Of String : %d",i);getch();}
Path :- F:\MCA I Sem\FOP\Final\String - 3 - Roll No :- 04MCA54
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...