Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

create a Makefile to compile all the programs in the folder Sampleio. Add a target at the top of the Makefile to compile all the

create a Makefile to compile all the programs in the folder Sampleio.

Add a target at the top of the Makefile to compile all the programs when you type make, The target would be named all.

Run make to compile all the programs.

Run at least 4 of the programs.

Paste a copy of the code you ran showing the programs running into a Word or pdf document

Look at the Unix cheat sheet

Note how to use the man pages to get the options available. Options have a minus sign in front of them. Redirection is used to change the location for the input or output from a command. The following redirections commands >, >>

Try out these commands

man

ls (try a few different options)

cd

mv

rm

touch

cat (with and without redirection to a file ie: "cat filename > outputfilename")

Choose 2 other commands from the list

These are all commands you should be very familiar with to work with Unix.

The programs were in a Filecalled SAMPLEIO:

SWAPINT

/* * C Program to Illustrate Pass by Value. */ #include void swap(int a, int b) { int temp; temp = a; a = b; b = temp; } int main() { int num1 = 10, num2 = 20; printf("Before swapping num1 = %d num2 = %d ", num1, num2); swap(num1, num2); printf("After swapping num1 = %d num2 = %d ", num2, num1); return 0; }

SUMFIFTY

/* * C program to find the sum of first 50 natural numbers * using for loop */ #include void main() { int num, sum = 0; for (num = 1; num

PRINTFLOATS

#include int main() {

int integer = 9876; float decimal = 987.6543;

// Prints the number right justified within 6 columns printf("4 digit integer right justified to 6 column: %6d ", integer);

// Tries to print number right justified to 3 digits but the number is not right adjusted because there are only 4 numbers printf("4 digit integer right justified to 3 column: %3d ", integer);

// Rounds to two digit places printf("Floating point number rounded to 2 digits: %.2f ",decimal);

// Rounds to 0 digit places printf("Floating point number rounded to 0 digits: %.f ",987.6543);

// Prints the number in exponential notation(scientific notation) printf("Floating point number in exponential form: %e ",987.6543); return 0; }

PrintFLOAT

#include int main() { float f; printf("Enter a number: "); // %f format string is used in case of floats scanf("%f",&f); printf("Value = %f", f); return 0; }

PRINTCHAR

#include int main() { char chr; printf("Enter a character: "); scanf("%c",&chr); printf("You entered %c.",chr); return 0; }

PrintASCII

#include int main() { char chr; printf("Enter a character: "); scanf("%c",&chr);

// When %c text format is used, character is displayed in case of character types printf("You entered %c. ",chr);

// When %d text format is used, integer is displayed in case of character types printf("ASCII value of %c is %d.", chr, chr); return 0; }

CountVOWELS

#include int main() { char chr; printf("Enter a character: "); scanf("%c",&chr);

// When %c text format is used, character is displayed in case of character types printf("You entered %c. ",chr);

// When %d text format is used, integer is displayed in case of character types printf("ASCII value of %c is %d.", chr, chr); return 0; }

UNIX CHEAT SHEET

image text in transcribed

Unix/Linux Command Reference F0SSwire

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions