Question

I am trying to write a short program in C that prints the letters that are...

I am trying to write a short program in C that prints the letters that are the same in two different arrays. I am getting a error.

#include <stdio.h>

int main()
{
  
       char first[7]={'y','a','s','m','i','n','e'};
       char last[5]={'s','m','i','t','h'};
       int i;
     
     
   
       while(first[i] != '\0') && (last[i] != '\0')
       {
           if(first[i]==last[i])
                printf("%s", first[i]);
         
       }
   
    return 0;
        
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
I am trying to write a short program in C that prints the letters that are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • -I need to write a program in C to store a list of names (the last...

    -I need to write a program in C to store a list of names (the last name first) and age in parallel arrays , and then later to sort them into alphabetical order, keeping the age with the correct names. - Could you please fix this program for me! #include <stdio.h> #include <stdlib.h> #include <string.h> void data_sort(char name[100],int age[100],int size){     int i = 0;     while (i < size){         int j = i+1;         while (j < size){...

  • P1) Write a complete C program that prints out the word YES, if its string command...

    P1) Write a complete C program that prints out the word YES, if its string command line argument contains the sequence the somewhere in it. It prints out the word NO otherwise. Both the word the and partial sequences like in the words theatre or brother qualify. Note: You can use string functions or not but if you do the only ones allowed are strcpy and strlen. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P2) What is the output of the following program (one answer per...

  • I need the programming to be in language C. I am using a program called Zybook...

    I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }

  • Write a complete C program that inputs a paragraph of text and prints out each unique...

    Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...

  • I'm having trouble getting my program to output this statement Enter a sentence: Test! There are...

    I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters. Here's my code: #include<string.h> #include<stdio.h> #include<stdbool.h> int main() { char str[100]; int i; int vowels=0; int UC; int LC; int Others; int c; printf("Enter a sentence: \n"); gets(s); LC=countLC(&s); UC=countUC(&s); Others=countOthers(&s); printf("There are %d total characters.\n", ; for(i=0; i<strlen(str); i++){ if(isVowel(str[i])) vowels++;...

  • Please I need help in C language, I am trying to modify the code per the...

    Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions:                  1.      First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....

  • what is the output of the following program? #include<stdio.h> #include<string.h> int main(void){ char word[20]; int i...

    what is the output of the following program? #include<stdio.h> #include<string.h> int main(void){ char word[20]; int i =0    strcpy(word, "ORGANISE"); while(word[i] !='\0'){ if(i%2 ==1) word[i] = 'C'; i++; } printf("%s",word); return 0; }

  • ^^^ Q3. I am trying to implement double linked list but I was failed to write...

    ^^^ Q3. I am trying to implement double linked list but I was failed to write the code so anyone gives the main Code in the main function   THANK YOU FOR ADVANCE #include<stdio.h> #include<stdlib.h> #include<alloc.h> struct node {      int info;      struct node *lptr,*rptr; }; typedef struct node DL; DL *delete( ) , *insert ( ); void display(); DL *delete(DL *start,int x) {      DL *left,*right,*curr;      curr = start;      if( start == NULL)       {                 printf("\nDoubly...

  • Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char...

    Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }

  • Trying to debug a C program given to me. This is what I was given... //...

    Trying to debug a C program given to me. This is what I was given... // Program to read numeric elements (including decimals) into a 3X3 matrix and display them #include<stdio.h> int main(void) {    int size = 3, Matrix[size][size];    printf("Enter 9 elements of the matrix:\n") for (int i = 0, i <=size, i++}        for (int j = 0, j <= size, i++)            scan("%c", Matrix1[2][2]);    diplay(Matrix) float display(int Matrix1[][], int size) (   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT