C programing
1. You coded a set of statistics functions in a file called
stats.c. The header file stats.h contains the prototypes of the
functions.
Which of the following commands will produce an object file
a. gcc stats.c b. gcc –c stats.c c. gcc –g stats.c d. gcc –o
stats.c e. gcc –o stats.c stats.h
2. The program printMain prints the following “This is a test!!”.
Given the following code, how many times is the sentence “This is a
test!!” printed?
#include “stdio.h” #include “uinstd.h”
int main() { int cpid = 0; char *args[2]={“printMain”, NULL};
cpid = fork(); execv(“,/printMain”, args); cpid = fork();
execv(“./printMain”, args); sleep(10); return(0); }
a. 1 b. 2 c. 3 d. 4 e. none of the above
Answer 1: commands to produce an object file
option b) gcc –c stats.c
The -c option allows to generate the object file.
C programing 1. You coded a set of statistics functions in a file called stats.c. The...
Assignment 1 In this assignment you will be writing a tool to help you play the word puzzle game AlphaBear. In the game, certain letters must be used at each round or else they will turn into rocks! Therefore, we want to create a tool that you can provide with a list of letters you MUST use and a list of available letters and the program returns a list of all the words that contain required letters and only contain...
General Requirements . . . Write a program that reads letters from a file called "letters.txt". Your program will open the letters.txt file read in one character at a time For this assignment the test file will contain at least 30 letters, uppercase OR lowercase In your program you will change each letter (solution) to uppercase Use the function toupper in #include <ctype.h> You create a numerical version of the uppercase letter from the file . o Use int numberSolution...
USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is one of the simplest encryption techniques in the field of cryptography. It is a cipher in which each letter in a plain text message is replaced by a letter some fixed number of positions up the alphabet (i.e., by right shifting the alphabetic characters in the plain text message). For example, with a right shift of 2, ’A’ is replaced by ’C’, ’B’ is...
Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions. int letter_count(char *s) computes and returns the number of English letters in string s. int word_count(char *s) computes and returns the number of words in string s. void lower_case(char *s) changes upper case to lower case of string s. void trim(char *s) removes the unnecessary empty spaces of string s. mystring.h #include <stdio.h> int letter_count(char *); void lower_case(char *); int word_count(char *); void trim(char...
Programs 1. String Utilities In this exercise you will implement several utility functions involving strings. You will place all of your function prototypes in a header file named string utils.h and all of your function definitions in a source file named string utils.c. You should implement your own main test driver program to test your functions, but you need not hand it in. a. void addChar(char *str, char c, int n) - this function should add a char c at...
Has
to be in Unix!
Lab 7 Programs 1. Create a prints.c file, and copy the following into it: #include <stdio.h> int main(int argc, char * argv[]) { double x = 1.0, y = 5.1e7; float pi = 3.14159f; int i=0, j=5115; short int m= 6; unsigned long int n = 51151151; return 0; Now, write printf commands to: • print x with a field width of 6; print y with a field width of 8 and a precision of...
Topics: Arrays in C. For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it. Requirements: Your program must compile and run correctly using the gcc compiler on ale. You must write the corresponding function definitions for the following function prototypes: // set all elements of the histogram to zero void init_histogram(int histo[]); // construct the histogram from string void cons_histogram(char string[], int...
Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...
Using the program segment below, write two short functions to complete the program. Use the test cases to ensure the program works properly. Prototypes: void int2bin(int, int[8]); The first function will convert an integer that is between 0 - 255 to its binary representation. You are to store the binary number in the array passed to the function. void printBinary(int[8]); The second function will print the binary number stored in the array passed to the function. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Test 1: 13...
programing in c language
Write a program, using the following functions, that reads two
polynomials and prints the polynomials before and after the
addition.
a) polyRead
- Read in a polynomial and convert it to its linked list
representation. - Return a pointer to the header node of this
polynomial.
b) polyWrite
- Output a polynomial using a form that clearly displays
it.
c) polyAdd
- Compute c = a + b. Do not change either a or b.
where,...