Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
ASCII Code Calculator
ASCII Code Calculator
void main()
{
char c,d;
clrscr();
printf("t enter a character::::");
c=getchar();
printf("nnt ASCII code is ::::%d",c);
printf("nndo you want to continue ...
press1.... else 0");
d=getch();
if(d==1)
{
main();
}
else
{
exit(0);
}
getch();
}
Source Code
1
void main()
{
long int n,i,c,d;
clrscr();
printf("Enter your number::");
scanf("%ld",&n);
printf("your number is::%ldn",n);
i=1;
while(i<=10)
{
c=i*n;
printf("%ld*%ld=%ldn",n,n,i,d);
i++;
}
printf("nn do yo want to contiune
...press1..else0..");
d=getch();
if(d=='1')
{
main();
}
else
{
exit(0);
}
getch();
}
Table Calculator
Table Calculator
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
2
Decimal To Binary Calculator
void main()
{
int[20],c=0,n,m=0,i,d;
clrscr();
printf("enter a decimal number
between (1- 32767):");
scanf("%d",& n);
while(n>0)
{
m=n%2;
a[c]=m;
n=n/2;
c++;
}
c--;
for(i=c;i>=0;i--);
{
printf("%d",a[i]);
}
getch();
}
Decimal to Binary calculator
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
3
Standard Calculator
Standard Calculator
void main()
{
int a,b,c;
char r,o;
clrscr();
printf("Standard Calculator.n");
gotoxy(10,4);
scanf("%d",&a);
gotoxy(15,4);
o=getche();
gotoxy(20,4);
scanf("%d",&b);
if(o=='+')
{
c=a+b;
}
if(o=='-')
{
c=a-b;
}
if(o=='*')
{
c=a*b;
}
if(o=='/')
{
c=a/b; }
gotoxy(15,8);
printf("%d",c);
getch();
}
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
4
Color Grid Printer
Color Grid Printer
void main()
{
int i,j,d;
clrscr();
for(i=1;i<=600;i++)
{
if(i%40==0)
{
printf("n");
}
else
{
textbackground(j);
cprintf(" ");
j++;
}
if(j==7)
{
j=1;
}
}
getch();
}
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
5
Power calculator
Power Calculator
void main()
{
int n,p,s,i,e;
clrscr();
gotoxy(10,2);
printf("number");
gotoxy(10,4);
scanf("%d",&n);
gotoxy(20,2);
printf("power");
gotoxy(20,4);
scanf("%d",&p);
s=1;
for(i=1;i<=p;i++)
{
s=s*n;
}
gotoxy(15,6);
printf("%d",s);
getch();
}
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
6
Palindrome Calculator
Palindrome Calculator
void num_palin()
{
int n,p=0,t,m;
clrscr();
printf("enter a number==");
scanf("%d",&n);
t=n;
while(t>0)
{
m-t%10;
p=p*10+m;
t=t/10;
}
if(p==n)
{
printf("palindrome");
}
else
{
printf("not
palindrome");
}
}
void main()
{
num_palin();
getch();
}
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
7
Alphabet Calculator
void main()
{
int i,j,r;
char c;
clrscr();
printf("alphabet in upercase press1..n
alphabet in lowercase press 2");
c=getch();
printf("nnn");
if(c=='1') [
printf("your case is uppercase
nnn");
for(j=65;j<=90;j++)
{
delay(50);
printf("%c
t",j);
}
}
else if(c=='2') {
printf("your case is lowercase
nnn");
for(j=97;j<=122;j++)
{
delay(50);
printf("%c
t",j);
}
}
else {
printf("wrong input"); }
Source Code
Alphabet Calculator
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
8
Armstrong Calculator
void main()
{
int n,t,t1,p=0,i,c=0,m=0,a=0,w;
clrscr();
printf("enter a limit::");
scanf("%d",&n);
for(i=1;i<=1;i++)
{
i++; }
n=i;
t=n;
t1=n;
c=0;
m=0;
a=0;
p=0;
i=0;
while(t1>0)
{
i++;
t1=t1/10;
}
while(t>0)
{
m=t%10;
p=pow(m,i);
a=a+p;
t=t/10;
}
}
Armstrong Calculator
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
9
Prime Number Calculator
Prime number calculator
void main()
{
int i,n,c=0;
clrscr();
printf("enter a number=");
scanf("%d",&n);
for(i=1;1<=n;i++)
{
if(n%i==0)
{
c++;
}
}
if(c==1||c==2)
{
printf("prime");
}
else
{
printf("not prime");
}
getch();
}
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
10
Text Printer
void main()
{
char a[]="This is Dezyne E'cole College";
int i,l,g=1,m;
clrscr();
l=strlen(a);
for (i=0,i<1;i++);
{
delay(300);
textcolor(g);
cprintf("%c",a[1]);
if(g=5)
{
g=1;
}
g++;
}
printf("nn do you want to continue press 1...else 0");
m=getch();
if(m=='1')
{
main();
}
else
{
exit(0);
}
getch();
}
Text Printer
Source Code
Rahul Saini
Bachelor of Computer
Application 1st Year
Dezyne E’cole College
www.dezyneecole.com
11

Bca 1st year C langauge .pdf

  • 1.
    Rahul Saini Bachelor ofComputer Application 1st Year Dezyne E’cole College www.dezyneecole.com ASCII Code Calculator ASCII Code Calculator void main() { char c,d; clrscr(); printf("t enter a character::::"); c=getchar(); printf("nnt ASCII code is ::::%d",c); printf("nndo you want to continue ... press1.... else 0"); d=getch(); if(d==1) { main(); } else { exit(0); } getch(); } Source Code 1
  • 2.
    void main() { long intn,i,c,d; clrscr(); printf("Enter your number::"); scanf("%ld",&n); printf("your number is::%ldn",n); i=1; while(i<=10) { c=i*n; printf("%ld*%ld=%ldn",n,n,i,d); i++; } printf("nn do yo want to contiune ...press1..else0.."); d=getch(); if(d=='1') { main(); } else { exit(0); } getch(); } Table Calculator Table Calculator Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 2
  • 3.
    Decimal To BinaryCalculator void main() { int[20],c=0,n,m=0,i,d; clrscr(); printf("enter a decimal number between (1- 32767):"); scanf("%d",& n); while(n>0) { m=n%2; a[c]=m; n=n/2; c++; } c--; for(i=c;i>=0;i--); { printf("%d",a[i]); } getch(); } Decimal to Binary calculator Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 3
  • 4.
    Standard Calculator Standard Calculator voidmain() { int a,b,c; char r,o; clrscr(); printf("Standard Calculator.n"); gotoxy(10,4); scanf("%d",&a); gotoxy(15,4); o=getche(); gotoxy(20,4); scanf("%d",&b); if(o=='+') { c=a+b; } if(o=='-') { c=a-b; } if(o=='*') { c=a*b; } if(o=='/') { c=a/b; } gotoxy(15,8); printf("%d",c); getch(); } Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 4
  • 5.
    Color Grid Printer ColorGrid Printer void main() { int i,j,d; clrscr(); for(i=1;i<=600;i++) { if(i%40==0) { printf("n"); } else { textbackground(j); cprintf(" "); j++; } if(j==7) { j=1; } } getch(); } Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 5
  • 6.
    Power calculator Power Calculator voidmain() { int n,p,s,i,e; clrscr(); gotoxy(10,2); printf("number"); gotoxy(10,4); scanf("%d",&n); gotoxy(20,2); printf("power"); gotoxy(20,4); scanf("%d",&p); s=1; for(i=1;i<=p;i++) { s=s*n; } gotoxy(15,6); printf("%d",s); getch(); } Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 6
  • 7.
    Palindrome Calculator Palindrome Calculator voidnum_palin() { int n,p=0,t,m; clrscr(); printf("enter a number=="); scanf("%d",&n); t=n; while(t>0) { m-t%10; p=p*10+m; t=t/10; } if(p==n) { printf("palindrome"); } else { printf("not palindrome"); } } void main() { num_palin(); getch(); } Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 7
  • 8.
    Alphabet Calculator void main() { inti,j,r; char c; clrscr(); printf("alphabet in upercase press1..n alphabet in lowercase press 2"); c=getch(); printf("nnn"); if(c=='1') [ printf("your case is uppercase nnn"); for(j=65;j<=90;j++) { delay(50); printf("%c t",j); } } else if(c=='2') { printf("your case is lowercase nnn"); for(j=97;j<=122;j++) { delay(50); printf("%c t",j); } } else { printf("wrong input"); } Source Code Alphabet Calculator Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 8
  • 9.
    Armstrong Calculator void main() { intn,t,t1,p=0,i,c=0,m=0,a=0,w; clrscr(); printf("enter a limit::"); scanf("%d",&n); for(i=1;i<=1;i++) { i++; } n=i; t=n; t1=n; c=0; m=0; a=0; p=0; i=0; while(t1>0) { i++; t1=t1/10; } while(t>0) { m=t%10; p=pow(m,i); a=a+p; t=t/10; } } Armstrong Calculator Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 9
  • 10.
    Prime Number Calculator Primenumber calculator void main() { int i,n,c=0; clrscr(); printf("enter a number="); scanf("%d",&n); for(i=1;1<=n;i++) { if(n%i==0) { c++; } } if(c==1||c==2) { printf("prime"); } else { printf("not prime"); } getch(); } Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 10
  • 11.
    Text Printer void main() { chara[]="This is Dezyne E'cole College"; int i,l,g=1,m; clrscr(); l=strlen(a); for (i=0,i<1;i++); { delay(300); textcolor(g); cprintf("%c",a[1]); if(g=5) { g=1; } g++; } printf("nn do you want to continue press 1...else 0"); m=getch(); if(m=='1') { main(); } else { exit(0); } getch(); } Text Printer Source Code Rahul Saini Bachelor of Computer Application 1st Year Dezyne E’cole College www.dezyneecole.com 11