Command Line Arguments in C Programming, Summaries of Computer science

A comprehensive guide on command line arguments in c programming. It covers the concept, instructional objectives, learning outcomes, syntax, sample codes, program execution, and references for further learning. The session aims to help students understand how to pass input parameters to a c program at runtime, customize the behavior of a c program, and facilitate testing and debugging.

Typology: Summaries

2023/2024

Uploaded on 02/21/2024

praneeth-kothagundhu
praneeth-kothagundhu 🇮🇳

2 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CREATED BY K. VICTOR BABU
COMPUTATIONAL THINKING FOR
STRUCTURED DESIGN
Topic:
COMMAND LINE ARGUMENTS
Mrs.U.Harita
Asst Professor
Department of BES-1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Command Line Arguments in C Programming and more Summaries Computer science in PDF only on Docsity!

COMPUTATIONAL THINKING FOR

STRUCTURED DESIGN

Topic:

COMMAND LINE ARGUMENTS

Mrs.U.Harita

Asst Professor

Department of BES-

AIM OF THE SESSION To Understand the concept of Command Line Arguments INSTRUCTIONAL OBJECTIVES This Session is designed to:

  1. To customize the behavior of a C program by passing input parameters at runtime.
  2. Facilitate the testing and debugging of C programs by allowing developers to specify input parameters easily and repeatedly during the development process. LEARNING OUTCOMES At the end of this session, you should be able to: 1.Understanding how to pass input parameters to a C program at runtime. 2.Familiarize with the main function's argc and argv arguments, and its usage.

INTRODUCTION

  • (^) These are parameters passed to a program at runtime through the command line.
  • They enable programs to handle a wide range of input data and configuration parameters without requiring prompts or input dialogs.
  • This makes C programs more flexible and versatile, allowing them to perform different tasks and operations based on user input. KELF CTSD BES-

Session Description

  • (^) It reduces the need for manual input and enabling users to perform tasks quickly and easily.
  • (^) They also make it easier to test and debug programs by providing a way to automate the input data and configuration parameters used during testing.
  • (^) They are useful when we want to control our program from outside rather than hard coding the values inside the program. KELF CTSD BES-

Sample Code : To Add two integers using Command Line Arguments #include <stdio.h> #include<stdlib.h> void main ( int argc, char *argv[] ) { int a,b,sum; if ( arg!=3) { return -1;} a=atoi(argv[1]); b=atoi(argv[2]); sum=a+b; printf(“%d”,sum); return 0} KLEF CTSD BES-

Program Execution Steps to execute the program 1 Go to the command prompt and type cmd 2 c:\users\harita>cd Documents c:\users\harita\cd Documents> cla 5 5 10 KELF CTSD BES-

REFERENCES FOR FURTHER LEARNING OF THE SESSION Reference Books:

  1. Mark Allen weiss, Data Structures and Algorithm Analysis in C, 2008, Third Edition, Pearson Education.
  2. Horowitz, Sahni, Anderson Freed, “Fundamentals of Data structures in C”, 2nd Edition2007.
  3. Robert Kruse, C. L. Tondo, Bruce Leung, Shashi Mogalla, “Data structures and Program Design in C”, 4th Edition- Sites and Web links:
  4. www.hackerrank.com
  5. www.codechef.com Reference Books:
    1. 1.) Brian W. Kernighan, Dennis M. Ritchie, “The C Programming Language: ANSI C Version”, 2/e, Prentice-Hall/Pearson Education-2005. 2.) E. Balagurusamy, “Programming in ANSI C” 4thed. Tata McGraw-Hill Education, 2008 Sites and Web links:
  1. https://www.w3schools.com/c/c_arrays.php
  2. https://www.includehelp.com/c-programs/c-programs-one-dimensional-arrays-problems-and-solutions.aspx https://technictiming.com/c-programming/array/