File of C Programming
File of C Programming
Programming
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
else
if((avg>33)&&(avg<45))
printf("\nThird divisoin");
else
printf("Fail");
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the num=");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("%d%d",a,b);
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
circumference of circle//
#include<stdio.h>
#include<conio.h>
void main()
{
int c,n,l,b,p,a;
float ar,r;
clrscr();
printf("Press below values for operation's: \n");
printf("1.Rectengle\n");
printf("2.Circle\n");
printf("Enter the choice: ");
scanf("%d",&n);
if(n==1)
{
printf("Enter the Length & Breadth for Area & Perimeter of
Rectangle: ");
scanf("%d%d",&l,&b);
a=l*b;
printf("\nArea of Rectangle is : %d",a);
p=2*(l+b);
5
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter the num=");
scanf("%d",&n);
if(n%2==0)
printf("even");
else
printf("odd");
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int year;
clrscr();
printf("Enter the year=");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
printf("%d is a leap year",year);
else
printf("%d is not leap year",year);
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int h,s,m;
clrscr();
printf("Enter the Second=");
scanf("%d",&s);
m=s/60;
h=s/3600;
printf("h=%d,m=%d,s=%d",h,m,s);
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
printf("%d\t",i*j);
}getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=6;i++)
{
for(j=6;j>i-1;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output:
11
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
void main()
{
int n,r,p,s=0;
clrscr();
printf("Enter the number=");
scanf("%d",&n);
p=n;
while(n>0)
{
r=n%10;
printf("The value of r is%d\n",r);
n=n/10;
printf("The value of n is%d\n",n);
s=s*10+r;
printf("The value of s is%d\n",s);
printf("---------------------\n");
}
printf("%d%d",p,s);
if(p==s)
printf("\n number is palindrome %d",s);
13
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
else
printf("not");
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
void main()
{
int i,n,r;
clrscr();
n=1234;
while(n>0)
{
r=n%10;
printf("%d",r);
n=n/10;
}
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
void main()
{
char a;
clrscr();
printf("enter the value=");
scanf("%c",&a);
printf("ASCII=%d",a);
getch();
}
Out put
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
{ int n,r,s=0,p;
clrscr();
printf("enter the num=");
scanf("%d",&n);
p=n;
while(n>0){
r=n%10;
n=n/10;
s=s+(r*r*r); }
if(s==p)
printf("Num Is Armstronge");
else
printf("Not");
getch();
}Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
int fact(int);
void main()
{ int a,b;
clrscr();
printf("enter the num=");
scanf("%d",&a);
b=fact(a);
printf("factorial %d",b);
getch(); }
int fact(int n)
{ if(n==1)
return(1);
else
return(n*fact(n-1)); }
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int a=0,b=1,c;
clrscr();
while(a<20)
{
c=a+b;
printf("%d\n",a);
a=b;
b=c;
}
getch();
}Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<math.h>
void main()
{
int n,s=0,p;
clrscr();
printf("Enter The Num");
scanf("%d",&n);
printf("Enter The Value For Power");
scanf("%d",&p);
s=pow(n,p);
printf("%d",s);
getch();
}
Output:
20
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int num,i;
clrscr();
printf("enter the num");
scanf("%d",&num);
i=2;
while(i<=num-1)
{
if (num% i==0)
{
printf("not prime num");
break;
}
i++;
if(num% i==0)
printf("prime num");
}
getch();
}
21
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
Output:
// wap to ask the user for a number . print the square of the number
and user want to continue or not //
#include<stdio.h>
22
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<conio.h>
void main()
{
int a=2,b,n;
clrscr();
while(a<=10)
{
b=a*a;
printf("%d\t",b);
a=a+1;
printf("\n");
printf("Do You want to Continue?");
scanf("%d",&n);
if(n==1)
continue;
else
exit(0);
}
getch();
}
Output:
23
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,l,k;
clrscr();
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
{
printf(" ");
}
for(l=1;l<=i;l++)
{
printf("%d",l);
}
for(k=i-1;k>=1;k--)
{
printf("%d",k);
}
printf("\n");
}
25
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
getch();
}
Output:
BCA 1
ST
SEM
ROLL NO.140025011050
Programming
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
float sum=0.00;
clrscr();
printf("enter the valueof n=");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+(float)i/((i*2)+1);
}
printf("sum of harmonic series=%f",sum);
getch();}
Output:
27
BCA 1
ST
SEM
ROLL NO.140025011050