Download as pdf
Download as pdf
You are on page 1of 93
~ | RATHINGM faa NAAC RATHINGM “TECHNICAL CAMPUS — CAMPUS —ccoaszrscon Affiliated To Anna University, Chennai & Approved by AICTE, New Delhi. Eachanari, Coimbatore, Tamil Nadu, India - 641 021 RATHINGM LABORATORY RECORD NOTE BOOK NAME BRANCH REGISTER NUMBER YEAR / SEMESTER ACADEMIC YEAR SUBJECT CODE SUBJECT NAME ~ | RATHINGM 4) NAAC RATHINGM TECHNICAL CAMPUS —cconscrscon Affiliated To Anna University, Chennai & Approved by AICTE, New Delhi. - 641021 Eachanari, Coimbatore, Tamil Nadu, In‘ BONAFIDE CERTIFICATE NAME ACADEMIC YEAR YEAR/SEMESTER BRANCH UNIVERSITY REGISTER NUMBER: Certified that this is the bonafide record of work done by the above student in the Laboratory during the year 2022 - 20: Staff-in-Charge Head of the Department ‘Submitted for the Practical Examination held on Internal Examiner External Examiner ~ | RATHINGM fa wr RATHINGM “TECHNICAL CAMPUS CAMPUS —cconszrscee Affiliated To Anna University, Chennai & Approved by AICTE, New Delhi. Eachanari, Coimbatore, Tamil Nadu, India - 641 021 INDEX SHEET SLNo. | DATE EXPERIMENT NAME PAGE | MARKS | SIGN. Sl.No. DATE EXPERIMENT NAME PAGE ‘NO. MARKS. SIGN. Ex.No:01 TO LEARN AND DEVELOP APPLICATIONS USING GCC AND MAKE Date: AIM: To learn and develop applications using gcc and make. PROGRAM: Hello, world! #include int main(int arge, char **argy) { printf("%s\n", "Hello, world!"); return 0; } compilation: - compile, link, and execute: gcc hello.c aout ~ compile: gcc -c hello.c or gee -g -Wall -c hello.c - link: gec hello.o or gcc -g hello.0 -o hello - link multiple files and library: gcc -g myfile1.o myfile2.0 -Im -o myprogram Pre-processin; - Part of compilation ~ Process lines that begin with °# - Can be invoked separately with pp or gee -E Function definition: return type ~ argument list - function body - functions can only be at the top level (file scope) main() - The only function that a C program will execute - Other functions can be called from main) Using multiple functions Exampl int addtint x, int y); int main(int arge, char **argy) { int sum; sum = add(1, 2); printf(’%d\n", sum); return 0; } int addint x, int y) { retum x+y; } Function declaration: > Also called a prototype > A function must have been seen before it’s called > Enables compiler to do type-checking Using multiple files: Example: - myadd.h (called a header file): #ifndef MYADD_H_ #define_ MYADD_H_ int add(int x, int y); ‘#endif - myadd.e: #include "myadd.h" int add(int x, int y) { return x + } - main. #include "myadd.h" int main(int arge, char **argv) { } Preprocessor directives: - conditional compilation ifdef unix printf("you are cool”); File inclusion #include #include "myadd.h" ~ macros define PI 3.14 - just a textual substitution - so be careful! #define square(x) x * x // wrong! Make fil ‘This Make file should be used as a template for future Make files. It’s heavily commented, so hopefillly you can understand what each line does. We'll use gcc for C compilation and g++ for C++ compilation CC = gee CXX=g++ # Let’s leave a place holder for additional include directories INCLUDES = # Compilation options: #-g for debugging info and -Wall enables all warnings CFLAGS = -g -Wall S(INCLUDES) CXXFLAGS = -g -Wall S(INCLUDES) # Linking option: #-g for debugging info LDFLAGS =-g # List the libraries you need to link with in LDLIBS # For example, use "-Im" for the math library LDLIBS = # The Ist target gets built when you type "make", # It’s usually your executable. ("main" in this case.) # # Note that we did not specify the linking rule. # Instead, we rely on one of make’s implicit rules: *# # S(CC) S(LDFLAGS) $(LDLIBS) 3 #in the dependency list if we want to. # # make uses the following implicit rule to compile a . file into a.o # fille: main.o: main.c myadd.h # And myadd.o depends on myadd.c and myadd.h. myadd.o: myadd.c myadd.h # Always provide the "clean" target that removes intermediate files. # What you remove depend on your choice of coding tools # (different editors generate different backup files for example). # # And the "clean" target is not a file name, so we tell make that # it’s a "phony" target. PHONY: clean clean: rm -f *.0 a.out core main # “all” target is useful if your Makefile builds multiple programs. # Here we'll have it first do "clean", and rebuild the main target .PHONY: all all: clean main RESULT: ‘Thus the program to learn and develop applications executed successfully. ing gcc and make is completed and Ex.No:02, ~ 5 — Use version control systems command to clone, commit, Dates push, fetch, pull, checkout, reset, and delete repositories AIM: Use version control systems command to clone, commit, push, fetch, pull, checkout, reset, and delete repositories. FUNCTIONAL DIAGRAM: sets, aa aU wna orace || _ovconmn — — | — | —— —____ — citPut COMMANDS: ‘The commands are, Clone Commit Push, Fetch Pull Checkout Reset Delete VY VY VYVY Clone: The git clone command is used to create a copy of a specific repository or branch within a repository. Git is a distributed version control system, Maximize the advantages of a full repository on your ‘own machine by cloning. Syntax: git clone https://github. com/github/training-kit.git Commit: git commit creates a commit, which is like a snapshot of your repository. These commits are snapshots of your entire repository at specific times. You should make new commits often, based around logical units of change. Over time, commits should tell a story of the history of your repository and how it came to be the way that it currently is. Commits include lots of metadata in addition to the contents and message, like the author, timestamp, and more. Syntax: git commit -m “update the README.md with link to contributing guide” Push: git push updates the remote branch with local commits. It is one of the four commands in Git that prompts interaction with the remote repository. You can also think of git push as update or publish. Syntax: git push -u origin main Pull git pull is one of the 4 remote operations within Git. Without running git pull, your local repository will never be updated with changes from the remote. git pull should be used every day you interact with a repository with a remote, at the minimum. That's why git pull is one of the ‘most used Git commands. Synt # General format git pull OPTIONS REPOSITORY REFSPEC # Pull from specific branch git pull REMOTE-NAME BRANCH-NAME Checkout: Use git checkout on the command line to create a new branch, change your current working branch to a different branch, or even to switch to a different version of a file from a different branch with git checkout [branchname] [path to file]. The “checkout” action updates all or part of the working tree with a tree object or blob from the object database, and updates the index and HEAD if the whole working tree is pointing to a new branch. Syntax: git checkout [branch name] [path to file] Reset: The term reset stands for undoing changes. The git reset command is used to reset the changes. ‘The git reset command has three core forms of invocation. These forms are as follows. > Soft > Mixed Hard yyntax: git reset