Object: To Print The ASCII Codes of All The Alphapets. Source Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

Lab#04 F.

No#4497

Object: To print the ASCII codes of all the Alphapets.


Source Code:
//M.Babar//
//F.No. 4497//
//To print the ASCII codes of all the Alphapets//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a;
clrscr();

for(a=65;a<=90;a++)

printf("The ASCII codes of %c is : %d \n",a,a);

getch();
}
Output:

Computer Fundamentals & Programming 1


Lab#04 F.No#4497

Object: To print the Volume of the Cylinder.


Source Code:

//M.Babar//
//F.No. 4497//
//To print the Volume of the Cylinder//
#include<stdio.h>
#include<conio.h>
void main(void)
{
float radius,height,volume;
radius=2.5;
height=16.0;
volume=3.14216*radius*radius*height;
printf("The volume of cylinder is: %.2f ",volume);

getch();
}
Output:

Computer Fundamentals & Programming 2


Lab#04 F.No#4497

Object: To print a program that calculates the area of a circle.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that calculates the area of a circle //
#include<stdio.h>
#include<conio.h>
void main(void)
{
float A,R,Pi;
Pi=3.14216;

printf("The radius of the circle is :");


scanf("%f",&R);

A=Pi*R*R;
printf("The circumference if the circle is %.2f",A);
getch();
}
Output:

Computer Fundamentals & Programming 3


Lab#04 F.No#4497

Object: To print a program that converts the Fahrenheit into Celsius.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that converts the Fahrenheit into Celsius //
#include<stdio.h>
#include<conio.h>
void main(void)
{
float C,F;
printf("Enter tempreture in Fahrenheit:");
scanf("%f",&F);
C=5/9.0*(F-32);
printf("The tempreture in Celsius is : %.2f",C);
getch();
}

Output:

Computer Fundamentals & Programming 4


Lab#04 F.No#4497

Object: To print a program that converts the Celsius into Fahrenheit.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that converts the Celsius into Fahrenheit //
#include<stdio.h>
#include<conio.h>
void main(void)
{
float C,F;
printf("Enter tempreture in Celsius:");
scanf("%f",&C);
F=(9/5.0)*C+32;
printf("The tempreture in Fahrenheit is : %.2f",F);
getch();
}

Output:

Computer Fundamentals & Programming 5


Lab#04 F.No#4497

Object: To print a program that converts the Feet into Miles.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that converts the Feet into Miles //
#include<stdio.h>
#include<conio.h>
void main(void)
{
float F,M;
M=0.00018939;
printf("Enter distance in Feets: ");
scanf("%f",&F);
M=M*F;
printf("The distance in Miles is : %f",M);
getch();
}
Output:

Computer Fundamentals & Programming 6


Lab#04 F.No#4497

Object: To print a program that calculates Elapsed time.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that calculates Elapsed time //
#include<stdio.h>
#include<conio.h>
void main(void)
{
float ET,distance,speed;
char ch;
ch='y';
while(ch=='y')
{
printf("\nEnter Total distance:");
scanf("%f",&distance);
printf("Enter Avg Speed: ");
scanf("%f",&speed);
ET=distance/speed;
printf("The Elapsed time is found to be: %f",ET);
printf("\nDo you want to continue:");
ch=getche();
}
}
Output:

Computer Fundamentals & Programming 7


Lab#04 F.No#4497

Object: To print a program that calculates nth term of a sequence .


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that calculates nth term of a sequence //
#include<stdio.h>
#include<conio.h>
void main(void)
{
double a,d,n,v;
char ch;
ch='y';
while(ch=='y')
{
printf("\nThe first term of the sequence is : ");
scanf("%lf",&a);
printf("The difference of the seqence is: ");
scanf("%lf",&d);
printf("Enter Number of terms in the sequence:");
scanf("%lf",&n);
v=a+(n-1)*d;
printf("The value of nth term of the sequence is %.2lf",v);
printf("\nDo you want to continue:");
ch=getche();
}
}
Output:

Computer Fundamentals & Programming 8


Lab#04 F.No#4497

Object: To print a program that prints decimal,Octal and hexadecimal.


Source Code:
//M.Babar//
//F.No. 4497//
//To print a program that prints decimal,Octal and hexadecimal //
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a;
clrscr();
for(a=0;a<=10;a++)
printf("Decimal: %d \t Octal: %o \t Hexa Decimal: %#x\n",a,a,a);
}
Output:

Computer Fundamentals & Programming 9


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.No.4497//
//To print the given pattern//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();

