0% found this document useful (0 votes)
65 views20 pages

Myppt

C is a structured programming language that supports dynamic memory allocation. It was developed by Dennis Ritchie and can be used to create applications like web browsers and file systems. C programming utilizes various data types including basic types like int and float, as well as derived types like arrays and pointers. Functions are blocks of code that perform tasks when called, and conditionals and loops control program flow.

Uploaded by

srivalli2406
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)
65 views20 pages

Myppt

C is a structured programming language that supports dynamic memory allocation. It was developed by Dennis Ritchie and can be used to create applications like web browsers and file systems. C programming utilizes various data types including basic types like int and float, as well as derived types like arrays and pointers. Functions are blocks of code that perform tasks when called, and conditionals and loops control program flow.

Uploaded by

srivalli2406
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/ 20

C PROGRAMMING

• C was developed by Denis Ritche..

• C is structured Programming language..

• C Supports Dynamic Memory Allocation Functions..

• You can also use the C/C++ programming language to create the Google Chrome web
browser and the Google File
Data types

 Data Types in C Programming  Derived Data Types:


 In C programming, data types are used to define the  Array: Used to store a collection of homogeneous
type of data that a variable can hold. There are four data elements. Example: int numbers[5] = {1, 2, 3,
categories of data types in C programming: 4, 5};
 Basic Data Types:  Pointer: Used to store the memory address of
 int: Used to store integer values. Example: int age =
another variableUser-defined Data Types:
25;  Structure: Used to store a collection of
 float: Used to store decimal values. Example: float heterogeneous data elements. Example: struct
price = 10.99; student { char name[50]; int age; };
  Union: Similar to a structure, but only one member
double: Used to store double-precision floating-point
values. Example: double pi = 3.14159; can be accessed at a time. Example: union data { int

i; float f; };
char: Used to store single characters. Example: char
grade = 'A';  . Example: int *p; p = &age;
variables

 Variables  // Declare variables example


 In C programming, a variable is a container int num1, num2, sum;
that holds a value. It has a name, a data type,
num1 = 5; num2 = 7;
and a value assigned to it. Variables are used
to store and manipulate data in a program. sum = num1 + num2;
printf("The sum of %d and %d is %d.", num1,
num2, sum);
Input and output stmts

Input and Output statement are used to read and write the
data in C
programming.

printf()-->it display the data in the screen…

scanf()it read the data from the user…


comments

Comments are two types : #include<stdio.h> #include<stdio.h>


int main() int main()
1. Single line comment..(//) { {
//printf(“Hello”); /*printf(“Hello”);
2. Multiline Comments..(/* */) printf(“Hii”); printf(“Hii”);*/
printf(“Hwru”); printf(“Hwru”);
} }
o/p: HiiHwru o/p:Hwru
DATA TYPES

 It represent the data and type of the variable . It describes size of memory to be
allocated for the variable..

 1.Basic Data Types(int,float,char,double)

 2.Derived Defined(Arrays,Pointers,Function)

 3.User Defined(Structures,Unions…)
OPERATORS
• Arthemetic Operators(+,-,*,/.%)

• Relational Operators(>,<,>=,<=,==,!=)

• Bistwise Operators(&,|)

• Logical Operators(&&,||,!)

• Assignment Operators(=)

• Compound Assignment Operators(+=,-=,*=,/=,%=)

• Increment/Derement Operators(++,--)

• Bitwise Shift Operations(>>(right),<<(left))


VARIABLES

Variables are which is used to stored the data…Variables are names

Variable Declaration:
<<Datatype>> <<variable name>;
Ex:int val;

Variable Intilization:
<<Datatype>> <<variable name>> = value;
Ex:int val=10;
LOOPS

Loops are used to execute the statement multiple times… for(intilization;condition;u


While(condition) pdation)
{ {
In C Loops can be: ----; --------;
----; --------;
}
1.Entry Control Loop(While ,For) }

do
{
2.Exit Control Loop(do while) -----;
-----;
}while(condition);
Loop Control Statements:
1.break; //it stops execution and come out from the loop
2.Continue;//it skips the execution control goes to update expression
EXAMPLE PROGRAMS ON LOOPS

int i=0; do
for(int i=0;i<10;i++) While(i<10) {
{ { printf(“%d
printf(“%d “,i); printf(“%d “,i);
“,i); i++;
} }while(i<10);
}
o/p:0 1 2 3 4 5 6 7 8 9 o/p: 0 1 2 3 4 5 6 7 8 9
o/p:0 1 2 3 4 5 6 7 8 9
int i; int i;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++)
if (i == 4) { {
break; if (i == 4) {
} continue;
printf("%d ", i); }
} printf("%d\n", i);
O/P:0 1 2 3 }
o/p:01 2 3 5 67 8 9
CONDITIONAL
STATEMENTS

Conditional statements in C are programming constructs that allow a program to execute


different blocks of code based on whether a certain condition is true or false.

Conditional Statements are :

1.if if(condition){execute the statements }condition true

2.if-else if(condition){if statements are execute}else{else part stat executed}

3.Switch switch(choice){case 1: case 2:

statements; statements;
break; break;
}
FUNCTIONS

A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.


#include<stdio.h>
Syntax: Int add(int,int)Function Declaration
Int main()
{
returntype functionname(arg1,arg2) int a=10,b=20;
{ add(a,b);Called Function
}
------; Int add(int c,int d)Function Definition
------; {
printf(“%d”,c+d);
return 0;
} }
FUNCTIONS

ACTUAL PARAMETERS :
 The arguments which are present in the called function are Actual
Argument #include<stdioh>
Int add(int,int)Function Declaration
add(a,b);Called Function Int main()
{
int a=10,b=20;
FORMAL ARGUMENTS :
add(a,b);Called Function
 The arguments which are present in the function definition are }
Int add(int c,int d)Function Definition
 Formal Arguments..
{
 Int add(int c,int d)Function Definition printf(“%d”,c+d);
return 0;
}
ARRAYS

• Arrays which is used to stored collection of same datatype elements.


• Arrays stored collection of homogeneous elements..
• Array elements can be accessed based on index value
• Array index start with 0 ends with size-1
• Syntax :datatype arrayname[size];Declaration
 datatype arrayname[5]={1,2,3,4,5};Intilization
ARRAYS

• Reading and printing the array elements using loop


#include<stdio.h>
Int main()
{
int num=5, arr[num];
for(int i=0;i<num;i++)
{
scanf(“%d”,&arr[i]);
}
for(int i=0;i<num;i++)
{

printf(“%d “,arr[i]);
}
}
TWO DIMENSIONAL ARRAYS

Two Dimensional arrays are also called as matrix .It stores the values in rows
and coloumns..
int x[3][4];
for(int i = 0; i < 3; i++)
Syntax :
{
Datatype arrayname[row][col]; for(int j = 0; j < 4;
j++){
Example :-
scanf(“%d”,&x[i][j]);
int arr[2][2]={{1,2},{3,4}};
col1 col2 printf(“%d”,x[i][j]);
}
row1 1 2
}
row2 3 4
STRUCTURES

• Arrays which is used to stored collection of same datatype elements.


• Structures which is used to stored to collection of same and different data type element
Syntax:
struct structure name
{
member1;
member2;
};
struct structure name variablename;structure variable declaration
Note : Structure class ends with semicolon
Ex:
struct structure
{
int a;
float b;
};
struct structure var={1,2.2};structure initialization
int main()
{
printf(“%d %f\n”,var.a,var.b);
}

Note:We can acess the structure elements by using (.)operator..


unions

You might also like