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

Lecture4 Ascii Values

ASCII Value In C

Uploaded by

Sandeep sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture4 Ascii Values

ASCII Value In C

Uploaded by

Sandeep sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

Assignments :

1 ) WAP to calculate average of three nos .

2 ) WAP to convert temperature Fahrenheit to centigrade .

3 ) WAP to calculate area of triangle , rectangle and circle .


# WAP to calculate values of quadratic expression
#include<stdio.h>
#include<math.h>
void main()
{ int a,b,c;
clrscr();
printf("\nEnter values a , b and c ");
scanf("%d%d%d",&a,&b,&c);

printf("\n X1 = %f “ , );
printf("\n X2 = %f “ , );
}
Differences B/W int and char
int X=5; Char ch=‘5’;
ASCII value (American Standard Code for
Information Interchange)
Definition : - numeric value of character is called the
ASCII value

‘A’, ‘B’ , ‘C’ , ‘D’ , …………. …‘Z’


65 66 67 68 90
‘a’ , ‘ b’ , ’c’ , ’d’,……… ………’z’
97 98 99 100 122
‘0’ , ‘1’ , ‘2’ , ‘3’………………….’9’
48 49 50 51 57
<enter> 13
< esp> 27
<space> 32
<back space> 8

Note :-
//WAP to display the ASCII value of any char
#include<stdio.h>
void main()
{ char ch;
printf("enter any character");
scanf("%c",&ch);
printf(“\n %c “ , ch ) ;
printf("\n ASCII value = " , );
}
Initialize char in prog.
Enerring char in prog.
#include<stdio.h> #include<stdio.h>
Void main( )
void main() { char ch;
printf("enter any character");
{ char ch = A ; scanf("%c",&ch);
or ------------------
}
char ch = ‘A’ ;
}
Console Window

enter any character A


or
enter any character ‘A’
//WAP to convert into upper case into lower case:-
#include<stdio.h>
void main()
{ char ch;
printf("enter any character in upper case ");
scanf("%c",&ch);

printf("\n lower case character=%c",ch);


}
Assignment : WAP convert into lower case to into upper case:-

//WAP to convert into digit character into integer:-


void main()
{ char ch;
int x;
printf("\n Enter any digit character ");
scanf("%c",&ch);

printf("\n Integer value=%d",x);


}
-:Control statements:-
To control the flow of execution we used control statements;
1.if .
2.Loop : - while .
3. do_while .
4. for .
5.return .
6.break .
7.continue .
8.goto .
9.switch .

Note :- all control statements are keyword .


“if” statement :-

Note :-
Syntax of if statement-
If ( condition)
{
Statement 1;
Statement 2;
----------------
}

Note:- If we have more then one statements in “if”


statement , Parenthesis is must . but if we have only
single statement in “ if “ statement parenthesis is not
must.
EX:- int X =10,Y = 5,Z = 3 ;
if(X>=Y)
printf ( “Hello”);
if (Y!=Z)
printf (“Hello”);
if (Z==100)
printf(“ Hello”);
if( Z = 100 )
printf ( “ Hello “) ;
if ( 25 )
printf ( “Hello “);
if ( -12 )
printf( “Hello “);
if(‘A’)
printf(“Hello’);
if(0)
printf(“Hello”)
if(‘0’)
printf(“Hello”);
if ( )
printf( “Hello “);
if ( ‘ ‘ )
printf( “Hello”);
if(X>=Y && Z=100)
printf ( “Hello”);

if(X>=Y && (Z=100))


printf ( “Hello”);
printf ( “Hello”);
if(1,0)
printf ( “Hello”)
if(2,5,7,9,0,1)
printf ( “Hello”);
if(0,1)
printf ( “Hello”);
if(X>Y);
printf ( “Hello”);

Note:-
Syntax of if-else statement:-
if(condition)
{
Statement 1;
Statement 2;
-----------------
}
else
{
Statement 1;
Statement 2:
----------------
}
#WAP to check no is even or odd
#include<stdio.h>
void main( )
{ int no;
printf ("\n Enter any no");
scanf("%d",&no);
if( )
printf("\n no is even");
else
printf("\n no is odd");
}
#WAP to check no is even or odd
#include<stdio.h>
void main( )
{ int no;
printf ("\n Enter any no");
scanf("%d",&no);
if(no%2)
printf("\n no is odd");
else
printf("\n no is even");
}
Assignment :
# WAP to check year is leap year or not .

# WAP to check character is alphanumeric or not .


Syntax of if-else if statement
if(condition1)
{ Statement 1;
----------------
}
else if(condition2)
{ Statement 1;
----------------
}
else if(condition3)
{Statement 1;
----------------
}
else
{Statement 1;
----------------
}
//WAP to find the biggest no from 3 nos
void main()
{ int a,b,c;
printf("enter the value of a,b,c");
scanf("%d%d%d",&a,&b,&c);
if( )
printf( “ is biggest");
else if(
printf(“ is biggest ");
else
printf(“ is biggest ");
}
Assignment :
Syntax of Nested If
//WAP to Find Biggest Element in given 3 Elements
void main()
{ int a,b,c;
printf("\nEnter three number:");
scanf("%d%d%d",&a,&b,&c);
Assignment :

#WAP to display grade of student accordingly percentage


per grade
90 to 100 ‘A’
80 to 89 ‘B’
70 to 79 ‘C’
60 to 69 ‘D’
per <60 ‘Fail’

You might also like