for(rows=1;rows<=3;rows++)
{
for(cols=1;cols<=3;cols++)
printf("*");
printf("\n");
}
getch();

}
Output:

Computer Fundamentals & Programming 10


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.NO.4497//
//To print the given pattern//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();
for(rows=1;rows<=3;rows++)
{
for(cols=1;cols<=rows;cols++)
printf("*");
printf("\n");
}
getch();
}
Output:

Computer Fundamentals & Programming 11


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.NO.4497//

//To print the given pattern//


#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();
for(rows=3;rows>=1;rows--)
{
for(cols=1;cols<=rows;cols++)
printf("*");
printf("\n");
}
getch();
}
Output:

Computer Fundamentals & Programming 12


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.NO.4497//

//To print the given pattern//


#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols,space;
clrscr();

for(rows=1;rows<=3;rows++)
{
for(space=1;space<rows;space++)
printf(" ");

for(cols=3;cols>=rows;cols--)
printf("*");

printf("\n");
}
getch();

}
Output:

Computer Fundamentals & Programming 13


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.NO.4497//

#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols,i,var=0;
clrscr();
for(rows=1;rows<=3;rows++)
{
for(cols=3;cols>=rows;cols--)
printf("*");
for(i=1;i<=var;i++)
printf(" ");
for(cols=3;cols>=rows;cols--)
printf("*");
printf("\n");
var+=2;
}
getch();
}
Output:

Computer Fundamentals & Programming 14


Lab#04 F.No#4497

Object: To print the given pattern using Nested for-loop.


Source Code:
//M.Babar//
//F.NO.4497//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols,i,var=0;
clrscr();
for(rows=1;rows<=3;rows++)
{
for(cols=3;cols>=rows;cols--)
printf("*");
for(i=1;i<=var;i++)
printf(" ");
for(cols=3;cols>=rows;cols--)
printf("*");
printf("\n");
var+=2;
}
var=4;
for(rows=1;rows<=3;rows++)
{
for(cols=1;cols<=rows;cols++)
printf("*");
for(i=1;i<=var;i++)
printf(" ");
for(cols=1;cols<=rows;cols++)
printf("*");
printf("\n");
var-=2;
}
getch();
}
Output:

Computer Fundamentals & Programming 15


Lab#04 F.No#4497

Object: To print the given pattern using Nested while-loop.


Source Code:
//M.Babar//
//F.NO.4497//
//To print the given pattern//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();
rows=1;
while(rows<=3)
{
cols=1;
while(cols<=3)
printf("*",cols++);
printf("\n");
rows++;
}
getch();
}

Output:

Computer Fundamentals & Programming 16


Lab#04 F.No#4497

Object: To print the given pattern using Nested while-loop.


Source Code:
//M.Babar//
//F.NO.4497//
//To print the given pattern//
#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();
rows=1;
while(rows<=3)
{
cols=1;
while(cols<=rows)
printf("*",cols++);
printf("\n");
rows++;
}
getch();
}
Output:

Computer Fundamentals & Programming 17


Lab#04 F.No#4497

Object: To print the given pattern using Nested while-loop.


Source Code:
//M.Babar//
//F.NO.4497//

//To print the given pattern//


#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols;
clrscr();
rows=3;
while(rows>=1)
{
cols=1;
while(cols<=rows)
printf("*",cols++);
printf("\n");
rows--;
}
getch();
}
Output:

Computer Fundamentals & Programming 18


Lab#04 F.No#4497

Object: To print the given pattern using Nested while-loop.


Source Code:
//M.Babar//
//F.NO.4497//

//To print the given pattern//


#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols,space;
clrscr();
rows=1;
while(rows<=3)
{
space=1;
while(space<rows)
printf(" ",space++);
cols=3;
while(cols>=rows)
printf("*",cols--);
printf("\n");
rows++;
}
getch();
}
Output:

Computer Fundamentals & Programming 19


Lab#04 F.No#4497

Object: To print the given pattern using Nested while-loop.


Source Code:
//M.Babar//
//F.NO.4497//

#include<stdio.h>
#include<conio.h>
void main(void)
{
int rows,cols,space,var=0;
clrscr();
rows=1;
while(rows<=3)
{
cols=3;
while(cols>=rows)
printf("*",cols--);
space=1;
while(space<=var)
printf(" ",space++);
cols=3;
while(cols>=rows)
printf("*",cols--);
printf("\n");
var+=2;
rows++;
}
getch();
}
Output:

Computer Fundamentals & Programming 20

You might also like