OBJECTIVE



LAB # 01INTRODUCTIONOBJECTIVEFamiliarization with C programming in an Integerated Development Environment.THEORYProgrammingThe act of writing computer programs is called computer programming. A computer program is a sequence of instructions written using a computer programming language to perform specified tasks by the computer. There are a large number of programming languages that can be used to write computer programs, for example: C, C++, Java, Python, PHP, Perl, Ruby etc.C Programming LanguageC is a general-purpose programming language used to develop a wide range of applications from operating systems like Windows to software that is used for creating 3D movies. C was developed by Dennis Ritchie at Bell labs, USA between 1969 and 1973. It has since become one of the most widely used programming languages of all time. C programming is highly efficient, that is one of the reasons why it is very popular despite being more than 40 years old. Many later programming languages have borrowed directly or indirectly from C, including C++, Java, JavaScript, C#, Objective-C, Perl, PHP, Python, and Verilog.Integrated Development EnvironmentAn Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. Typically, an IDE contains a code editor, a compiler or interpreter and a debugger that the developer accesses through a single graphical user interface (GUI). An IDE may be a standalone application, or it may be included as part of one or more existing and compatible applications. IDEs are also available online that can be accessed through a web browser. Using an IDE will save you a lot of time and effort in writing a program. However, be careful of some of the pitfalls of using an IDE as it may not be ideal for everyone and might not be suitable in every situation. Some IDEs are very complicated to use and may consume a lot of resources. Many IDEs support C Programming Language. Some of the popular IDEs are listed below.Standalone IDEs:Microsoft Visual Studio Code IDEs:Ideone GDB a C program file with Code::BlocksCode::Blocks creates what is called a Workspace to keep track of the project you are working on. A project is a collection of one or more source (as well as header) files. Source files are the files that contain the source code for your program. When developing a C language program, you write C source code that is saved in a .c file.Step#1: To create a file, click on the File pull-down menu, open New and select File.Step#2: Select C/C++ source and click Go.Step#3: As we are going to write code using C language, select ‘C’ and click Next.Step#4: Mention filename (e.g. FirstProg.c) with full path (where you want to save file) and click Finish.You can now start to write code in your file.206692588455500A simple C programFollowing is a simple C program./*Description: Writes the words "Hello, World!" on the screen*/ #include<stdio.h> // The main functionmain() { printf("Hello, World! \n"); }/*...*/ and // are used for comments. Comments do not cause the computer to perform any action when the program is run.#include<stdio.h> tells the preprocessor to include the contents of the standard input/output header (<stdio.h>) in the program.main () indicates the beginning of the main function. Every C program must contain the main function. printf("Hello, World! \n") instructs the computer to print on the screen the string of characters marked by the quotation marks. \n is an escape sequence that means newline. It causes the cursor to position to the beginning of the next line on the screen.; is called the statement terminator. Every C statement must end with the statement terminator.{...} are called braces or curly brackets. A left brace begins the body of every function and a corresponding right brace ends the function. This pair of braces and the portion of the program between the braces is called a block. Braces are used to delimit blocks of code other than functions as well.Build and Run a C ProgramStep#1: Write your code in .c file.Step#2: Click Build menu and click Build (or press Ctrl+F9) to build the program.Step#3: Click Build menu and click Run (or press Ctrl+F10) to run the program.(Steps 2 and 3 can be combined by selecting Build and run or pressing F9)The output would be displayed in a separate window.Hello, World!Process returned 0 (0x0) execution time : 1.516 sPress any key to continue.EXERCISEUse Code::Blocks to create a file named lab1.c. Write the following code in the file. Execute it and show the output. (You can use the Snipping Tool to take a snapshot of your output window).Code:/* My first program */ #include<stdio.h> main() { printf("Welcome the the world of programming! \n"); }Output:Code:// My second program#include<stdio.h> int main() { printf("Welcome the the "); printf("world of programming! \n");}Output:Write a program in C language that prints your bio-data on the screen. Show your program and its output. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download