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

Chapter02 CLanguage

A data structure is a way of organizing and storing data to enable efficient access and modification. Common types include arrays, linked lists, stacks, queues, and trees, each designed to manage data for specific operations, making it essential in programming and algorithm design.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Chapter02 CLanguage

A data structure is a way of organizing and storing data to enable efficient access and modification. Common types include arrays, linked lists, stacks, queues, and trees, each designed to manage data for specific operations, making it essential in programming and algorithm design.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Jobkey University

• Faculty of ICT
• Course: Procedural Language
• C-Language
• Instructor: Eng. Abdikani Dhuhul

1
Copyright © 2012 Pearson Education, Inc.
Chapter 2:

Introduction to C Language

Copyright © 2012 Pearson Education, Inc.


DATA TYPES IN C LANGUAGE
Data Types
The data type in C defines the amount of
storage allocated to variables, C is rich in data
types. The verity of data type allow the
programmer to select appropriate data type to
satisfy the need of application as well as the
needs of different machine.

Copyright © 2012 Pearson Education, Inc.


There are three classes of Data-Type

Displays output on the computer screen


1.Primary Data Type
2.Derived Data Type
3.User Defined Data Type

Copyright © 2012 Pearson Education, Inc.


Primary Data Types(Fundamental Data Types)

• All C compiler support five type of


fundamental data type
• 1. Integer int 2,768 to 32,768
• 2. Character char -128 to 127
• 3. Floating Point float 3.4e-38 to 3.4e+38
4. Double Precision Floating Point double
1.7e-308 to 1.7e+308
• 5. Void Data Type void(used for function
when no value is to be return)
Copyright © 2012 Pearson Education, Inc.
Derived Data Type
• Those data types which are derived from
fundamental data types are called derived data
types. There are basically three derived data
types .
1. Array: A finit collection of data of same types or
homogenous data type.
2. String: An array of character type.
3. Structure: A collection of related variables of the
same or different data types.

Copyright © 2012 Pearson Education, Inc.


• Variables and Literals

Copyright © 2012 Pearson Education, Inc.


Variables and Literals
• Variable: a storage location in memory

– Has a name and a type of data it can hold


– Must be defined before it can be used:

int item;
Int a;
Int b;

Copyright © 2012 Pearson Education, Inc.


Literals
• Literal: a value that is written into a
program’s code.

 "hello, there" (string literal)


 12 (integer literal)

Copyright © 2012 Pearson Education, Inc.


Identifiers
• An identifier is a programmer-defined
name for some part of a program:
variables, functions, etc.

Copyright © 2012 Pearson Education, Inc.


Installation the Setup
1. Double Click Setup Dev
2. And complete the steps
3. After installed the setup search the Dev
4. Then Create New File

Copyright © 2012 Pearson Education, Inc.


InterFace

Copyright © 2012 Pearson Education, Inc.


• The Parts of a C Program

Copyright © 2012 Pearson Education, Inc.


The Parts of a C Program
// sample C program comment
#include <iostream> preprocessor directive
using namespace std; which namespace to use
int main() beginning of function named main
{ beginning of block for main
Printf "Hello, there!"; output statement
string literal
return 0; send 0 to operating system
} end of block for main

Copyright © 2012 Pearson Education, Inc.


Special Characters
Character Name Meaning
// Double slash Beginning of a comment
# Pound sign Beginning of preprocessor
directive
< > Open/close brackets Enclose filename in #include
( ) Open/close Used when naming a
parentheses function
{ } Open/close brace Encloses a group of
statements
" " Open/close Encloses string of
quotation marks characters
; Semicolon End of a programming
statement

Copyright © 2012 Pearson Education, Inc.


Creating New File
• Click File Menu
• Click New
• Click Source File

Copyright © 2012 Pearson Education, Inc.


Some Practice
Displaying Output:

#include <stdio.h>
#include <stdlib.h>
int main()
{

printf(" Welcome ");

return 0;
}

Copyright © 2012 Pearson Education, Inc.


Compile & Run
• When You Finish the Coding
• Make Compile
• Then Run the Code
• Or make Compile & Run at same time

Copyright © 2012 Pearson Education, Inc.


Making New Line
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf( "Jobkey University\n");
printf("Facult of ICT");
return 0;
}

Copyright © 2012 Pearson Education, Inc.


Declarion
#include<stdio.h>
#include<conio.h>
int main(void)
{

int p, n ;
float r, si ;
p = 10 ;
n=3;
r=2;
/* formula for simple interest */
si = p * n * r /100;
printf ( "%f" , si ) ;
getch();
}

Copyright © 2012 Pearson Education, Inc.


End

Copyright © 2012 Pearson Education, Inc.

You might also like