0 ratings 0% found this document useful (0 votes) 22 views 17 pages Lab On C Programming
The document outlines a lab syllabus for a C Programming course at SMT. G. G. Khadse College, detailing various programming exercises including input/output operations, control statements, operators, and functions. It includes specific tasks such as checking for palindromes, generating Fibonacci series, and demonstrating array concepts.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Carousel Previous Carousel Next
Save Lab on C Programming For Later SMT. G. G. KHADSE COLLEGE, MUKTAINAGAR.
Semester-|
BCA-107 Lab on C Programing - I
INDEX
Ex ‘| Page
Nol Title | B*| Date |Remark
T| Write programm for i” Z
: s
2) Unformatted input output statements like getchar), putchar), gets), Za
puts) Be
eee ae ae ens
Also study various format String and sequence characters.
2 | Write a program to ilustrate vi
s operators Hike
a) Arithmetic operator
| »b) increment / deerement operator
«) Conditional operator
4) sizeof operator
3 | Write a program (o illustrate various control statements
ait
b) ifelse : |
©) nested if-else
é) switch 4
4 | Write a program to illustrate various control statements
| 8) while loop
») do...while loop
€) for loop
3
‘Write a program to sheck whether the number is palindrome or not.
7 -
_° | Write a program to check whether the number is Armstrong or not.
4 - bic
Write a program to generate Fibonacci series up to given term,
rs ; 7
| | Write a program to find factorial of given number.
°) write a program for print the table of 1 to 5 using nested loop.
10 sh
Write a program to check Whether the string is palindrome or not,
11 | Write a program (o demonstrate concept of array,
1a) One-dimensional
b) Multi-dimensional
12| Write a program to demonstrate various standard library functions,
Siting functions - stlen(, strepy(, streat(),strempQ
Batch In-charge oY Head of Department/* Program for Unformatted i "
foe ‘ted input output getchar() and putchar() */
include
void main()
‘ chareh:
clscr();
printf("enter a charcter
thar);
printfi"\n display a character :
putehan(ch);
getch():
}
[AAeeeuaAA Se eeAOUTPUTHAAHAAneeHEetn
center a charcter :a
display a characte
seheaaunenssseineneteananuneniny
‘Program for Unformatted input output gets) and puts() */
include
include
void main()
charch[S0};
clrser):
Printf("Enter Message : ");
gets(ch);
printf("your Message is
puts(ch), .
getch0;
}
[stseaneeenns¢QUTPUTHHithanenees
‘enter your name: Welcome to Learn C Programming Language
your name is : Welcome to Learn C Programming Language
Ststsecsnstetauanannadannaeenaneny
#/Program for formatted input output printf() and scanf()
include
lude
Void main()
{
int a,badd;
clrser();
print{(*\nEnter the value for a
scanfi"96d", 8a);
printf("\nEnter the value for b"
8b);
printf" the addition is %d"add);
etch ();
}
[tsasesscananeansuannarssQUTPUTHTeetnenninnn
Enter the value fora 10
Enter the value for b 20
the addition is 30Write a program to illustrate various operators like
a) Arithmetic operator
Hinclude
#include
void main)
include
include
void main()
{
inta,b,add,sub,mult,div;
elrser():
printf(“enter the value for a");
scanf{"%d",&a);
printf("enter the value for b");
scanf("%d",&b);
printf("\n the addition of %d",add);
printf("\n the subtractions of %d",sub);
printf("wn the multiplication of %d" mult;
printf("in the division of %od",div)s
etch 0;
}
[eehaeaaannnuneaaQUTPUTMittntieneeensnanuensnnes/
enter the value for a 5
enter the value for b 10
the addition of 15
the subtractions of -5
‘the multiplication of 50
the division of 0
[iheineneseennenennannanseneneenennniaenanenentn]
/*Write a program to illustrate various operators like
(b) Increment (Decrement operator*/
include
include
void main()
int,
lrser(;
nel;
do
(
Printf("\n Yd");
}
while(n=5); 4
yeh:
Whsansnusasaneuenee QUTPUTM A) HEnaHeAH]
1
2
3
4
[Meenentenanuenenauneniennannannnnnanenns)/*Write a program to illustrate various operators like
C)Conditional Operator
include
Hinclude
void main()
{
int age;
clrser();
printf("\n enter your age
seanf("%d" &age);
(age>=18)?
printf("you can vote’
printf("you can't vote");
getch0;
[seeeeseeseeseeeQUTPUTHeteeeetttansseensseesy
enter your age :23
you can vote
[PetNANeN ee eeeecceeennennnennetnenettesettese]
1 Write a program to illustrate various operators
4) sizeof operator*/
#include
include
void main,
{
ccharch;
inta; .
float b;
elrseri
printf(°\n size of character variable is %d",sizeof (ch));
printf(*\n size of integer variable is %d" sizeof (a));
printf(*\n size of float variable is %d" sizeof (b));
getchQ);
,
[heeetsuaaannnaaasenneeehhQUTPUp pee eniinniaenneeannnecaannn
size of character variable is 1
size of integer variable is 2
size of float variable is 4
MARR AAaRCERTAAAARASERRESAIA ERAN AE RENAN RRM MMH ERR NKIMrite a program to illustrat
a) if
Hinclude
#inelude
void main()
{
fe various control statements
printf("Enter your mark");
seanf("%d",& marks);
iflmarks>=24)
printf(“congratulation you hav passed");
getch0;
petbaenneneeaeenneeeee2QU
Enter your mark 25
ITPUT#AARKAAeRRneeR nee)
congratulation you hav passed
JHenshankanhnintinieeeaennenmnnnns nanan]
INWrite a program to illustrate various controbstatements
(jifelse
Hinclude
include
void main()
t
mark;
elrserQ);
printf("Enter your mark")
seanf("%d", 8 mark);
iffmarte
printf("congratulation you
else
printf("sorry your exam i
getch(;
}
a
u hav passed");
in failed”)
[ebeuneevasensenaseQUTPUTeatsteanedpipaannnsssanes
Enter your mark23
sorry your exam in failed
leunnaeTonnanuannennettnyWrite a program to illustrate v:
(oNested if rate various control statements
include
include
void main()
intijs
clrser();
forti=
{
for j=
{
printf("\n %d\t%d" ij);
}
}
getch();
sit)
=2;j+4)
}
[ticoiiianisneeee OUTPUT nines
1
snow
1
2
2
3
3
2
SE Ei SII IIEa program to illustrate various control statements
itch case
include
#include
void main()
{
int da
clrser()
printf("Enter a day");
3
scanf{"%d",&day);
switeh(day)
t
case |
printf("sunday");
break;
case 2:
printf("monday");
break;
case 3:
printf("thusday");
break;
case 4:
printf("wednesday");
break;
case 5:
printf("thursday"
break;
case 6:
printf("frida
break;
case 7:
printf("saturday");,
break;
default:
printf("enter validechoise");
}
getch();
[peneeanansnenesas QUTPUTHyprenagatenunnn
Entera day 4
wednesday
shanssacanaanenannnannnnnan ninsnannnnn nd]Write a program to illustrate v
(a) while loop
include
include
void main()
{
{
printf¢"in %d"n);
nH;
}
geteh(s
}
petaneenneeeeneet QUTPUTIAHIRARaAAN
1
2
3
4
5
AMRAMOARRRnAAaaRananeRRReeRRRe EER]
Write a program to illustrate various control statements
(b) Do while loop
Hinelude
‘include
void main)
t
int a;
elrser(; «
do
t
printf("\n %d" a);
3
while(a<=5);
etch
easnasssnnseceensnQUrpuTuessstseetennnny
1
2
3
‘
$
Henenenanannuanennainan nie nin nnn ane na nnn]iMrite a program to illustrate various control statements
(©) For loop
#include
#include
void main)
co,
int ns
for(n=1jn<=5;n++)
{
printf("\n %od",n);
3
getch;,
[Jedoccocekescek UTP THHs aiken]
1
2
3
4
5
[HERA aaa RRR]7
Lb
siwrite a programme to check whether given number is pallindrome or not
finelude
winclude
void main()
{
while(n!=0)
d=n%10;
P=(p*10)+d;
n=n/l0;
printf("%6d This is palindrome="
printf("%d This is not palindrome=",i);
3
getchOs
freeeeneersoutputeeete
Enter any number=12321
12321 This is palindrome=
sensenesenensesanssasnesebasseseeneeesuceneseneseneneesenses/
Iiwrite a programme to check whether given number is amstrong or not.
Hinclude
#include
void main() .
intnum,temp.cem,sum=0;
clrser)
print("\nEnter any number=";
scanf("%d" Senum);
while(num>0)
{
rem=num%10;
sum=sum+(rem*rem*rem);
‘num=num/10;
d
Htaan—temp)
print{("\WThis is amstrong number ");
printf("InThis is not amstrong number ");
y_ Betehs
Poeenen reneee!
sevevenessQuTPUT?
Enter any number=153
STE AaIONg UBT snevencoes
eeeeneneeey‘write a program ti print Fibonacci series,
Hinelude
#include
void main()
t
intn,i,sum=0,F=0,s=1;
clrser();
printf("\nEnter any number uptofibonaccie serie
scanf("%d'" &n);
printf("\nFibonaccie series upto %di
printf("\n0");
for(i=l:i
#include
void main()
intn,i,fact=1;
clrser();
print(("\nEnter any number=");
seanf("¥%ed",8n);
while(>=1)
i ,
fact=fact*i;
} vecmoch
printf"\nFactrocial=%d" fact);
yates
[setsenesenszoutputttenteet
Enter any number=6
Factrocial=720
eneseneneousseedtonecnssensennenens//*Write a program for print the tabl 1
Reine Pp table of 1 to 5 using nested loop*/
#include
void mainQ)
lrser();
for(i=1; i<=10; +4)
{
num=
Printf("%di\t",(num*}));
printf("\n");
}
getch0;
Pebeoriniaaceetg tpt nininii tana ta ae
Jesu d: =,
a. Oy 30)
came ee 2h |S
8 ie We ay
10 15 20 25
12 18 24 30
ae ieeeo
16 24 32 40
ise 7sOme 4s
10 20 30 40 50
Taran eA SIE ETO A LATA AAAS
weIAUEEne/* Write a program to check whether the string is palindrome or no */
include
include
include
void main()
4
char st (20);
int i,lentemp=0.flag=0;
(
io nen
temp=;
break;
)
}
‘f{temp—=0)
printfa the sting is palindrome");
else
‘rint("w the string is not palindrome");
etch;
lanerestenneeneuanneantnenety
lutstensenenananansunenene
center a string: radar
the string is palindrome
{he Sine i Pe ne icereteneesCcunswnsunewnnncnvannsnnsunenes]write a program to demonstrate concept of array
a) One-dimensional */
#include
#include
void main()
{
int a5),
clrscr();
printf("in enter array 5 elemen
for(i=0; i
#include
void main()
int a3][3}i
clrser();
printf("\nEnter the elements for array a: ");
for(i-O;i<3ii++)
{
for(im0j<3jt+)
{
Sean Sal
)
printf("nThe entered elements for array a is \n");
forli=Q:i<3;i++)
: for(=0j3 +4)
{nt %a" ali;
prin";
met
[neeonseneesoutputt®
Enter the elements for array a:
123
456
789
‘The entered elements for aah } is
123
456
789
aseesnenesy/‘/Awrite a program to demonstrate various standard library functions
a)funetion(strlen) */
#include
+#include
#include
void main()
{
char name(30];
int len;
printf("\n enter a string :");
scanf{"%6s" name);
len=strlen(name);
printf("wn the length of string is %d",len);
etch);
Jeteteeeeettetoutputttiteaniets
enter a string : computer
the length of string is 8
[Program finished]
Fintieniierresbiatniietananen
/* byfunction(strepy) */
#include
include
include
void main)
{
char source{30],dest[30];
lrser();
printf("\n enter the source string :");
seanf("%s" source);
strepy(dest,source);, ri
printf("n the source string is copi
etch;
in destination : %s" dest);
Jetseesestenteeasunaateesqutputteenintesnitessnnee
center the source string : computer
the source string is copied in destinatior‘/e)funetion(streat) */
include
include
include
void main()
char source{}=" Department "destination{}="Computer";
cliser();
strcat(destination,source);
printf("concatenated string is %s" destination);
getch();
[itvaesnanenseraneeneensQUTPUT#netetneninannes
atenated string is ComputerDepartment
etntttnetirnneesereenitinuancenenneneseanth)
/*@) fanction(stremp) */
include
include
include
‘void main()
{
char string] []="spark’,string2(]="computerdepartment";
intemp;
cemp=stremp( string] string2);
iffemp>0)
rint("%s > %s" tring string2);
else
{
iffemp<0)
rintf("%6s < %s" string string2),
else
prints » %s" string] string2);
)
etch;
[nveeenenenssQUTPUTHCHseeenee
spark > computerdepartment
Stetessesatansesnentanresnenets)