//program1
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
int main()
{
//Declare Variables
char array[10][30]; //2D array for storing
strings
int i, n;
//Get the maximum number of strings
printf("Enter number of words to
input(<=10)\n");
scanf("%d", &n);
if(n>10){
printf("invalid ");
exit(0);
}
//Read the user input words
printf("Enter the words one by one: \n");
for(i=0; i< n ; i++) {
scanf("%s",array[i]);
}
printf("\n");
for(i=0; i< n ; i++) {
printf("%s\n",array[i]);
}
printf("\n");
for(i=0; i<n ; i=i+2) {
//Concatenation function for two
words
strcat(array[i],array[i+1]);
}
for(i=0; i< n ; i=i+2) {
//printing the word at index
i
printf("%s\n",array[i]);
}
printf("\n");
printf("Enter the words again from the above one by
one: \n");
for(i=0; i< n ; i++) {
scanf("%s",array[i]);
}
printf("\n");
for(i=0; i<n ; i=i+3) {
//Technique to concatenate three
words
strcat(array[i],array[i+1]);
strcat(array[i],array[i+2]);
}
for(i=0; i< n ; i=i+3) {
printf("%s\n",array[i]);
}
//Return to the system
return 0;
}
//program 2
#include <stdio.h>
#include <string.h>
int main()
{
char array[10][8], tarray[10][8], temp[8];
int i, j, n;
printf("Enter the number of words n(<=5) \n");
scanf("%d", &n);
printf("Enter %d names\n", n);
for (i = 0; i < n; i++)
{
scanf("%s", array[i]);
strcpy(tarray[i], array[i]);
}
//using a temporary character array to sort the words
for (i = 0; i < n - 1 ; i++)
{
for (j = i + 1; j < n; j++)
{
if (strcmp(array[i], array[j]) > 0)
{
strcpy(temp, array[i]);
strcpy(array[i], array[j]);
strcpy(array[j], temp);
}
}
}
printf("\n");
printf("Sorted names are:\n");
//printing the words in sorted order
for (i = 0; i < n; i++)
{
printf("%s\n",array[i]);
}
return 0;
}
//OUTPUT FOR PROGRAM1
in c Lab Assighment-String Manipulation 1. Create an array of characters to hold a list of 10 words Read the words f...
Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names, and read in course names from an input file. Then do the output to show each course name that was read in. See Chapter 8 section on "C-Strings", and the section "Arrays of Strings and C-strings", which gives an example related to this lab. Declare the array for course names as a 2-D char array: char courseNames[10] [ 50]; -each row will be a...
In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...
Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...