You are on page 1of 6

AIM POINT INFOSYSTEM PVT. LTD.

2019

COMPILER:- It is a software which is used to convert high level language(English) to


low level language(binary 0,1). Or source code to machine code.

FLOW CHART OF “C” PROGRAM


types of error
Start
1:- Compile time error/ syntax error
Load c

Edit program
2:- Run time error/ logical error
compile

Run

O/P

Exit

Header Files : Header file are predefined library files , contain predefined functions and
categorized related to their functionality

Syntax : #include<headerfile.h>
Example
#include< stdio.h > : contain functions related to input / output operation
#include< math.h > : contain functions related to math operation
#include< conio.h > : contain functions related to console device operation
#include< string.h > : contain functions related to string operation
#include< dos.h > : contain functions related to DOS operation

< stdio.h > Standard Input Output Hearder File


It contain all functions related to input / output operations .

printf( ):- It is a formatted function of < stdio.h > header file which is used to print some
message or valves on moniter..
formatted specifiers /characters in “C”
Ex: 1 ) - printf ( “Hello India ” ); Datatype Specifiers
O/P :- Hello India int %d, %i
char %c
Ex 2 ) - int X=5; float %f
char Y=’A’; string %s
float Ch=10.5; unsigned int %u
long int %ld
double %lf
FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 1 long double %Lf
AIM POINT INFOSYSTEM PVT. LTD. 2019

printf ( “%d %f %c” , X , Y , Ch );


O/P 5 10.5 A

Ex 3 )- printf ( “Average = %f ” , avg );


O/P: Average = 27 . 8

scanf( ) :- It is a formatted function of <stdio.h> header file which is used to scan or


enter
Some values from keyboard on moniter.
Ex:-
int X;
char Ch;
float Y;

Scanf ( “%d%f%c” , &X , &Y,&Ch);

//WAP to calculate the addition of two no:-.


#include<stdio.h>
void main( )
{ int x,y,z ; //decleration of variable
printf (" \n enter the valve of x and y : ");
scanf ( "%d%d" , &x , &y );
z=x+y ;
printf ( "\n the sum of nos=%d " , z );
}

Basic concept for executing programs:


 SAVE with .c extension (in user directory)
 COMPILE = F9
 RUN = Ctrl+F9
 O/P = Alt+F5 ( to shift control to outpur window )

//WAP to the division of 2 nos.


#include<stdio.h> Datatype <op> Datatype Result
void main() int int int
{ int x , y ; int float float
float z ; float int float
printf("enter the valve of x and y"); float float float
scanf ( "%d%d" , &x , &y ); float long int

FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 2


AIM POINT INFOSYSTEM PVT. LTD. 2019

z= x/y ;

printf("\n the division of 2 nos=%f",z);


}

Type casting :- By this the compiler reads one primitive datatype as another primitive
Datatype( Temporary only )

Note : We cant change data type in any computer language ( there is no concept )

Exercise : int x ,y ;
float z ;
z = ( float ) x / y ;
z = x / ( float ) y ;
z = float ( x ) / y ;
z = ( float ) ( x / y ) ;
Note :-

.# WAP to swap 2 nos


#include<stdio.h>
void main()
{ int x , y ;

printf("\n Enter the valve of x and y : ");


scanf ( "%d%d" , &x , &y );
printf("\n Before Swapping : %d %d “ , x , y ) ;

printf("\n After Swapping : %d %d “ , x , y ) ;


}
Assginment : WAP to swapping of two nos without using third variable( atleast by 2
methods)

# WAP to swapping of two different data type


# include < stdio .h >
void main( )
{
int x ;
float y ;

FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 3


AIM POINT INFOSYSTEM PVT. LTD. 2019

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<conio.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 Root1= %f “ , );
printf("\n Root1= %f “ , );
}

Differences B/W int and char

int X=5; char ch=’5’;

FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 4


AIM POINT INFOSYSTEM PVT. LTD. 2019

ASCII value ( )
Definition : -

‘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’ //digit character
48 49 50 51 57
<enter> 13
< esp> 27
<space> 32
<back space> 8

Note :- In case of int compiler directly convert int into binary no and stored in 2 bytes ,
where in case of char compiler convert the ASCII value of char in binary no and stored
in 1 byte .

//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 = ", );
}

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

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


}
Assignment : WAP convert any lower case character to into upper case character:-.
//WAP to convert into digit character into integer:-
FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 5
AIM POINT INFOSYSTEM PVT. LTD. 2019

#include<stdio.h>
void main()
{ char ch;
int x;
printf("\n Enter any digit character : ");
scanf("%c",&ch);

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


}

FACULTY : SANDEEP SAHU( M.Tech(CSE))Page 6

You might also like