Question

Unix and C

1) Which of the following command(s) can be used to check if the string aabbcc matches a pattern described by regex aa.* or not? (a) expr aabbcc: aa.* (b) echo aabbccegrep aa.* (c) expr match aabbcc aa.* (d) egrep aa.*< END aabbcc END 2) Which of the following is legal directives in C? (a) #include<stdio.h> (b) #include <stdio.h> (c) #include stdio.h (d) include stdio.h 3) If c is a variable of type char and i is a variable of int type, which one of the following statement is illegal? (a) c=65: (c) c-putcharO: (d) getchar(c);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to the question is given below.

Ans1. Option C is correct.

expr match "aabbcc" 'aa.*'
match function gives the number of characters in the pattern if match is found else it returns 0

Ans2. Option A is correct.
Legal directive is
#include<stdio.h>
and all other options will give error.

Ans3.Option C and Option D are illegal.
c=putchar();
putchar() function is used to write a single character at the output stream. It must have one argument.
getchar(c)
getchar() function does not contains any arguments. It is used to read from the input stream.


Ans4.Option C is correct.
c is char type.
c='A'+'6'-'2'
c=69
c is char type so, it converts it to char so, c will become 'E'


Ans5.Option C ... Single Quotes....
when echoing a string, to inhibit wildcard substitution we can use single quotes.


Ans6.Option B is correct.
To create an executable file, the command is cc -o test test.c


Ans7. Option A,B and D are correct.
The correct option to execute the c file in Home directory
A. /Home/test
B ./test
D test


Ans8.Option B (1) is correct.
Here x=16 and y=3
x>>y here x is right shifted by 3
16/2^3=16=8=2 which is not 0 so, output is 1


Ans9. Option D is correct.
None of the above.
in func() function, we just right shifting x by y and after that checking if it is a 0 or non zero number.



Ans10.Option C is correct.
Option A and B gives the same result.
0 to 9
But Option C gives 1 to 9
becasue at startin checking condition makes it increase by 1


Ans11. Option D is correct.
The commands grouped together don't share the same I/O channel.





If the answer helped please upvote it means a lot. For any query please comment.







Add a comment
Know the answer?
Add Answer to:
Unix and C 1) Which of the following command(s) can be used to check if the...
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
  • using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings...

    using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings separated by a space. The first string will consist of the following sets of characters: +, *, $, and {N} which is optional. The plus (+) character represents a single alphabetic character, the ($) character represents a number between 1-9, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many...

  • 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)...

  • Create a UNIX makefile for the following C program: //convert.c char toUpper(char c){ if(c>='a' && c<='z')...

    Create a UNIX makefile for the following C program: //convert.c char toUpper(char c){ if(c>='a' && c<='z') return c-32; return c; } //converting sentance to upper void convertSentence(char *sentence){ int i=0; while(sentence[i]!='\0'){ //convert to upper for each character sentence[i] = toUpper(sentence[i]); i++; } } //converting all sentences into uppercase void convertAll(char **sentenceList, int numOfSentences){ int i=0; while(i<numOfSentences){ //calling convertsentence function to conver uppercase convertSentence(sentenceList[i]); i++; } } sentences.c #include<stdio.h> #include<stdlib.h> #include "convert.c" int main(){ //declaring character array char **mySentences; int noOfSentences;...

  • C programming Question1 (a) Write a C program that will print out all command line arguments,...

    C programming Question1 (a) Write a C program that will print out all command line arguments, in reverse order, one per line. Prefix each line with its index. 6 marks] (b) Consider this C code snippet int a- 100 int b- 42; inte p- &a; int q-b; p qi printf ("%d %d\n" ,a,*p); When this code is executed, what numbers will it print? [2 marks] (c) Consider this C program int main(int argc,char argv) char* target- "Apple" char vord[100] printf...

  • 1.Which of the following Linux scripting commands would be used to access the single command-line parameter...

    1.Which of the following Linux scripting commands would be used to access the single command-line parameter that a user has typed on the command-line? Group of answer choices A) $0 B) $# C) $$ D) $* E) $1 2. If I type the command “update my local Internet settings” (without the quotes) at the Linux command-line, from within the running script which of the following variables would the word “Internet” be stored in, if the script gets run correctly? Group...

  • Programing In C Add Command Line Arguments (Argc and Argv) and use files to the following...

    Programing In C Add Command Line Arguments (Argc and Argv) and use files to the following program. My program is called Ultimo.exe and it is in (C:\Users\Dell\source\repos\Ultimo\Debug). The file used is a .txt file in the directory of the .exe program. The text file which is address.txt is at the same location as Ultimo.exe (C:\Users\Dell\source\repos\Ultimo\Debug). The program takes information in the address.txt file and sorts it by zip code, from smallest to largest. The program works by using input/output redirection...

  • 1. (50 pts) Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer...

    1. (50 pts) Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string ('A'<>'Z', 'B'<->'Y', 'C''X', etc). You should divide this conversion task among the n threads as evenly as possible, Print out the...

  • C programing - can you check my work? Given the following variable declarations complete the table...

    C programing - can you check my work? Given the following variable declarations complete the table below. Assume the proper header files have been included. char a, b, C; int d,e - 20. f = 16 : int *p = NULL, , **q = NULL, *r = NULL; double g, h, i; double *s = NULL , *t = NULL , *u = NULL; Expression For each expression list what the variable declaration would look like. Data Type C Declaration...

  • In the following statement: foo = 'C' + 1; Which of the following could be a...

    In the following statement: foo = 'C' + 1; Which of the following could be a valid data type for the variable foo? (More than one may be correct) 1) int 2) char 3) none of the above

  • 1. Which one of the following commands will update the PATHEXT environment variable to include it...

    chapter 11 1. Which one of the following commands will update the PATHEXT environment variable to include its original contents plus the file extension RUN? a. SET PATHEXT-YPATHEXT%; RUN b. SET PATH+.RUN c. SETX PATHEXT5%PATHEXT%.RUN d. SETX PATH %PATHEXT%,RUN display the default command used to open a spe- cific file type? a. SETX b. ASSOC c. PATHEXT d. FTYPE 3. What command-line utility is used to display the file type linked to a specific file extension a. SETX b. ASSOC...

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