0% found this document useful (0 votes)
29 views

C Programming Lecture 01

This document discusses C programming and provides an example program. It covers: - A computer program is a sequence of instructions to perform a specified task. - The steps to develop a program are to write it, check for correctness by compiling, and then execute it. - An example C program is shown that prints "Welcome to C programming!" when run. It demonstrates key elements like comments, functions, input/output operations, and returning a value. - The document also briefly discusses data types in C programming and printing special characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

C Programming Lecture 01

This document discusses C programming and provides an example program. It covers: - A computer program is a sequence of instructions to perform a specified task. - The steps to develop a program are to write it, check for correctness by compiling, and then execute it. - An example C program is shown that prints "Welcome to C programming!" when run. It demonstrates key elements like comments, functions, input/output operations, and returning a value. - The document also briefly discusses data types in C programming and printing special characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

C Programming

Lecture : 02
Data types, variables, constants
1. Introduction
2. Simple C program Example
3. Memory Concepts
4. Arithmetic in C
Computer Program
A Computer program is a sequence of
instructions written to perform a specified
task with a computer.
Computer Program
A Computer program is a sequence of
instructions written to perform a specified
task with a computer.
Example: Computer Program
Computer tell me what would be my balance
after 1 year if my starting balance is 1,00,000
and interest rate is 10%.
COMPUTER PROGRAM
Steps for developing a program
1. Write your program
2. Check Correctness (Compile)
3. Execute
COMPUTER PROGRAM
1 /* Author : Xyz
2 A first program in C */
3 #include <stdio.h>
4
5 int main()
6 {
7 printf( "Welcome to C programming!\n" );
8
9 return 0;
10 }
Welcome to C programming!
COMPUTER PROGRAM
Comments
– Text surrounded by /* and */ is ignored by
computer
– Used to describe program
• #include <stdio.h>
– Preprocessor directive - tells computer to load
contents of a certain file
– <stdio.h> allows standard input/output
operations
COMPUTER PROGRAM
• int main()
– C programs contain one or more functions,
exactly one of
which must be main
– Parenthesis used to indicate a function
– int means that main "returns" an integer value
– Braces indicate a block
• The bodies of all functions must be contained in
braces
COMPUTER PROGRAM
• printf( "Welcome to C!\n" );
– Instructs computer to perform an action
• Specifically, prints string of characters within
quotes
– Entire line called a statement
• All statements must end with a semicolon
– \ - escape character
• Indicates that printf should do something out of
the
ordinary
• \n is the newline character
COMPUTER PROGRAM
• return 0;
– A way to exit a function
– return 0, in this case, means that the program
terminated
normally
• Right brace }
– Indicates end of main has been reached
COMPUTER PROGRAM
Printing special characters
What How
New line printf( "\n" );
Tab printf( "\t" );
Alarm printf( "\a" );
Double quote printf( "\"" );
Slash(\) printf( "\\" );
Percent (%) printf( “%%" );
COMPUTER PROGRAM
Basic Data types
COMPUTER PROGRAM
Representing integers
COMPUTER PROGRAM
Representing fractions (float/double)
Thanks!

You might also like