Upload
veerakumars
View
218
Download
0
Embed Size (px)
Citation preview
8/10/2019 07 g 108 c Programming Laboratory.psb
1/57
BANNARI AMMAN INSTITUTE OF TECHNOLOGY(Autonomous Institution Affiliated to Anna University-CoimbatoreApproved by AICTE - Accredited by NBA and NAAC with A! "rade#
SATHYAMANGALAM 638 401 Erode Di!ri"! T#$i% N#d&
DE'ARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
07 G 108 C PROGRAMMING LABORATORY
Prepared By,
P.UmaMaheswar
L!"""
P.#e$%a&hara'h
L!"""
1
8/10/2019 07 g 108 c Programming Laboratory.psb
2/57
BANNARI AMMAN INSTITUTE OF TECHNOLOGY(Autonomous Institution Affiliated to Anna University-Coimbatore
Approved by AICTE - Accredited by NBA and NAAC with A! "rade#
SATHYAMANGALAM 638 401 Erode Di!ri"! T#$i% N#d&
DE'ARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING
07G108 C PROGRAMMING LABORATORI"#
(C)mm)* ') a$$ &ra*+hes
0 0 -
Pr)/rams Us*/ e+s)*Ma2*/ a*d L))p*/ #'a'eme*'s3
1. Write a program to calculate the simple interest, given the principle, period and rate of interest (SimpleInterest = PNR /1!
". Write a program to convert the temperature from #ahrenheit to $entigrade and vice versa.%. ( # = 1.& ' ($ %"!! ) $ = ( #* %"! /1.& !+. Write a program to find the largest of % numers using the minimum possile chec-s. (Simple if!. Write a program to convert inar to decimal numer using 0hile loop.. Write a program to find all possile roots of 2uadratic e2uation using s0itch case.3. Write a program to read a particular numer and to chec- 0hether it is a prime numer or not.&. 4he 5lectricit Production compan has to print up the ills for its customers at the follo0ing rate6
Write a program to do the aove and the output should e in the follo0ing order $ustomer name, Numerof 7nits and the 4otal 8ill.
Pr)/rams Us*/ 45*+')*s3
9. Write a program using function that 0ill round a floating point numer to an indicated decimal place. #ore'ample, the numer 1".3&
1. Would :ield the value 1".3 0hen it is rounded off to t0o decimal places.11. Write a function e'change to interchange the values of t0o variales sa ; and :1". Write a recursive function that 0ill generate and print first n #ionacci series.
Pr)/rams Us*/ Arrays3
1%. Write a program to merge t0o different siW? rate is Rs."
#or the ne't 1 >W? rate is Rs.
#or the ne't " >W? rate is Rs.3
#or more than % >W? rate is Rs.&
"
8/10/2019 07 g 108 c Programming Laboratory.psb
3/57
13. 7sing arras 0rite a program to arrange the given set of N numers in ascending order and hence to pic-the greatest and the smallest numer. nd also find the presence of a specified numer
#'r*/ 6a*d$*/ Pr)/rams3
1&. Write a program to count numer of vo0els, consonants, 0ords, 0hite spaces and other characters in a
given line of te't.19. Write a program to chec- 0hether the given string is a palindrome or not.". Write a program to find the occurrence of a su string in a main string and if found replace it 0ith ne0
string."1. Write a program to sort the set of names in alphaetical order."". Write a program using gets @($apital! and puts o (Small! 0hich converts a given A$A program tped in
uppercase to a program in lo0ercase
Pr)/rams Us*/ #'r5+'5res3
"%. $reate a structure to store the follo0ing details6 Rollno, Name, Bar-1, Bar-", Bar-%, 4otal, verage, Result and $lass.
Write a program to read Rollno, name and % suCect mar-s. #ind out the total, result and class as follo0s6
a. 4otal is the addition of % suCect mar-s. Result is DPassD if all suCect mar-s are greater than or e2ual to else D#ailD.c. $lass 0ill e a0arded for students 0ho have cleared % suCectsi! $lass DEistinctionD if average F=3ii! $lass D#irstD if average lies et0een to 3+ (oth inclusive!iii! $lass DSecondD if average lies et0een G 9 (oth inclusive!d. Repeat the aove program to manipulate 1 studentsA details and sort the structures as perran- otained them
"+. Eefine a structure that can descrie the emploees 0ith the fields 5no, 5name. 8asic. Write a program tocalculate E = %"H of 8asic. ?R = 1H of 8asic. $$ = 1H of 8SI$, P# = 1, of 8asic andprint all details 0ith Net pa ll processing should e using pointer notation.
Pr)/rams Us*/ P)*'ers3
". Write a program to count the numer of consonants, vo0els, digits, 0hite spaces and other characters in aline of te't using pointers
". Write menu driven program to perform all string handling operations using pointers."3. Write a program to sort a list of strings in an alphaetical order (using pointers 0ith EB!"&. Write a menu driven program to perform addition, sutraction and multiplication of matrices using
pointers."9. Write a program to search for an element using inar search.%. Write a program for encrption of a given sentence and decrption of the same sentence.
%
8/10/2019 07 g 108 c Programming Laboratory.psb
4/57
1. #IMPL" INT"R"#T
OB"CTI"3
4o calculate the simple interest using the principle amount, no of ears andrate of interest
#OURC" CO"3
#include
#include
main()
{
float prin_amt,no_yrs,int_rate;
float SI;
printf("n !nter the principle amt");
scanf("f",$prin_amt);
printf("n !nter the no of years ");
scanf("f",$no_yrs);
printf("n !nter the interest rate ");
scanf("f",$int_rate);
SI%(prin_amt&no_yrs&int_rate)';
printf("n *he simple interst is f",SI);
+etch();
+
8/10/2019 07 g 108 c Programming Laboratory.psb
5/57
NPUT & OUTPUT :
!nter the principle amt-
!nter the no of years -
!nter the interest rate -
*he simple interst is /-.
iva Juestions6
1! $ programming language 0as developed KKKKKKKKKKK"! $ 0as developed in the ear KKKKKKKKKKKKKK%! $ is a KKKKKKKKKKKKKKK language+! $ language is availale for 0hich of the follo0ing @perating SstemsL! Which of the follo0ing smol is used to denote a pre*processor statementL! Which smol is used as a statement terminator in $L3! $haracter constants should e enclosed et0een KKKKK
8/10/2019 07 g 108 c Programming Laboratory.psb
6/57
. 4A6R"N6"IT TO C"NTIGRA" AN IC" "R#A
OB"CTI"3
4o convert the temperature from #ahrenheit to $entigrade and vice versa.
#OURC" CO"3
#include
#include
0oid main()
{
float 1,2;
int ch;
clrscr();
printf("ntt 1345!6SI34 32 *!78!69*:6!");
printf("nn . 1!4 to 296");
printf("n . 296 to 1!4");
printf("nn !4*!6 3:6 1=3I1! ");
scanf("d",$ch);
sitch(ch)
{
case
printf("nt !nter the 1enti+rade 0alue ");
scanf("f",$1);
2%.?&1@;
printf("nt *he correspondidin+ 2ahrenheit 0alue f 2",2);
AreaB;
8/10/2019 07 g 108 c Programming Laboratory.psb
7/57
case
printf("nt !nter the 2ahrenheit 0alue ");
scanf("f",$2);
1%(2C)'.?;
printf("nt *he eDui0alent 1enti+rade 0alue f 1",1);
AreaB;
default
printf("nt In0alid 1hoice");
+etch();
INPUT 9 OUTPUT 3
1345!6SI34 32 *!78!69*:6!
. 1!4 to 296. 296 to 1!4
!4*!6 3:6 1=3I1!
!nter the 2ahrenheit 0alue E-
*he eDui0alent 1enti+rade 0alue /. 1
5i0a Fuestions
1! 4he ma'imum length of a variale in $ is KKK"! What 0ill e the ma'imum si
8/10/2019 07 g 108 c Programming Laboratory.psb
8/57
-. LARG"#T O4 - NUMB"R#
OB"CTI"3
4o find the largest of % numers using the minimum possile chec-s.
#OURC" CO"3
#include
#include
0oid main()
{
int a,A,c;
printf("n G96H!S* 9734H 4:7!6S ");
printf("nn !nter the numAers 9,,1 n");
scanf("ddd",$a,$A,$c);
if((a>A) $$ (a>c))
printf("n *he lar+est no is 9 % d",a);
else if(A>c)
printf("n *he lar+est no is % d",A);
else
printf("n *he lar+est no is 1 % d",c);
+etch();
&
8/10/2019 07 g 108 c Programming Laboratory.psb
9/57
INPUT 9 OUTPUT 3
MR5S4 B@N % N7B85RS
5nter the % numers ,8,$ 6
11"%+"
4he largest no is $ = +"
iva Juestions6
1! 4he operator GG is an e'ample for KKK operator."! 4he operator G is used for%! 4he operator / can e applied toKKKKKKKKKKK+! 4he e2ualit operator is represented KKKKKKKKKK! @perators have hierarch. It is used to -no0 0hich operatorL
9
8/10/2019 07 g 108 c Programming Laboratory.psb
10/57
:. BINARY TO "CIMAL CON"R#ION
OB"CTI"3
4o convert the given inar numer into a decimal numer using 0hile loop.
#OURC" CO"3
#include
#include
#include
0oid main(){
lon+ n,r,i%,J,dec%;
clrscr();
printf("n !nter the Ainary numAer ");
scanf("ld",$n);
hile(nK%) {
r%n ;
dec%dec@r&po(,i);
n%n';
i@@;
printf("*he eDui0alent decimal numAer ld",dec);
+etch();
INPUT 9 OUTPUT 3
I496 *3 L!1I79G
!nter the Ainary numAer
1
8/10/2019 07 g 108 c Programming Laboratory.psb
11/57
*he eDui0alent decimal numAer M
5i0a Fuestions
) 4he it0ise NE operator is used forKKKKKKKKKK
) Which operator has the highest prioritL
) 4he tpe cast operator is represented asKKKKKKKKKKKK
E) 5'plicit tpe conversion is -no0n as
11
8/10/2019 07 g 108 c Programming Laboratory.psb
12/57
;. ROOT# O4
8/10/2019 07 g 108 c Programming Laboratory.psb
13/57
sitch(option)
{
case
printf("n 633*S 96! 6!9G 94L !F:9G");
root%(CA'(&a));
root%root;
printf("n 633* % f, n 633* % f",root,root);
AreaB;
case
printf("n 633*S 96! 6!9G 94L :4!F:9G");
root%CA@sDrt(sr)'(&a);
root%CACsDrt(sr)'(&a);
printf("n 633* % f, n 633* % f",root,root);
AreaB;
case
printf("n 633*S 96! I79HI496");
s%CA'&a;
s%sDrt(aAs(sr))'(&a);
printf("n 633* %f@ fi",s,s);
printf("n 633* fCfi",s,s);
1%
8/10/2019 07 g 108 c Programming Laboratory.psb
14/57
INPUT 9 OUTPUT 3
R@@4S @# J7ER4I$ 5J74I@N
5nter the values of a,,c6
1
*
9
WSR =.
R@@4S R5 R5M NE 5J7M
R@@4 1 = %.,
R@@4 "= %.
iva Juestions 6
1! In the $ language AaO representsKKKKKKKKKK
"! 4he numer of the relational operators in the $ language isKKKKKKKKK
%! compound statement is a group of statements included et0een a pair ofKKKKKKKK
+! In $, 0hat is unionL
! multidimensional arra can e e'pressed in terms ofKKKKKKKKKK
1+
8/10/2019 07 g 108 c Programming Laboratory.psb
15/57
=. PRIM" NUMB"R OR NOT
OB"CTI"3
4o chec- 0hether the given numer is a prime numer or not.
#OURC" CO"3
includeQstdio.hF
includeQprocess.hF
includeQconio.hFvoid main(!
int n,prime,i)
clrscr(!)
printf(Dnttt PRIB5 N@ D!)
printf(Dn 5nter the numer 6 D!)
scanf(DHdD,Gn!)
for(i=")iQn)i!
if(nHiT=!
prime=1)
else
printf(Dnn 4he given numer Hd is not a prime numerD,n!)
getch(!)
1
8/10/2019 07 g 108 c Programming Laboratory.psb
16/57
e'it(!)
U
U
printf(Dnn 4he given numer Hd is a prime numernD,n!)
getch(!)
U
INPUT 9 OUTPUT 3
PRIB5 N@
5nter the numer 6 1%4he given numer 1% is a prime numer
iva Juestions 6
1! pointer to a pointer in a form ofKKKKKKKKKK
"! Pointers are ofKKKKKKKK
%! Ba'imum numer of elements in the arra declaration int aVV& is KKKKKKKKKK
+! rra suscripts in $ al0as start atKKKKKKKK
! Structure is defined as KKKKKKKKKKKKKK
1
8/10/2019 07 g 108 c Programming Laboratory.psb
17/57
7. "L"CTRICITY BILL
OB"CTI"3
4o print the electricit ill 0ith $ustomer Name , Numer of units and
4otal amount
#OURC" CO"3
#include
#include
0oid main()
{
int initial,final,consumed,amt,ch;
char nameOP;
clrscr();
printf("ntt !G!1*6I1I* IGG");
printf("nn !nter the 1ustomer 4ame ");scanf("s",$name);
printf("n !nter the 2inal unit ");
scanf("d",$final);
printf(" !nter the Initial unit ");
scanf("d",$initial);
consumed%finalCinitial;
if(consumed- $ consumed- $ consumed
8/10/2019 07 g 108 c Programming Laboratory.psb
18/57
amt%consumed&/;
else if (consumed>-)
amt%consumed&?;
printf("n 1ustomer 4ame s",name);
printf("n 4o of :nits d",consumed);
printf("n *otal amount d",amt);
+etch();
INPUT 9 OUTPUT 3
5M5$4RI$I4: 8IMM
5nter the $ustomer Name 6 ?ema
5nter the #inal unit 6%+
5nter the Initial unit 61"
$ustomer Name 6 ?ema
No of 7nits 6 "%+
4otal amount 6 1%&
iva 6
1. ?eader files in $ contain 0hat L
". 4he printf(! function retunes 0hich value 0hen an error occursL
%. 4he output of printf(DHuD, *1! isKKKKKK
+. n mpersand efore the name of a variale denotesKKKKKKKK
. Null character is represented KKKKKKKKK
. statement differs from e'pression terminating 0ith aKKKKKKKKK
1&
8/10/2019 07 g 108 c Programming Laboratory.psb
19/57
8. ROUNING O44 4LOATING POINT NUMB"R
OB"CTI"3
4o round off a floating point numer using function.
#OURC" CO"3
#include
#include
#include
float round(float data,int di+);
0oid main()
{
float data,result;
int i,J,di+;
clrscr();
printf("nntt63:4LI4H 322 2G39*I4H 4:7!6n");
printf("n !nter the data ");
scanf("f",$data);
printf("n =o many di+its you ant after decimal pointQ ");
scanf("d",$di+);
if(di+
8/10/2019 07 g 108 c Programming Laboratory.psb
20/57
float round(float data,int di+)
{
lon+ temp,test;
float result;
result%(po(,di+@) & data);
temp%result;
test%temp;
if(test>%-)
temp%(temp')@;
else
temp%temp';
result%temp'po(,di+);
return(result);
INPUT 9 OUTPUT 3
R@7NEIN @## #M@4IN N7B85R
5nter the data 6 1".+9&3
?o0 man digits ou 0ant after decimal pointL 6 %
4he rounded off value of the data 1".+9&3 is6 1".+3
iva 6
What should e the e'pression return value for a do*0hile to terminateKKKKKKKK
What for continue statement is usedLWhich operator in $ is called a ternar operatorL
Which of the follo0ing is a -e 0ord is used for a storage classL
When the main function is called, it is called 0ith the argumentsL
"
8/10/2019 07 g 108 c Programming Laboratory.psb
21/57
>. INT"RC6ANGING T6" ALU"# O4 T?O ARIABL"#
OB"CTI"3
4o interchange the values in et0een t0o variales using function.
#OURC" CO"3
#include
#include
0oid sap(int R,int y);
0oid main()
{
int R,y;
clrscr();
printf("nntt I4*!61=94HI4H *=! 59G:!S 32 *N3 596I9G!S ");
printf("nnn!nter the 0alues for R $ y n");
scanf("d d",$R,$y);
printf("n *he 0alue of R $ y Aefore interchan+e n R%d n
y%dn",R,y);
sap(R,y);
+etch();
0oid sap(int R,int y)
{
int temp;
temp%R;
R%y;
y%temp;
"1
8/10/2019 07 g 108 c Programming Laboratory.psb
22/57
printf("n *he 0alue of R $ y after interchan+e n R%d n y%d
n",R,y);
INPUT 9 OUTPUT 3
IN45R$?NIN 4?5 M75S @# 4W@ RI8M5S
5nter the values for ' G 6
+
"%
4he value of ' G efore interchange 6
'=+
="%
4he value of ' G after interchange 6
'="%
=+
iva6
1! What is the difference et0een include QfileF and include LfileL
"! What is the difference et0een far and nearL
%! What is hashingL
+! ?o0 can I open a file so that other programs can update it at the same timeL
! When should a far pointer e usedL
""
http://www.coolinterview.com/interview/1025/http://www.coolinterview.com/interview/1000/http://www.coolinterview.com/interview/1043/http://www.coolinterview.com/interview/1036/http://www.coolinterview.com/interview/999/http://www.coolinterview.com/interview/1025/http://www.coolinterview.com/interview/1000/http://www.coolinterview.com/interview/1043/http://www.coolinterview.com/interview/1036/http://www.coolinterview.com/interview/999/8/10/2019 07 g 108 c Programming Laboratory.psb
23/57
10. 4IBONACCI #"RI"#
OB"CTI"3
4o generate first n #ionacci series using recursive function .
#OURC" CO"3
#include
#include
lon+ int fiAo(int n);
0oid main()
{
lon+ int n,i;
clrscr();
printf("nnttt 2I34911I S!6I!S");
printf("nn!nter the numAer n ");
scanf("ld",$n);
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
24/57
return ;
else
return(fiAo(iC)@fiAo(iC));
INPUT 9 OUTPUT 3
#I8@N$$I S5RI5S
5nter the numer n6 1
1 1 " % & 1%
"1 %+ &9 1++ "%% %33
%a3
1. 0h n e'ecutes faster than n1L
. Wh doesnLt strcat (string, LTL!) 0or- L
-. Is N7MM al0as defined as L
:. 0hen should the volatile modifier e usedL
;. What is page thrashingL
"+
http://www.coolinterview.com/interview/6074/http://www.coolinterview.com/interview/15132/http://www.coolinterview.com/interview/1007/http://www.coolinterview.com/interview/1058/http://www.coolinterview.com/interview/1061/http://www.coolinterview.com/interview/6074/http://www.coolinterview.com/interview/15132/http://www.coolinterview.com/interview/1007/http://www.coolinterview.com/interview/1058/http://www.coolinterview.com/interview/1061/8/10/2019 07 g 108 c Programming Laboratory.psb
25/57
11. ARRAY M"RGING
OB"CTI"3
4o merge t0o different si
8/10/2019 07 g 108 c Programming Laboratory.psb
26/57
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
27/57
INPUT 9 OUTPUT 3
7!6HI4H 32 9669S NI*=3:* L:8GI19*!
5nter the first arra ma' value6 +
5nter the first arra element6
1
"
%
1
5nter the second arra ma' value6
5nter the second arra element6
"
3
%
Resultant arra 0ithout duplicate 6
1
"
3
%
"3
8/10/2019 07 g 108 c Programming Laboratory.psb
28/57
1-. MATRI@ MULTIPLICATION 9 TRAN#PO#"
OB"CTI"3
4o multipl t0o matrices and to find the transpose of a resultant matri' using arra.
#OURC" CO"3
#include
#include
#include
0oid main()
{
int aOPOP,AOPOP,cOPOP,dOPOP,r,c,r,c,i,J,B;
clrscr();
printf("ntt 79*6I 7:G*I8GI19*I34 $ *694S83S!n");
printf("n!nter the ro $ column siTe of first matriR ");
scanf("d d",$r,$c);
printf("n!nter the ro $ column siTe of second matriR ");
scanf("d d",$r,$c);
if(cK%r)
{
printf("n "7atriR multiplication is not possiAle.ecause
6K%1"");
+etch();
eRit();
"&
8/10/2019 07 g 108 c Programming Laboratory.psb
29/57
else
{
printf("n!nter the first matriR n");
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
30/57
printf("n6esultant multiplied matriRn");
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
31/57
INPUT 9 OUTPUT 3
B4RI; B7M4IPMI$4I@N G 4RNSP@S5
5nter the ro0 G column si
8/10/2019 07 g 108 c Programming Laboratory.psb
32/57
1:. #TANAR "IATION
OB"CTI"3
4o find the follo0ing using arras
a!. 4o find the average and standard deviation.
!. 4o find the numer of integers, 0hich are greater than e2ual to a specified numer in the list.
#OURC" CO"3
includeQstdio.hF
includeQmath.hF
includeQconio.hF
void main(!
float n,i,sum=,s2rsum=,mean,stddev,chec-)
float dataV",deviationV",devias2rV")
clrscr(!)
printf(Dn tt S4NERE E5I4I@N nD!)
printf(Dn 5nter the numer of elements in data arra 6 D!)
scanf(DHgD,Gn!)
printf(Dn 5nter the elements of data arra one one 6 nD!)
for(i=1)iQ=n)i!
scanf(D HgD,GdataVi!)
for(i=1)iQ=n)i!
sum=sumdataVi)
mean=sum/n)
for(i=1)iQ=n)i!
deviationVi=dataVi*mean)
%"
8/10/2019 07 g 108 c Programming Laboratory.psb
33/57
devias2rVi=po0(deviationVi,"!)
s2rsum=s2rsumdevias2rVi)
U
stddev=s2rt(s2rsum/n!)
printf(Dn Et Bt (E*B!t (E*B!(E*B!D!)
printf(Dn KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKD!)
for(i=1)iQ=n)i!
printf(Dn Hgt Hgt H."ft H&.+fD, dataVi,mean,deviationVi,devias2rVi!)
printf(Dn Sum of deviation s2uare 6HgD,s2rsum!)
printf(Dnntt a!. B5N or = Hg t S4EE5I4I@N = HgD ,mean,stddev!)
printf(Dnn 5nter the numer to chec-6 D!)
scanf(DHgD,Gchec-!)
printf(D tt !.4he follo0ing numers are greater than the given numer 6D!)
for(i=1)iQ=n)i!
if(dataViFchec-!
printf(Dntt dataVHg=HgD,i,dataVi!)
U
getch(!)
U
%%
8/10/2019 07 g 108 c Programming Laboratory.psb
34/57
INPUT 9 OUTPUT 3
S4NERE E5I4I@N
5nter the numer of elements in data arra 6
5nter the elements of data arra one one 6
1
"%
1"
+
%
E B (E*B! (E*B!(E*B!
KKKKKKKKKKKKKKKKKKKKKKKKKKKKK
1 1.& *1.& "+9.+
"% 1.& ." %&.++
1" 1.& *+.& "%.+
+ 1.& "&." 39."+1
% 1.& *1%.& 19.++
Sum of deviation s2uare 61"9.&
a!. B5N or = 1.& S4EE5I4I@N = 1.1+3
5nter the numer to chec-6 1
! 4he follo0ing numers are greater than the given numer 6
dataV"="%
dataV%=1"
dataV+=+
%+
8/10/2019 07 g 108 c Programming Laboratory.psb
35/57
%a
1. When 0ould ou use a pointer to a function
. What is static identifierL "!Where are the auto variales storedL
-. When does the compiler not implicitl generate the address of the first element of an arraL
:. What are the advantages of auto varialesL
%
http://www.coolinterview.com/interview/1003/http://www.coolinterview.com/interview/12287/http://www.coolinterview.com/interview/973/http://www.coolinterview.com/interview/978/http://www.coolinterview.com/interview/1003/http://www.coolinterview.com/interview/12287/http://www.coolinterview.com/interview/973/http://www.coolinterview.com/interview/978/8/10/2019 07 g 108 c Programming Laboratory.psb
36/57
1;. ARRAY A#C"NING AN 4INING
OB"CTI"3
4o arrange the given set of N numers in ascending order, to pic- the greatest and the
smallest numer and to find the presence of a specified numer
.
#OURC" CO"3
#include
#include
0oid main()
{
int n,i,J,temp,aOP,R,found%;
clrscr();
printf("nnt 9669 9S1!4LI4H, 2I4LI4H H6!9*!S*, S79GG!S* 94L S8!1I2I!L
4:7!6");
printf("nn!nter the no of datas in array (n) ");
scanf("d",$n);
printf("n!nter the datas for array n");
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
37/57
printf("n*he sorted array is ");
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
38/57
INPUT 9 OUTPUT 3
9669 9S1!4LI4H, 2I4LI4H H6!9*!S*, S79GG!S* 94L S8!1I2I!L 4:7!6
5nter the no of datas in arra (n! 6
5nter the datas for arra 6
1"
%
3
"%
4he sorted arra is 6
1"
"%
%
3
4he minimum value of the arra is 6 4he ma'imum value of the arra is 6 3
5nter the data to find 6
5lement Present in Position 6
%a 3
1. What are advantages and disadvantages of e'ternal storage classL
. ?o0 do ou override a defined macroL
-. $an math operations e performed on a void pointerL
:. Where does gloal, static, local, register variales, free memor and $ Program instructions
get storedL
%&
http://www.coolinterview.com/interview/976/http://www.coolinterview.com/interview/1017/http://www.coolinterview.com/interview/992/http://www.coolinterview.com/interview/12288/http://www.coolinterview.com/interview/12288/http://www.coolinterview.com/interview/976/http://www.coolinterview.com/interview/1017/http://www.coolinterview.com/interview/992/http://www.coolinterview.com/interview/12288/http://www.coolinterview.com/interview/12288/8/10/2019 07 g 108 c Programming Laboratory.psb
39/57
1=. #TRING 6ANLING OP"RATION#
OB"CTI"3
4o find the numer of presence of numers, consonants, 0ords, 0hite spaces G other
characters..
#OURC" CO"3
#include
#include
#include
0oid main()
{
int 0o%,num%,cons%,s%,oth%,i,l;
char nO-P;
clrscr();
printf(" nnttt13:4*I4H *=! 4:7!6 32nt 53N!GS, 4:7!6S,
134S3494*S, N36LS, N=I*! S891!S $ 3*=!6 1=9691*!6S");
printf("nn !nter a line of teRtn");
+ets(n);
l%strlen(n);
for(i%;i%M- $$ nOiP%W/ $$ nOiP%E? $$ nOiP
8/10/2019 07 g 108 c Programming Laboratory.psb
40/57
else if(nOiP%%)
s@@;
else if(nOiP>% $$ nOiP
8/10/2019 07 g 108 c Programming Laboratory.psb
41/57
%. Eifference et0een 6 * 1!loal variale and Mocal variale , "!Static variale and loal
variale L
+. 4o 0hich numering sstem can the inar numer 111111111 e easil converted toL
17. #TRING PALINROM"
OB"CTI"3
4o chec- 0hether the given string is a palindrome or not.
#OURC" CO"3
#include
#include
#include
0oid main()
{
char strO-P;
int len,i,J,notpal%;
clrscr();
printf("nntt S*6I4H 89GI4L637! ");
printf("nn!nter the Strin+ ");
scanf("s",str);
len%strlen(str);
for(i%,J%lenC;i
8/10/2019 07 g 108 c Programming Laboratory.psb
42/57
if(notpal%%)
printf("n"*he +i0en strin+ is not palindrome"");
else
printf("n"*he +i0en strin+ is palindrome"");
+etch();
INPUT 9 OUTPUT 3
S4RIN PMINER@B5
5nter the String6 malaalam
D4he given string is palindromeD
S4RIN PMINER@B5
5nter the String6 nalam
D4he given string is not palindromeD
iva6
1. ?o0 can 0e read/0rite structures from/to data filesL". What is the 2uic-est searching method to useL%. Eifferentiate et0een a lin-er and lin-ageL
+"
http://www.coolinterview.com/interview/15163/http://www.coolinterview.com/interview/1044/http://www.coolinterview.com/interview/975/http://www.coolinterview.com/interview/15163/http://www.coolinterview.com/interview/1044/http://www.coolinterview.com/interview/975/8/10/2019 07 g 108 c Programming Laboratory.psb
43/57
1>. #ORTING O4 NAM"# IN ALP6AB"TICAL OR"R
OB"CTI"3
4o sort the names in alphaetical order using string handling functions.
#OURC" CO"3
#include
#include
#include
0oid main()
{
char nameOPOP,tempO-P;
int i,J,n;
clrscr();
printf("ntt S36*I4H 32 497!S I4 9G8=9!*I19G 36L!6n");
printf("n!nter the numAer of names ");
scanf("d",$n);
printf("n!nter the names one Ay one n");
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
44/57
printf("ntt S36*!L 497!S n");
for(i%;i
Saritha.R
8indhu.N
:asodha.>
8indhu.$
S@R45E NB5S
8indhu.$
8indhu.N
Punitha.>
Saritha.R
:asodha.>
iva6
1. What is the 2uic-est searching method to useL
". ?o0 to find $E of four numersL
%. What is PreprocessorL
+. What is the heapL
. $an a variale e oth const and volatileL
. ?o0 can ou chec- to see 0hether a smol is definedL
++
http://www.coolinterview.com/interview/1044/http://www.coolinterview.com/interview/16400/http://www.coolinterview.com/interview/1034/http://www.coolinterview.com/interview/996/http://www.coolinterview.com/interview/1057/http://www.coolinterview.com/interview/1016/http://www.coolinterview.com/interview/1044/http://www.coolinterview.com/interview/16400/http://www.coolinterview.com/interview/1034/http://www.coolinterview.com/interview/996/http://www.coolinterview.com/interview/1057/http://www.coolinterview.com/interview/1016/8/10/2019 07 g 108 c Programming Laboratory.psb
45/57
0. #TRING CA#" CON"R#ION
OB"CTI"3
4o convert the given 0ord from uppercase to lo0ercase.
#OURC" CO"3
#include
#include
#include
0oid main()
{
char upperOP,loerOP;
int len,i;
clrscr();
printf("nnt 1345!6SI34 2637 :88!6 19S! *3 G3N!6 19S! ");
printf("nn!nter the strin+ in uppercase ");
scanf("s",upper);
len%strlen(upper);
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
46/57
INPUT 9 OUTPUT 3
$@N5RSI@N #R@B 7PP5R $S5 4@ M@W5R $S5
5nter the string in uppercase6 ?5BM4?
4he lo0er case of D?5BM4?D is DhemalathaD.
iva6
1. Eifference et0een 6* 1! N7MM pointer and N7MM macroL
". What is the difference et0een te't and inar modesL
%. $ Program to print the follo0ing series6 1 1 " 1 " % 1 " % + 1 " % +
+. ?o0 I can add t0o numers in c language 0ithout using rithmetic operatorsL
+
http://www.coolinterview.com/interview/16203/http://www.coolinterview.com/interview/1038/http://www.coolinterview.com/interview/11753/http://www.coolinterview.com/interview/12525/http://www.coolinterview.com/interview/16203/http://www.coolinterview.com/interview/1038/http://www.coolinterview.com/interview/11753/http://www.coolinterview.com/interview/12525/8/10/2019 07 g 108 c Programming Laboratory.psb
47/57
1.#TU"NT "TAIL#
OB"CTI"3
4o calculate the average of three mar-s of students and to store the Rollno, Name,Bar-1, Bar-", Bar-%, 4otal, verage, Result and $lass using structure.
#OURC" CO"3
#include
#include
#include
struct stud
{
int rollno,m,m,m,total;
char nameOP,+radeOP;
float a0+;
sO-P;
0oid main()
{
int i,n;
clrscr();
printf("nttt S*:L!4*S L!*9IGS ");
printf("n !nter the numAer of student");
scanf("d",$n);
for(i%;i
8/10/2019 07 g 108 c Programming Laboratory.psb
48/57
scanf("s",$sOiP.name);
printf("n 7arB ");
scanf("d",$sOiP.m);
printf("n 7arB ");
scanf("d",$sOiP.m);
printf("n 7arB ");
scanf("d",$sOiP.m);
if(sOiP.m
8/10/2019 07 g 108 c Programming Laboratory.psb
49/57
INPUT 9 OUTPUT 3
S47E5N4S E54IMS
5nter the numer of student6"
5nter the student 1 details6
Roll no 6"
Name 68indhu.N
Bar-1 6
Bar-" 6
Bar-% 63"
5nter the student " details6
Roll no 61
Name 6Shanthi.>
Bar-1 61"
Bar-" 6+
Bar-% 63& S47E5N4 BR> MIS4
R@MMN@ NB5 BR>1 BR>" BR>% 4@4M 5R5 RE5
" 8indhu.N 3" 19% +. #irst
1 Shanthi.> 1" + 3& 1% +. #ail
iva6
1. ?o0 can I sort things that are too large to ring into memorL". What is the code for clrscr(! functionL%. ?o0 do ou print onl part of a stringL+. What is the difference et0een goto and longCmp(! and setCmp(!L
+9
http://www.coolinterview.com/interview/1046/http://www.coolinterview.com/interview/16261/http://www.coolinterview.com/interview/1012/http://www.coolinterview.com/interview/1064/http://www.coolinterview.com/interview/1046/http://www.coolinterview.com/interview/16261/http://www.coolinterview.com/interview/1012/http://www.coolinterview.com/interview/1064/8/10/2019 07 g 108 c Programming Laboratory.psb
50/57
. "MPLOY"" #ALARY "TAIL#
OB"CTI"3
4o calculate the E, ?R, $$, P# of an emploee and to print the Pa slip using
structure 0ith pointer notation.
#OURC" CO"3
#include
#include
struct emp
{
int eno;char enameO-P;
lon+ int Aasic;
;
0oid main()
{
douAle da,hra,cca,pf,+ross,net;
struct emp &e,a;
e%$a;clrscr();
printf("nntt !78G3!! S9G96 L!*9IGS ");
printf("n !nter emp no ");
scanf("d",$eC>eno);
printf("n !nter name of the employee ");
scanf("s",$eC>ename);
printf("n !nter the Aasic pay ");
scanf("ld",$eC>Aasic);
da%eC>Aasic&';
hra%eC>Aasic&-';
8/10/2019 07 g 108 c Programming Laboratory.psb
51/57
cca%eC>Aasic&';
pf%eC>Aasic&-';
+ross%eC>Aasic@da@hra@cca;
net%+rossCpf;
printf("nttt 89 SGI8 n");
printf("n!mployee 4o d",eC>eno);
printf("n4ame s",eC>ename);
printf("nasic salary ld",eC>Aasic);
printf("n=69 lf",hra);
printf("nL9 lf",da);
printf("n82 lf",pf);
printf("nHross Salary lf",+ross);
printf("n4et Salary lf",net);
+etch();
INPUT 9 OUTPUT 3
5BPM@:55 SMR: E54IMS
5nter emp no 6 1"
5nter name of the emploee 6 Sasi-ala.8
5nter the asic pa 6 1
P: SMIP
5mploee No 6 1"
Name 6 Sasi-ala.8
8asic salar 6 1?R 6 "".
E 6 +&.
P# 6 "".
ross Salar 6 "%.
Net Salar 6 "1%.
1
8/10/2019 07 g 108 c Programming Laboratory.psb
52/57
iva 6
1. What is the purpose of realloc( !L
". ?o0 do ou print onl part of a stringL
%. What is the difference et0een goto and longCmp(! and setCmp(!L
+. ?o0 I can add t0o numers in c language 0ithout using rithmetic operatorsL
. ?o0 much memor does a static variale ta-esL
"
http://www.coolinterview.com/interview/961/http://www.coolinterview.com/interview/1012/http://www.coolinterview.com/interview/1064/http://www.coolinterview.com/interview/16271/http://www.coolinterview.com/interview/12545/http://www.coolinterview.com/interview/961/http://www.coolinterview.com/interview/1012/http://www.coolinterview.com/interview/1064/http://www.coolinterview.com/interview/16271/http://www.coolinterview.com/interview/12545/8/10/2019 07 g 108 c Programming Laboratory.psb
53/57
-. #TRING 6ANLING OP"RATION#
OB"CTI"3
4o find the numer of presence of numers, consonants, 0ords, 0hite spaces G other
characters..
#OURC" CO"3
#include
#include
#include
0oid main()
{
int 0o%,num%,cons%,s%,oth%,i,l;
char &str+;
clrscr();
printf(" nnttt13:4*I4H *=! 4:7!6 32nt 53N!GS, 4:7!6S,
134S3494*S, N36LS, N=I*! S891!S $ 3*=!6 1=9691*!6S");
printf("nn !nter a line of teRtn");
+ets(str+);
hile(&str+K%YY)
{
if(&str+%%U9UVV&str+%%U!UVV&str+%%UIUVV&str+%%U3UVV&str+%%U:UVV
&str+%%UaUVV&str+%%UeUVV&str+%%UiUVV&str+%%UoUVV&str+%%UuU)
0o@@;
else if(&str+>%M- $$ &str+%W/ $$ &str+%E? $$ &str+
8/10/2019 07 g 108 c Programming Laboratory.psb
54/57
s@@;
else if(&str+>% $$ &str+
8/10/2019 07 g 108 c Programming Laboratory.psb
55/57
". Is it etter to use a macro or a functionL
%. Is there anthing ou can do in $ that ou cannot do in $ L
+. What is indirectionL
. 4ell me the difference et0een strdup and strcpL
. What use of structure and unionL
http://www.coolinterview.com/interview/1026/http://www.coolinterview.com/interview/15128/http://www.coolinterview.com/interview/1011/http://www.coolinterview.com/interview/14254/http://www.coolinterview.com/interview/12318/http://www.coolinterview.com/interview/1026/http://www.coolinterview.com/interview/15128/http://www.coolinterview.com/interview/1011/http://www.coolinterview.com/interview/14254/http://www.coolinterview.com/interview/12318/8/10/2019 07 g 108 c Programming Laboratory.psb
56/57
:. #TRING L"NGT6 9 COPY U#ING POINT"R
OB"CTI"3
4o find the length of the string and to cop it to another string using pointer.
#OURC" CO"3
#include
#include
main()
{
char o_arrOP,&d_arr;
int len%;clrscr();
printf("nntS*6I4H G!4H*= $ 138I4H 2:41*I34S :SI4H 83I4*!6");
printf("nn !nter the ori+inal array");
+ets(o_arr);
d_arr%o_arr;
printf("nn ori+inal array s",o_arr);
printf("nn duplicate arrays",d_arr);
hile(&d_arrK%UU)
{
len@@;
d_arr@@;
printf("nn len+th of the strin+ d",len);
+etch();
8/10/2019 07 g 108 c Programming Laboratory.psb
57/57
INPUT 9 OUTPUT 3
S4RIN M5N4? G $@P:IN #7N$4I@NS 7SIN P@IN45R
5nter the original arra6 hi ho0 are uL
original arra 6 hi ho0 are uL
duplicate arra6 hi ho0 are uL
length of the string 6 1%
iva6
1. 0hat is the difference et0een the functions memmove(! and memcp(!L
". Write a code for implementation of doul lin-ed list 0ith use of single pointer in each node
%. When should the register modifier e usedL Eoes it reall helpL
+. ?o0 do ou use a pointer to a functionL
. What is a null pointerL
http://www.coolinterview.com/interview/15146/http://www.coolinterview.com/interview/5977/http://www.coolinterview.com/interview/1059/http://www.coolinterview.com/interview/1004/http://www.coolinterview.com/interview/1009/http://www.coolinterview.com/interview/15146/http://www.coolinterview.com/interview/5977/http://www.coolinterview.com/interview/1059/http://www.coolinterview.com/interview/1004/http://www.coolinterview.com/interview/1009/