C and Cpp-Programming-Lecture Slides, Slides of Computer Programming

This lecture was delivered by Prof. Varun Sahil to explain Programming concepts at Ankit Institute of Technology and Science. It includes: Traditionally, Programs, Extension, Languages, Microsoft, Compiler, Visual, Studio, Jargon, Executable

Typology: Slides

2011/2012

Uploaded on 07/23/2012

paravi
paravi 🇮🇳

5

(1)

65 documents

1 / 48

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C and C++
Traditionally C programs use the file
extension .C and C++ programs the
extension .CPP
C is essentially a subset of C++, so you
could use a C++ compiler to run a C
program. The two languages are
extremely similar.
In the labs we will be using a Microsoft
compiler called Microsoft Visual Studio.
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30

Partial preview of the text

Download C and Cpp-Programming-Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

C and C++

^ Traditionally C programs use the fileextension .C and C++ programs theextension .CPP ^ C is essentially a subset of C++, so youcould use a C++ compiler to run a Cprogram. The two languages areextremely similar. ^ In the labs we will be using a

Microsoft

compiler called Microsoft Visual Studio.

Some programmer jargon  Some words that will be used a lot:  Source code: The stuff you type into thecomputer. The program you are writing.  Compile (build): Taking source code andmaking a program that the computer canunderstand.  Executable: The compiled program that thecomputer can run.  Library: Added functions for Cprogramming to do certain tasks.  Header file: Files ending in .h which areincluded at the start of source code.

Basic Structure of a C Program output: Hello World!

C Program:^ #include <stdio.h>int main(){ printf(“Hello World!”);return 0;}

Example: Hello World

Basic Structure of a C Program

#include

<stdio.h> int^ main(){ printf(“Hello

World!”); return

0; C Program }

:

Example: Hello world Includes standardinput/output library ofprocedures. Read: “Hash-include”

Basic Structure of a C Program

C Program:^ #include <stdio.h>int main(){ printf(“Hello World”);return 0;}

Curly braces mark the beginning

and^ end

of a

Example: block of instructions.

Hello World

Basic Structure of a C Program

C Program:^ #include <stdio.h>int main(){ printf(“Hello World”);return 0;}

Instruction (

function call

)

Example: to output “Hello World”

Hello World

Printf

^ Writes on screen text in quotes ^ Quotes around string ^ Enclosed in parenthesis ^ Ends in semicolon

Control characters

^ \n – new line ^ \t - horizontal tab ^ \r - carriage return ^ \a - sound bell

Library functions

^ printf is a library function printf("SS-CARE \n School

of \n Engineering");

Output

SS-CARESchool

of Engineering

Variables

^ Variables, can be declared anywhere in theprogram. ^ However they are only visible to the programwithin the block of code in which they aredefined.

int^ main()

{ int^ x^

=^ 4; if^ (x>3){

int^ y^

=^ 3; } return

(0) }

Values and Variables

^ Basic Types:^ ^ Integers (signed and unsigned)

^ short ^ int  Floating point numbers ^ float ^ double  Characters (signed and unsigned)  Boolean

Basic Types:

char

^ Characters (

char

’a’ ’z’ ’A’ ’Z’ ’?’ ’@’ ’0’ ’9’

Variables

^ Name & type must be declared beforeuse ^ Allows for error checking ^ Explicit declaration