top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a C code for the logic - input: string, strong output: strng

0 votes
289 views

Write a C code for the logic -
input: string, strong
output: strng

posted May 6, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
#include<stdio.h>
#include<string.h>
int min(int a,int b)
{
        if(a<b)
                return a;
        else
                return b;
}
main()
{
        char str1[50],str2[50];
        printf("Enter string 1 \n");
        scanf("%s",str1);
        printf("Enter string 2 \n");
        scanf("%s",str2);
        int length = min(strlen(str1),strlen(str2));
        char str3[length+1];
        int i=0,j=0;
        for(;i<length;i++)
        {
                if(str1[i]==str2[i])
                        str3[j++]=str1[i];
        }
        str3[j]='\0';
        printf("%s\n",str3);
}
answer May 8, 2017 by Chirag Gangdev
Similar Questions
+3 votes

Implement a code that counts the occurrences of each word in an input file and write the word along with corresponding count in an output file sorted by the words alphabetically.

Sample Input

Gaurav is  a Good Boy
Sita is a Good Girl
Tommy is  a Good Dog
Ram is a Good person

Sample Output

D:\>Java FileWordCount inputFile.txt outputFile.txt
    Boy : 1
    Dog : 1
    Gaurav : 1
    Girl : 1
    Good : 4
    Ram : 1
    Sita : 1
    Tommy : 1
    a : 4
    is : 4
    person : 1
+1 vote

Write your own rand function which returns random numbers in a given range(input) so that the numbers in the given range is equally likely to appear.

+2 votes

Hello friends I am searching the Program to print source code as program output in C programming

...