Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

04 C Programming

C Programming lec -4 notes

Uploaded by

pnkulkarni05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

04 C Programming

C Programming lec -4 notes

Uploaded by

pnkulkarni05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

C PROGRAMMING

INDEX
1 Constants in C

2 Operators in C

3 Escape Sequence C

4 Format Specifier in C
CONSTANTS IN C
 A constant is a value or variable that can't be changed
in the program,

 Constants can be of any of the basic data types like an

Integer constant,
Floating constant,
Character constant, or
String constant.
Integer Constant 10, 20, 450 etc.

Floating-point Constant 10.3, 20.2, 450.6 etc.

Character Constant 'a', 'b', 'x' etc.

String Constant "c", "c program", "c in javatpoint"


etc.
Define constant in C

 The const keyword is used to define constant in C


programming.

const float PI=3.14;

Now, the value of PI variable can't be changed.


 Program :

#include <stdio.h>
#include <conio.h>

void main(){

const float PI=3.14;

printf("The value of PI is: %f",PI);

getch();

}
 OUTPUT
 Program :

#include <stdio.h>

int main() {

const int LENGTH = 10;


const int WIDTH = 5;

int mul;

mul= LENGTH * WIDTH;


printf("value of area : %d", mul);

return 0;
}
 OUTPUT
OPERATORS IN C
 An operator is simply a symbol that is used to perform
operations.

There are following types of operators to perform


different types of operations in C language….

➢ Arithmetic Operators
➢ Increment Decrement Operators
➢ Relational Operator
➢ Logical Operators
➢ Bitwise Operators
➢ Assignment Operators
➢ Misc Operators
 Program :

#include <stdio.h>

int main() {

int i,j,sum;

printf("Enter number One : ");


scanf("%d",&i);

printf("Enter number Two : ");


scanf("%d",&j);

sum = i+j;

printf("Total is : %d",sum);

getch();

return 0;
}
 OUTPUT
 Program

#include <stdio.h>

int main() {

int i = 1;

i++;

printf("Value of i is : %d",i);

getch();

return 0;
}
 OUTPUT
#include<stdio.h>
#include<conio.h>

void main(){

int i=60, j=50;


int checkValue;

checkValue = i>j;

printf("Value is return : %d", checkValue);

getch();

}
OUTPUT :

Return 1 if statement is true


Return 0 if statement is false
ESCAPE SEQUENCE IN C
 An escape sequence in C language is a sequence of
characters that doesn't represent itself when used
inside program.

but is translated into another character or a


sequence of characters that may be difficult or
impossible to represent directly.
List of Escape Sequences in C
Program :

#include <stdio.h>
#include <conio.h>

void main(){

int number=50;

printf("You \n are \n learning \n \'c\' language \n


\"Welcome to c language world...\" ");

getch();

}
OUTPUT
FORMAT SPECIFIER IN C
 In C programming we need lots of format specifier to
work with various data types.

 Format specifiers defines the type of data to be printed


on standard output
*****************************************************

You might also like