Input : Please enter the first string
Alamin
Please enter the second string
Chowdhury
Output : Alamin Chowdhury
Used While loop
Alamin
Please enter the second string
Chowdhury
Output : Alamin Chowdhury
Used While loop
- #include <stdio.h>
- void main()
- {
- char str1[100];
- char str2[100];
- char str3[100];
- int i=0, j=0, k=0;
- printf("Please enter the first string\n");
- //gets(str1);
- scanf("%s", str1);
- printf("Please enter the second string\n");
- //gets(str2);
- scanf("%s", str2);
- while(str1[i] != '\0'){
- str3[k]=str1[i];
- i++;
- k++;
- }
- str3[k]=' ';
- k++;
- while(str2[j] != '\0'){
- str3[k]=str2[j];
- j++;
- k++;
- }
- str3[k]='\0';
- printf("%s\n", str3);
- }
Used for loop
- #include <stdio.h>
- void main()
- {
- char str1[100];
- char str2[100];
- char str3[100];
- int i=0, j=0, k=0;
- printf("Please enter the first string\n");
- //gets(str1);
- scanf("%s", str1);
- printf("Please enter the second string\n");
- //gets(str2);
- scanf("%s", str2);
- for(str1[i] != '\0'; str3[k]=str1[i]; i++){
- //str3[k]=str1[i];
- //i++;
- k++;
- }
- str3[k]=' ';
- k++;
- for(str2[j] != '\0'; str3[k]=str2[j]; j++){
- //str3[k]=str2[j];
- //j++;
- k++;
- }
- str3[k]='\0';
- printf("%s\n", str3);
- }
একটি মন্তব্য পোস্ট করুন