Question

Experiment with the terminal and C programming   I want you to be able to setup a...

  1. Experiment with the terminal and C programming   I want you to be able to setup a folder, change to a folder, create a new file with the editor (windows version is fine), rename files, delete files, and change permissions.
  2. How to create a compiled program
  • Create your source code; lets say it is named test.c
  • Compile it using: gcc test.c –o test
  • Change the permissions to execute for everyone (755)
  • Run it by: ./test
  1. Create two programs
  • The first one that will print “Hello World.”
  • The second one will take two command line arguments (numbers), then will add them and print the result (Hint: Google “gcc how to pass numeric command line arguments into your c program” and you have to use “atoi.”) You should run it something like./test 3 4 and it should print: 7 (assuming your test is your compiled program)
  • Create a shell script that will run both of these compiled programs
0 0
Add a comment Improve this question Transcribed image text
Answer #1

test1.c
*********

#include <stdio.h>

int main()
{
printf("Hello world\n");
return 0;
}

test2.c
*********

#include <stdio.h>

int main(int argc, char *argv[])
{
   int a,b,sum;
   if(argc!=3)
   {
       printf("please use \"prg_name value1 value2 \"\n");
       return -1;
   }
  
   a = atoi(argv[1]);
   b = atoi(argv[2]);
   sum = a+b;
  
   printf("Sum of %d, %d is: %d\n",a,b,sum);
  
   return 0;
}

Run.sh
*********

./test1
./test2 10 20

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
Experiment with the terminal and C programming   I want you to be able to setup a...
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
  • Could you help me do the commands from nmber 16 to 21 For this assignment, you...

    Could you help me do the commands from nmber 16 to 21 For this assignment, you will: Unpack a tar archive. Change the unpacked files. Repack the files into a new tar archive. Turn in your new tar archive. Details Do not use an editor unless it specifically states to edit the file. By "editor" I mean vim, gedit, pico, etc. Despite its name, we don't consider sed to be an editor in this assignment, so you may use it...

  • You will write a C program, q1 sequence.c, that computes the value of the nth term...

    You will write a C program, q1 sequence.c, that computes the value of the nth term in any recursive sequence with the following structure: an = c1 · an−1 + c2 · an−2 a0 > 0 a1 > 0 c1 6= 0 c2 6= 0 Your C program will take 5 integer arguments on the command line: n, a0, a1, c1 and c2. n must be an integer greater than or equal to 0. If more or fewer arguments are...

  • CSIT 345 Lab 2 Process Programming Your lab requirement is to write program codes for 3.21 and sh...

    *Help Please with the code** CSIT 345 Lab 2 Process Programming Your lab requirement is to write program codes for 3.21 and shared memory program for producer and consumer as shown in the following. You can start with the code provided in the virtual machine in the virtual box you installed. The code can be found in /home/oscreader/osc9e-src/ch3 a. For 3.21, you can start with the newprocposix.c and modify the code to meet your requirement. Then type: gcc neypCOCROSİS.c to...

  • OPERATING SYSTEM... C , LINUX Modify the mycat.c program to write to stderr the number of...

    OPERATING SYSTEM... C , LINUX Modify the mycat.c program to write to stderr the number of bytes that were read from stdin each time. You may use cLion inside VM, or any other text editor of your choice, such as vi or emacs. There is also a neat text editor named Kate available in Ubuntu (you can find it in the menu). In cLion you can open a single.cfile without having to create a whole new project and modify the...

  • Using Unix/Linux Command line in terminal and C programming. (b) Write a basic C program contained...

    Using Unix/Linux Command line in terminal and C programming. (b) Write a basic C program contained in a1q4.c and perform the following tasks in your program’s main() function: (8 marks) • Declare and initialize at least one variable of these types: char, int, unsigned int, float, double and long double. When initializing your variables, ensure the constants you use are of the same type as your variable. See the “Constants” section of Topic 7 for more information. • Use printf(3)...

  • (In Linux) 1. Create a file to write to from your script and save it as...

    (In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...

  • 3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your...

    3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your implementation must use C/C++ and your code must run on the Linux machine general.asu.edu. Please refer to the programming guide (available under the Assignments folder on Blackboard) for using the general.asu.edu server, as well as compiling and running C/C++ code under Linux For this question, you need to provide a Makefile that compiles your program to an executable named a3 that runs on the...

  • Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and...

    Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and circle.h             2) Create a new directory to store the files in             3) Compile the code a) Run the command g++ driver.cpp -o executable_name, this will compile the code both for driver.cpp and the referenced file circle.h note: -o parameter specifies a new name for the executable, if you do not specify the “-o” parameter the default name of the executable is “a.out”...

  • Tokeniser in C++

    TokenisersBackgroundThe primary task of any language translator is to work out how the structure and meaning of an input in a given language so that an appropriate translation can be output in another language. If you think of this in terms of a natural language such as English. When you attempt to read a sentence you do not spend your time worrying about what characters there are, how much space is between the letters or where lines are broken. What...

  • Boot into your Linux partition (or open Linux in a VirtualBox VM). You will create a...

    Boot into your Linux partition (or open Linux in a VirtualBox VM). You will create a new directory in your home directory called csci2020u/lab02. We’ll add this folder to the Git repositories. Use the following steps to complete this lab: 1. Change into the csci2020u directory 2. Make a new directory, called lab02 3. Add the lab02 directory to Git 4. In the lab02 directory, create the directory structure used by Gradle (the files will be initially empty, you can...

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