C Language Practicals For Copies
C Language Practicals For Copies
Screen)
#include<stdio.h>
#include<conio.h>
void main()
#include<conio.h>
void main()
int x=45;
float ft=45.76;
getch();
Practical 3 (Write a program take input of character from user and print ASCII
values on the screen)
#include<stdio.h>
#include<conio.h>
void main()
char c;
scanf("%c",&c);
#include<conio.h>
void main()
clrscr();
scanf("%d",&a);
scanf("%d",&b);
sum= a+b;
printf("%d + %d = %d ",a,b,sum);
getch();
#include<conio.h>
void main()
int a,b,c, p;
float s,A;
clrscr();
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
s= (a+b+c)/2.0;
A=sqrt(s*(s-a)*(s-b)*(s-c));
P=a+b+c;
getch();
#include<conio.h>
void main()
int choice;
float F,C;
clrscr();
scanf("%d",&choice);
if (choice==1)
scanf("%f",&C);
F=9.0/5.0*C+32;
if (choice==2)
scanf("%f",&F);
C=5.0/9.0*(F-32);
getch();
}
#include<conio.h>
void main()
int n;
clrscr();
scanf("%d",&n);
if((n%3==0)&& (n%2==0))
else
getch();
Practical 8 (Write a program that finds whether a given year is leap or not.
Leap year is a year that is divisible by 4)
#include<stdio.h>
#include<conio.h>
void main()
int y;
clrscr();
scanf("%d",&y);
if(y%4==0)
printf("Leap Year");
else
getch();
Practical 9 (Write a program takes character from user and check whether
character is Vowel or Consontant)
#include<stdio.h>
#include<conio.h>
void main()
char ch;
clrscr();
scanf("%c",&ch);
switch(ch)
printf("Vowel");
break;
printf("Vowel");
break;
printf("Vowel");
break;
case 'o': case 'O':
printf("Vowel");
break;
printf("Vowel");
break;
default:
printf("Consontant");
getch();
#include<conio.h>
void main()
float n;
clrscr();
scanf("%f",&n);
printf("Conditilly Pass");
printf("Pass");
else
getch();
Practical 11 (write a Program that takes Number from user and check number
is prime or composite using while loop.)
#include<stdio.h>
#include<conio.h>
void main ()
clrscr();
scanf("%d",&n);
while (i<=n/2)
if (n%i==0)
c=0;
i=i+1;
if (c==2)
else
getch();
Practical 12 (write a Program that takes Number from user and print the
factorial of only positive number using while loop.)
#include<stdio.h>
#include<conio.h>
void main ()
clrscr();
while (i<=n)
fact=fact*i;
i++;
getch();
Practical 13 (write a Program that takes base and power of number and print
the Result using while loop.)
#include<stdio.h>
#include<conio.h>
void main ()
clrscr();
scanf("%d",&base);
scanf("%d",&power);
while (power!=0)
result = result*base;
--power;
printf("Answer = %d",result);
getch();
}
Practical 14 (write a Program that takes number from user and print the table
of given Number using do while loop.)
#include<stdio.h>
#include<conio.h>
void main ()
int num,a=1;
clrscr();
scanf("%d",&num);
do
printf("%d * %d = %d \n",num,a,num*a);
a++;
while (a<=10);
getch();
Practical 15 (write a Program that displays the following output using nested
for loop
1 2 3 4
5 6 7
8 9
10.)
#include<stdio.h>
#include<conio.h>
void main ()
{
int x,y,n;
n=1;
clrscr();
if (y>x)
printf(" ");
else
printf("%d\t",n++);
printf("\n");
getch();
Practical 16 (write a Program that displays the following output using nested
for loop
1 2 3 4
1 2 3
1 2
1.)
#include<stdio.h>
#include<conio.h>
void main ()
int i,j;
clrscr();
{
for (i=1; i<=4-j; i++)
printf(" ");
printf("%4d",i);
printf("\n\n");
getch();
Practical 17 (write a Program that displays the following output using nested
for loop
1
1 2
1 2 3
1 2 3 4.
#include<stdio.h>
#include<conio.h>
void main ()
int i,j;
clrscr();
printf(" ");
printf("%4d",i);
printf("\n\n");
}
getch();
Practical 18 (write a Program that displays the following output using nested
for loop
*
**
***
****
*****
#include<stdio.h>
#include<conio.h>
void main ()
{
int r,c;
clrscr();
for (c=1; c<=5; c++)
{
for (r=1; r<=c; r++)
printf("*");
printf("\n");
}
getch();
}
Practical 18 (write a Program that displays the following output using nested
for loop
@ @ @ @
% % % %
Practical 19 (write a Program that displays the table of number which is enter
by user using for loop.)
#include<stdio.h>
#include<conio.h>
void main ()
{
int num,i,ans;
clrscr();
printf("Enter a number to generate the table: ");
scanf("%d",&num);
printf("\n Table of %d",num);
for (i=1; i<=10; i++);
{
ans=num*i;
printf("%d * %d = %d",num,i,ans);
}
printf("Factorial of %d is : %d",num,fact);
}