Question

In: Computer Science

IN C LANGUAGE ONLY PLEASE! First Program: create branchloop.c file Content of the program Enter your...

IN C LANGUAGE ONLY PLEASE!

First Program:

  1. create branchloop.c file
  2. Content of the program
    1. Enter your name while running your program as you did with hello2.c (using argc and argv) name has to be 2 words max (e.g. Jose Lopez, Maria Rodrigues) . Make sure to check properly.
    2. Print your name 10 times using a loop. 10 is a fixed number.
    3. Count how many characters are in your first name and last name.
    4. If the number of characters of your first name is greater than last name print my first name is bigger than my last name.
    5. If the number of characters of your first name is less than last name then print my last name is bigger than my first name.
    6. If the number of characters is equal then print my first and last name have the same number of characters.
  3. Compile the program using: gcc -o branchloop branchloop.c
  4. Run the program using: ./branchloop firstname lastname

Second Program:

  1. Copy branchloop.c to branchloop2.c
  2. Restructure program to add the following functionality
  3. Enter a number at command line representing an index to your name along with your name. e.g. ./branchloop2 carlos alonso 5
  4. The index number must be within the size of your full name - if is not an error should be provided (number is larger than your full name).
  5. If the number fits the length of your name, use the number to find the letter correspond to it by indexing.
  6. Finally print your name in all lower case, print index number, and print character indexed in upper case.

Third program:

  1. Copy branchloop2.c to branchloop3.c
  2. Use the number entered in command line to:
    1. Print your name that many times
    2. Use a Do-While loop
  3. Count the number of letters in your name.
  4. Print the number of characters in your name followed by your name backwards.

Solutions

Expert Solution

First Program -

Code -

#include <stdio.h>

int main( int argc, char *argv[] ) {
//print name 10 time using for loop
for(int i = 0 ; i < 10; i++)
//argv[1] is first name and argv[2] is last name
printf("%s %s\n", argv[1],argv[2]);

//count character in first name   
int firstNameCharCount = 0;
//using for loop iterate till argv[1][i] not equal to '\0'
for (int i = 0; argv[1][i] != '\0'; ++i)
//incremenet firstNameCharCount
firstNameCharCount++;
//similarly count char in second name
int secondNameCharCount = 0;
for (int i = 0; argv[2][i] != '\0'; ++i)
secondNameCharCount++;
  
//compare character count , if firstNameCharCount is greater than secondNameCharCount
//then print my first name is bigger than my last name
if(firstNameCharCount>secondNameCharCount){
printf("my first name is bigger than my last name");
}
//compare character count , if secondNameCharCount is greater than firstNameCharCount
//then print my last name is bigger than my first name
else if(firstNameCharCount<secondNameCharCount){
printf("my last name is bigger than my first name");
}
//if both are equal
else if(firstNameCharCount==secondNameCharCount){
printf("my first and last name have the same number of characters.");
}
  
  

}

Screenshots -

pls ask multiple question in different part , we are told to answer first only in case of multiple question , pls do give a like ,thank you


Related Solutions

Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching...
Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching pairs of vehicle models and their respective makes Separate out the individual make and model on each line of the file Add the vehicle make to one list, and the vehicle model to another list; such that they are in the same relative position in each list Prompt the user to enter a vehicle model Search the list containing the vehicle models for a...
c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
C Programming Language: For this lab, you are going to create two programs. The first program...
C Programming Language: For this lab, you are going to create two programs. The first program (named AsciiToBinary) will read data from an ASCII file and save the data to a new file in a binary format. The second program (named BinaryToAscii) will read data from a binary file and save the data to a new file in ASCII format. Specifications: Both programs will obtain the filenames to be read and written from command line parameters. For example: - bash$...
Create a Java program that asks a user to enter two file names. The program will...
Create a Java program that asks a user to enter two file names. The program will read in two files and do a matrix multiplication. Check to make sure the files exist. first input is the name of the first file and it has 2 (length) 4 5 6 7 Second input is the name of the second file and it has 2 (length) 6 7 8 9 try catch method
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
Please answer the problem below in C programming language: Create a pointer activity source file -...
Please answer the problem below in C programming language: Create a pointer activity source file - cptr2.c - that takes two arguments, a number from 1 to 3, and a string sentence(s). Create variables for a character, an integer, a string pointer. Based on integer value you will use that number of string pointers. The string variable is a string pointer that has not been allocated.    Define pointers to those variables types without any initialization of those points to the...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Write a C Program that uses file handling operations of C language. The Program should perform...
Write a C Program that uses file handling operations of C language. The Program should perform following operations: 1. The program should accept student names and students’ assignment marks from the user. 2. Values accepted from the user should get saved in a .csv file (.csv files are “comma separated value” files, that can be opened with spreadsheet applications like MS-Excel and also with a normal text editor like Notepad). You should be able to open and view this file...
Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language...
Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language A Game store sells many types of gaming consoles. The console brands are Xbox, Nintendo, PlayStation. A console can have either 16 or 8 gigabytes of memory. Use can choose the shipping method as either Regular (Cost it $5) or Expedite (Cost is $10) The price list is given as follows: Memory size/Brand Xbox Nintendo PlayStation 16 gigabytes 499.99 469.99 409.99 8 gigabytes 419.99...
this program is to be done in c language. Using Pointers Create a program pointerTester.c to...
this program is to be done in c language. Using Pointers Create a program pointerTester.c to experiment with pointers. Implement the following steps one by one in your program: YOU NEED TO ANSWER QUESTION Use printf to print your answers at the end(after 12). 1. Declare three integer variables a, b and c. Initialize them to 0, 100 and 225, respectively. 2. Print the value of each variable and its address. 3. Add the following declaration to your code: int...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT