Search Header Logo

lab 1

Authored by Priyanka S Shivaramaiah

Professional Development

University

Used 11+ times

 lab 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of argc in the main function's argument list in a command-line arguments program?

It stores the total number of command-line arguments passed to the program.

It points to the first argument passed to the program.

It stores the program's executable name.

It holds the value of the first argument passed to the program.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements correctly describes argv in the main() function?

argv is an integer variable that stores the number of command-line arguments.

argv is a pointer to an array of strings (character pointers) that hold the command-line arguments.

argv is a function that retrieves command-line arguments from the user.

argv is a single string that holds all the command-line arguments concatenated.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does argv[0] typically contain in a C program that uses command-line arguments?

The first argument passed by the user.

The total number of command-line arguments.

The name or path of the executable program.

The last argument passed by the user.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following command: ./myProgram arg1 arg2 What would be the value of argc?

1

2

3

4

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following correctly accesses the second command-line argument passed to a C program?

argv[0]

argv[1]

argv[2]

argv[argc - 1]

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you convert a string passed as a command-line argument to an integer in C?

Use the strcat() function.

Use the atoi() function.

Use the strlen() function.

Use the strcpy() function.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If a C program is executed with the following command: ./myProgram 10 20 What is the correct way to access the value "20" in the program?

argv[0]

argv[1]

argv[2]

argv[3]

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?