Question

I need help please... Intro to Programming in C – small program 8 Project objective: To...

I need help please...

Intro to Programming in C – small program 8
Project objective: To compile, build, and execute an interactive program using character arrays and string.h functions
**Submit source code (prog8.c) through Canvas
• One source code file (unformatted text) will be submitted
• The file name must match the assignment
• The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas
• The code must be submitted on time in order to receive credit (11:59 PM on the due date)
• Late submissions will not be accepted or graded
• All programming assignments are individual work, sharing code is considered cheating
Write a small program that continues to concatenate words together until the user decides to quit.
- Declare 4-character arrays
- Declare a character for the q to quit
1. Greet the user
2. use strcpy to initialize the character arrays to "" (empty string/ no space)
3. Ask and get 2 words from the user (use a function for this)
4. use strcpy to create copies of the words
5. Combine 2 of the words into one word by using strcat
6. Combine the same 2 words into one word (in the other order) by using strcat (use the copied words)
7. print the 2 new words onto the screen
8. ask the user if they want to enter another 2 words (Q to quit ) if y loop back to number 2
9. say goodbye to the user SAMPLE OUTPUT: Welcome, you will enter two words and they will be joined together to form 2 different new words
Enter a word: skate Enter a word: board The new words are skateboard and boardskate
Would you like to enter 2 new words (Q to quit, anything else to continue) y
Enter a word: up Enter a word: town The new words are uptown and townup
Would you like to enter 2 new words (Q to quit, anything else to continue) q
Goodbye!
Press any key to continue . . .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program plan:As per question the user need to enter n=two words and the program concatenates them and display the as one word.In c we have a header file called string.h which has all the methods to work with strings.

strcpy(str1,str2): it is a method defined in string.h used to copy the str2 to str1.

strcat(str1,str2): it a method used to cancatenate two strings.str2 is added at the end of str1.

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[100],s2[100],t1[100],t2[100],q;
q='y';
clrscr();
while(q=='y')
{
strcpy(s1,"");
strcpy(s2,"");
printf("Welcome, enter two strings and they will be join together to form two differnt words\n");
printf("Enter a word:");
scanf("%s",&s1);
printf("\nEnter aword:");
scanf("%s",&s2);
//copy the strings to the temporary variables
strcpy(t1,s1);
strcpy(t2,s2);
//concatinating the strings and print the values
strcat(s1,s2);
strcat(t2,t1);
printf("\nThe new words are %s and %s",s1,t2);
printf("do you want to continue(y to continue and Q to skip");
scanf("%c",&q);
}
printf("Good bye");
return 0;
}

Add a comment
Know the answer?
Add Answer to:
I need help please... Intro to Programming in C – small program 8 Project objective: To...
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
  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To...

    Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...

  • In C Programming Write a program named CompareStrings. You will need two char arrays, name them...

    In C Programming Write a program named CompareStrings. You will need two char arrays, name them one and two, and have enough room for single words. Ask the user to enter two words (lower case), compare the words, and say if the first word is before or after the second word in lexigraphical order.

  • hey dear i just need help with update my code i have the hangman program i...

    hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...

  • Hi, this is an intro to C Programming Class. Please do not use arrays, functions, math.h,...

    Hi, this is an intro to C Programming Class. Please do not use arrays, functions, math.h, or struct to store any data except to declare strings char strVar[20]. Furthermore, can you please do a good check to make sure the final program does not have any problems because when I copy and paste them the app I use says there are some problems and it won't run the program. So if you can double check to make sure that everything...

  • The language is C++. Code needs to be added to line 28 and 37. Could someone...

    The language is C++. Code needs to be added to line 28 and 37. Could someone provide some help with how to do it? CODE Write a program to unscramble words A file with list of words is provided along with a template program to get you started. 1. Define a struct with 2 string members: sorted and original 2. Declare an array of 200000 elements with data type of the struct 3. Read from a file a list of...

  • Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an...

    Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an email address, and reports to the user whether or not the email address is valid. For the purposes of this assignment, we will consider a valid email address to be one that contains an @ symbol The program must allow the user to input as many email addresses as desired until the user enters "q" to quit. For each email entered, the program should...

  • need help please! thanks!! C++ programming Your program should do the following Prompt the user for...

    need help please! thanks!! C++ programming Your program should do the following Prompt the user for the first number (int data type) Read the first number Prompt the user for the second number (int data type) Read the second number Write code to calculate the quotient and remainder when the first number is divided by the second number Make sure to used variables in your output statements. /* OUTPUT Enter the first number: 126 Enter the second number: 31 126...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Please, I need help with program c++. This is a chutes and ladders program. The code...

    Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of the problem statement. Thank you very much. Assignment Overview This program will implement a variation of the game “chutes and ladders” or “snakes and ladders:” https://en.wikipedia.org/wiki/Snakes_and_Ladders#Gameplay. Just like in the original game, landing on certain squares will jump the player ahead or behind. In this case, you are trying to reach to bottom of the...

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