Programs
Programs
Program 1
// Print Statements
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf ("Welcome to C World");
getch();
return 0;
}
Program 2
// Output Statements using escape sequences
// /n /t /a // /? /' /" /b
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf ("Welcome to C World");
printf("\n C Escape Sequences ");
getch();
return 0;
}
Program 3
// Output Statements using gotoxy function
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
gotoxy(40,5);
printf ("Welcome to C World");
gotoxy(40,6);
printf(" C Escape Sequences ");
getch();
return 0;
}
2
Program 4
// Example for simple if Statements
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int sno;
printf("\n Enter student Number..");
scanf("\n %d",&sno);
if (sno==100)
printf("Record Existed");
getch();
return 0;
}
Program 5
// Example for simple if Statements with blocks
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int sno;
printf("\n Enter student Number..");
scanf("\n %d",&sno);
if (sno==100)
{
printf("Record Existed");
printf("\n He is student in NRI");
}
getch();
return 0;
}
3
Program 6
/* Example program for if-else
Printing Biggest number from two inputs */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers ..");
scanf("\n %d%d",&a,&b);
if (a>b)
printf("\nBig is =%d",a);
else
printf("\nBig is %d",b);
getch();
return 0;
}
Program 7
/* Example program for if-else
Printing Biggest integer from three inputs */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c;
printf("\n Enter two integers ..");
scanf("\n %d%d%d",&a,&b,&c);
if ((a>b) && (a>c))
printf("\nBig is =%d",a);
else
if ((b>a) && (b>c))
printf("\nBig is %d",b);
else
printf("\n Big is %d",c);
getch();
return 0; }
4
Program 8
/* Example program for if-else
Printing Biggest integer from Four inputs */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c,d;
printf("\n Enter two integers ..");
scanf("\n %d%d%d%d",&a,&b,&c,&d);
if ((a>b) && (a>c) && (a>d))
printf("\nBig is =%d",a);
else
if ((b>a) && (b>c) && (b>d))
printf("\n Big is %d",b);
else
if ((c>a) && (c>b) && (c>d))
printf("\n Big is %d",c);
else
printf("\n Big is %d",d);
getch();
return 0;
}
5
Program 9
/* Nested If Example 1
Caluculating Student Results */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int sno,m1,m2,m3,tot;
char htno[15],sna[15],res,div;
float avg;
printf("Enter Student Number...");
scanf("\n %d",&sno);
printf("\n Enter Student name..");
scanf("\n %s",&sna);
printf("\n Enter Marks in Three Subjects..");
scanf("\n %d %d %d",&m1,&m2,&m3);
tot=m1+m2+m3;
avg=tot/3;
if ((m1>=50) && (m2>=50) && (m3>=50))
{
res='P';
if (avg>=75)
div='D';
else
if (avg>=60)
div='F';
else
div='S';
}
else
{
res='F';
div='N';
}
clrscr();
printf("Student Number = %d",sno);
printf("\n Student name =%s",sna);
6
Program 10
/* Electricity Bill Generation type1
Example 2 for Nested if */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int cno,nu;
char code,cna[30];
long int lmr,cmr;
float ba,nb;
printf("\n Enter Consumer Number..");
scanf("\n %d",&cno);
printf("\n Enter Consumer Name..");
scanf("\n %s",&cna);
printf("\n Enter Last Month Meter Reading..");
scanf("\n %ld",&lmr);
printf("\n Enter Current Month Meter Reading..");
scanf("\n %ld",&cmr);
printf("\n Enter Code D/B/I ...");
scanf("\n %c",&code);
nu=cmr-lmr;
if ((code=='d') || (code=='D'))
{
if (nu<=100)
ba=nu*1.20;
else
if (nu<=200)
ba=nu*1.40;
else
if (nu<=300)
ba=nu*1.60;
else
ba=nu*1.75;
}
Else
8
if ((code=='b') || (code=='B'))
{
if (nu<=100)
ba=nu*1.50;
else
if (nu<=200)
ba=nu*1.90;
else
if (nu<=300)
ba=nu*2.20;
else
ba=nu*2.75;
}
else
{
if (nu<=100)
ba=nu*1.70;
else
if (nu<=200)
ba=nu*2.10;
else
if (nu<=300)
ba=nu*2.60;
else
ba=nu*3.75;
}
clrscr();
printf("\n Consumer Number....%d",cno);
printf("\n Consumer Name..%s",cna);
printf("\n Number of Units..%d",nu);
printf("\n Code = %c",code);
printf("\n Bill Amount ..%.2f",ba);
nb=ba+ba*10/100;
printf("\n Net Bill Amount..%.2f",nb);
getch();
return 0;
}
9
Program 11
/* Electricity Bill Generation type2
Example 3 for Nested if */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int cno,nu;
char code,cna[30];
long int lmr,cmr;
float ba,nb;
printf("\n Enter Consumer Number..");
scanf("\n %d",&cno);
printf("\n Enter Consumer Name..");
scanf("\n %s",&cna);
printf("\n Enter Last Month Meter Reading..");
scanf("\n %ld",&lmr);
printf("\n Enter Current Month Meter Reading..");
scanf("\n %ld",&cmr);
printf("\n Enter Code D/B/I ...");
scanf("\n %c",&code);
nu=cmr-lmr;
if ((code=='d') || (code=='D'))
{
if (nu<=100)
ba=nu*1.20;
else
if (nu<=200)
ba=(100*1.20)+(nu-100)*1.40;
else
if (nu<=300)
ba=(100*1.20)+(100*1.40)+(nu-200)*1.60;
else
ba=(100*1.20)+(100*1.40)+(100*1.60)+(nu-300)*1.75;
}
10
else
if ((code=='b') || (code=='B'))
{
if (nu<=100)
ba=nu*1.20;
else
if (nu<=200)
ba=(100*1.20)+(nu-100)*1.40;
else
if (nu<=300)
ba=(100*1.20)+(100*1.40)+(nu-200)*1.60;
else
ba=(100*1.20)+(100*1.40)+(100*1.60)+(nu-300)*1.75;
}
else
{
if (nu<=100)
ba=nu*1.20;
else
if (nu<=200)
ba=(100*1.20)+(nu-100)*1.40;
else
if (nu<=300)
ba=(100*1.20)+(100*1.40)+(nu-200)*1.60;
else
ba=(100*1.20)+(100*1.40)+(100*1.60)+(nu-300)*1.75;
}
clrscr();
printf("\n Consumer Number....%d",cno);
printf("\n Consumer Name..%s",cna);
printf("\n Number of Units..%d",nu);
printf("\n Code = %c",code);
printf("\n Bill Amount ..%.2f",ba);
nb=ba+ba*10/100;
printf("\n Net Bill Amount..%.2f",nb);
getch();
return 0; }
11
Program 12
/* Nested If Example 4
Caluculating Employee Salary */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int eno;
char ena[30],code;
long int basic,hra,ta,da,pf,pt,gs,ns;
printf("\n Enter Employee Number..");
scanf("\n %d",&eno);
printf("\n Enter Employee Name..");
scanf("\n %s",&ena);
printf("\n Enter Employee Code (A/B/C)..");
scanf("\n %c",&code);
printf("\n Enter Basic Salary ..");
scanf("\n %ld",&basic);
if ((code=='a') || (code=='A'))
{
da=basic*40/100;
hra=basic*12/100;
ta=basic*10/100;
gs=basic+da+hra+ta;
pf=gs*10/100;
pt=gs*2/100;
ns=gs-(pf+pt);
}
else
12
if ((code=='b') || (code=='B'))
{
da=basic*42/100;
hra=basic*14/100;
ta=basic*12/100;
gs=basic+da+hra+ta;
pf=gs*12/100;
pt=gs*2/100;
ns=gs-(pf+pt);
}
else
{
da=basic*44/100;
hra=basic*16/100;
ta=basic*14/100;
gs=basic+da+hra+ta;
pf=gs*16/100;
pt=gs*2/100;
ns=gs-(pf+pt);
}
clrscr();
printf("\n Employee Number=%d",eno);
printf("\n Employee Name..=%s",ena);
printf("\n Employee Code..=%c",code);
printf("\n Employee Basic=%ld",basic);
printf("\n DA=%ld",da);
printf("\n HRA=%ld",hra);
printf("\n TA=%ld",ta);
printf("\n Gross Salary=%ld",gs);
printf("\n PF=%ld",pf);
printf("\n PT=%ld",pt);
printf("\n NetSalary=%ld",ns);
getch();
return 0;
}
13
Program 13
// Program to print natural numbers between 1 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
for (int i=1;i<=10;i++)
{
printf("\n %d",i);
}
getch();
return 0;
}
Program 13.1
// Program to print natural numbers between 1 to 10 using while loop
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int i=1;
while(i<=10)
{
printf("\n %d",i);
i++;
}
getch();
return 0;
}
14
Program 14
// Program to print even numbers between 0 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
for (int i=0;i<=10;i+=2)
{
printf("\n %d",i);
}
getch();
return 0;
}
Program 14.1
// Program to print even numbers between 0 to 10 using while
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int i=0;
while(i<=10)
{
printf("\n %d",i);
i+=2;
}
getch();
return 0;
}
15
Program 15
// Program to print odd numbers between 0 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
for (int i=1;i<=10;i+=2)
{
printf("\n %d",i);
}
getch();
return 0;
}
Program 15.1
// Program to print odd numbers between 0 to 10 using while
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int i=1
while(i<=10)
{
printf("\n %d",i);
i+=2;
}
getch();
return 0;
}
16
Program 16
// Program to print sum of natural numbers between 0 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0;
for (int i=1;i<=10;i++)
{
s=s+i;
}
printf("\n %d",s);
getch();
return 0;
}
Program 16.1
// Program to print sum of natural numbers between 0 to 10 using while
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0,i=1;
while(i<=10)
{
s=s+i;
i++;
}
printf("\n %d",s);
getch();
return 0;
}
17
Program 17
// Program to print sum of even numbers between 0 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0;
for (int i=0;i<=10;i+=2)
{
s=s+i;
}
printf("\n %d",s);
getch();
return 0;
}
Program 17.1
// Program to print sum of even numbers between 0 to 10 using while
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0,i=0;
while(i<=10)
{
s=s+i;
i+=2;
}
printf("\n %d",s);
getch();
return 0;
}
18
Program 18
// Program to print sum of odd numbers between 0 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0;
for (int i=1;i<=10;i+=2)
{
s=s+i;
}
printf("\n %d",s);
getch();
return 0;
}
Program 18.1
// Program to print sum of odd numbers between 0 to 10 using while
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0,i=1;
while(i<=10)
{
s=s+i;
i+=2;
}
printf("\n %d",s);
getch();
return 0;
}
19
Program 19
/* Printing natural numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
printf("\n %d",a);
}
getch();
return 0;
}
Program 19.1
/* Printing natural numbers between two integers
using while */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b)
{
printf("\n %d",a);
a++;
}
getch();
return 0;
}
20
Program 20
/* Printing even numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
if ((a%2)==0 )
printf("\n %d",a);
}
getch();
return 0;
}
Program 20.1
/* Printing even numbers between two integers.
using while loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b)
{
if ((a%2)==0 )
printf("\n %d",a)
a++;
}
getch();
return 0; }
21
Program 21
/* Printing odd numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
if ((a%2)!=0 )
printf("\n %d",a);
}
getch();
return 0;
}
Program 21.1
/* Printing odd numbers between two integers.
using while loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b)
{
if ((a%2)!=0 )
printf("\n %d",a);
a++;
}
getch();
return 0; }
22
Program 22
/* Printing sum of natural numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
s=s+a;
}
printf("\n %d",s);
getch();
return 0;
}
Program 22.1
/* Printing sum of natural numbers between two integers.
using while loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b )
{
s=s+a;
a++;
}
printf("\n %d",s);
getch();
return 0; }
23
Program 23
/* Printing sum of even numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
if ((a%2)==0)
s=s+a;
}
printf("\n %d",s);
getch();
return 0;
}
Program 23.1
/* Printing sum of even numbers between two integers.
using while loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b)
{
if ((a%2)==0)
s=s+a;
a++;
}
printf("\n %d",s); getch(); return 0; }
24
Program 24
/* Printing sum of odd numbers between two integers.
using for loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
if ((a%2)!=0)
s=s+a;
}
printf("\n %d",s);
getch();
return 0;
}
Program 24.1
/* Printing sum of odd numbers between two integers.
using while loop */
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,s=0;
printf("\n Enter two integers..");
scanf("\n %d%d",&a,&b);
while(a<=b)
{
if ((a%2)!=0)
s=s+a;
a++;
}
printf("\n %d",s); getch(); return 0; }
25
Program 25
// Printing Count of Digits from given Integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n,s=0;
printf("\n Enter Integer..");
scanf("\n %d",&n);
while(n>0)
{
s=s+1;
n=n/10;
}
printf("\n Count of Digits=%d",s);
getch();
return 0; }
Program 26
// Printing Sum of Digits from given Integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n,r,s=0;
printf("\n Enter Integer..");
scanf("\n %d",&n);
while(n>0)
{
r=n%10;
s=s+r;
n=n/10;
}
printf("\n Sum of Digits=%d",s);
getch();
return 0;}
26
Program 27
// Printing Reverse digits from given Integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n,r,s=0;
printf("\n Enter Integer..");
scanf("\n %d",&n);
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
printf("\n Reverse Digits=%d",s);
getch();
return 0;
}
Program 28
// Printing Biggest of Digits from given Integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n,r,s=0;
printf("\n Enter Integer..");
scanf("\n %d",&n);
while(n>0)
{
r=n%10;
if (r>s)
s=r;
n=n/10;
}
printf("\n Biggest Digit=%d",s); getch(); return 0; }
27
Program 29
// Printing Smallest digit from given Integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n,r,s=9;
printf("\n Enter Integer..");
scanf("\n %d",&n);
while(n>0)
{
r=n%10;
if (r<s)
s=r;
n=n/10;
}
printf("\n Smallest Digit=%d",s);
getch();
return 0;
}
Program 30
// Swaping two integer values with other variable
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c;
printf("\n Enter two integers...");
scanf("\n %d%d",&a,&b);
c=a+b;
a=c-a;
b=c-b;
printf("\n a=%d",a);
printf("\n b=%d",b);
getch();
return 0; }
28
Program 31
// Swapping two integers without extra variable
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c;
printf("\n Enter two integers...");
scanf("\n %d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("\n a=%d",a);
printf("\n b=%d",b);
getch();
return 0;
}
Program 32
// Lucky Number
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c,r,t,s;
printf("\n Enter Start Number..");
scanf("\n %d",&a);
printf("\n Enter Ending Number..");
scanf("\n %d",&b);
printf("\n Enter Lucky Number..");
scanf("\n %d",&c);
29
for(;a<=b;a++)
{
t=a;
s=0;
while(t>0)
{
r=t%10;
s=s+r;
t=t/10;
}
if (c==s)
printf("\n %d",a);
}
getch();
return 0;
}
Program 33
// Math.Table model 1
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a;
printf("\n Enter Math.Table..");
scanf("\n %d",&a);
for(int i=1;i<=10;i++)
{
printf("\n %d x %d = %d",a,i,a*i);
}
getch();
return 0;
}
30
Program 34
// Math.Table model 2
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,i,t;
printf("\n Enter star. End. Math.Table..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
for(i=1;i<=10;i++)
{
printf("\n %d x %d = %d",a,i,a*i);
}
getch();
clrscr();
}
getch();
return 0;
}
Program 35
// Math.Table model 3
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a,b,c,d,i,t;
printf("\n Enter star. End. Math.Table..");
scanf("\n %d%d",&a,&b);
printf("\n Enter star.End. numbers..");
scanf("\n %d%d",&c,&d);
31
for(;a<=b;a++)
{
for(i=1;i<=10;i++)
{
printf("\n %d x %d = %d",a,i,a*i);
}
getch();
clrscr();
}
getch();
return 0;
}
Program 36
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int n;
printf("Enter Number to convert");
scanf("\n %d",&n);
while(n>0)
{
printf("%d",n%2);
n=n/2;
}
getch();
return 0;
}
32
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a;
float b;
int c;
printf("\n Enter Integer value..");
scanf("\n %d",&a);
printf("\n Enter Float value..");
scanf("\n %f",&b);
c=a+int(b);
printf("\n %d",c);
getch();
return 0;
}
}
getch();
return 0;
}
40
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int t,a,b, s,r,n;
printf("\n Enter two two Integer..");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
t=0;
n=a;
while(n>0)
{
r=n%10;
s=1;
while(r>0)
{
s=s*r;
r--;
}
t=t+s;
n=n/10;
}
if (t==a)
printf("\n%d= %d",a,t);
}
getch();
return 0;
}
50
break;
}
default:
printf("\ninvalid");
}
}while(i<=3);
getch();
return 0;
}
72) do-while example 4
// do while example 4
#include<stdio.h>
#include<conio.h>
int a,b;
int main()
{
clrscr();
int i;
do
{
clrscr();
printf("\n 1.Add...");
printf("\n 2.Sub...");
printf("\n 3.Mul...");
printf("\n 4.Exit..");
printf("\n Enter Choice...");
scanf("\n %d",&i);
switch(i)
{
case 1:
{
printf("\n Enter two integers");
scanf("\n %d%d",&a,&b);
printf("\n Addition=%d",a+b);
getch();
clrscr();
break;
}
57
case 2:
{
printf("\n Enter two integers");
scanf("\n %d%d",&a,&b);
printf("\n Addition=%d",a-b);
getch();
clrscr();
break;
}
case 3:
{
printf("\n Enter two integers");
scanf("\n %d%d",&a,&b);
printf("\n Addition=%d",a*b);
getch();
clrscr();
break;
}
default:
printf("\ninvalid");
}
}while(i<=3);
getch();
return 0;
}
58
// do while example 4
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int i;
printf("\n Enter I value..");
scanf("\n %d",&i);
do
{
printf("\n i value =%d",i);
i++;
}while(i<=10);
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
for(int i=1;i<=10;i++)
{
if(i==3)
continue; //break
printf("\n %d",i);
}
getch();
return 0;
}
59
getch();
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int a=6; // ex: 0110
int b=3; // ex: 0011
79) x=12+22+32….
// power of integer
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int s=0;
int a,b;
printf("\n Enter two integers :");
scanf("\n %d%d",&a,&b);
for(;a<=b;a++)
{
s=s+a*a;
}
printf("\n sqares of a= %d",s);
getch();
return 0;
}
61
1 Algorithm
2 PSEUDOCODE
3 FLOWCHARTS
4 Program Development Steps
5 Introduction to “C” Language / Features, Advantages & Disadvantages
6 Structure of C Program
7 Character set
8 C Tokens or Constants
9 Backslash Constants
10 Variables or scope of variable
11 Precedence and order of Evaluation
12 Data Types
13 TYPE CONVERSIONS / TYPE CASTING
14 OPERATORS
15 Computer Languages
16 Language Translators (Compiler and Interpreter)
17 Input and Output Statements
18 Control Statement (if-else & Nested If Statements….)
19 Arrays
20 Functions
21 Local Variables and Global Variables
22 Storage Classes
23 Structures
24 Unions
25 Difference between Structure and Union
26 Pointers
27 BITFIELD
28 C PRE-PROCESSOR
29 Dynamic Memory Allocation
30 Header Files
62
1) Algorithm
Definition:
The word “algorithm” means “calculation method”. An algorithm is a finite list of well-defined
instruction. Algorithm means procedures for solving mathematical problems. An algorithm is
step-by-step explanation of a process. It consists of the logical steps necessary to solve a
problem in a computer.
Features of an algorithm:
Finiteness: An algorithm terminates after a fixed number of steps.
Definiteness: Each step of the algorithm is precisely defined.
Effectiveness: All the operations used in the algorithm can be performed exactly in a fixed
duration of time.
Input: An algorithm has certain precise inputs.
Output: An algorithm has one or more outputs.
Example 1:
Algorithm to pick the largest of three numbers.
Step 1: Read A, B, C.
Step 2: if A>B go to step 3.
Else go to step 5
Step 3: if A>C Print A is the largest number
Else Print C is the largest number.
Step 4: Stop.
Step 5: if B>C print B is the largest number.
Else print C is the largest number.
Step 6. Stop.
63
2) PSEUDOCODE
Pseudo Code is a problem Solving Tool. It is the first step in writing a program. It consists of
English like statements that follow a loosely defined syntax and are used to convey the design
of an algorithm. It is an intermediate step in writing a program. It is an aid in writing the
program. It comes from the English language description of a program. It helps to translate
from an English language description of a problem to a program written in a programming
language like C. The goal of writing Pseudo Code is to provide a high-level description of an
algorithm, which facilitates analysis and final coding. Algorithms will often be expressed in
Pseudo Code.
General guidelines for checking the Pseudo Code.
1) Mimic good code and good English. Variable names
be mnemonic, comments be included.
2) Ignore unnecessary details. Use some convention to
group statements (begin /end, brackets)
3) Take advantage of programming shorthand’s. Using if-
then-else or looping structures.
64
3) FLOWCHARTS
Flowchart is a program design tool .In flowcharts standard symbols are used to represent the
logical flow of data through a function. It is a computer-programming tool. The main purpose of
Flowchart is design of an algorithm. It is a pictorial representation of an algorithm. A Flowchart
is simply a method of assisting the programmer to layout in visual, two dimensional formats.
Uses of Flow Charts:
1) Flowcharts are an excellent means of communication and they impart ideas to others.
2) Flowcharts provide an overview of the entire problem and its algorithm for solution.
3) Flowcharts facilitate coding and modification of programs.
4) Flowcharts provide a permanent recording of program logic.
5) Flowcharts show all major elements and their relationships.
Problem Definition: Problem definition includes the specification of inputs and outputs
processing requirements, system constraints and error-handling methods. It includes many
factors such as input, output, time constraints, process requirements accuracy, memory
limitations, error handlings and interfaces.
Program Design: Flowcharting techniques are used in describing program structure. Program
design techniques are Flowcharting, top-down design, structured programming and modular
programming. In Modular programming, programs are divided into smaller programs or
modules. And in top-down design generalized subtasks that are subsequently defined.