1.WRITE A C PROGRAM TO CALCULATE SUM OF TWO NUMBERS
PROGRAM:
# include<studio.h>
#include<conio.h>
void main()
{
{
Int
a,b,c;
printf(“Enter the two no to calculate sum :”);
scanf(“%d%d”,&a&b);
c=a+b;
printf(“The sum of %d and %d is
=%d”,a,b,c);
getch();
}
OUT PUT :
Enter two number to
calculate sum: 3 4
The sum of 3 and 4 is =12
2.WRITE A C PROGRAM TO CALCULATE TO CHECK A
NUMBER EVEN OR ODD
PROGRAM:
#
include<studio.h>
#include<conio.h>
void main()
{
{
int n;
printf(“Enter the numbers to check
even or odd :”);
scanf(“%d”,&n);
if(n%2==0)
printf(“Given
numbers is even”);
else
printf(“Given
numbers is not even”);
getch();
}
OUT PUT :
Enter
the numbers to check even or odd : 11
Given numbers is not even
Enter
the numbers to check even or odd: 10
Given numbers is even
3. WRITE A C PROGRAM TO CALCULATE MULTIPLICITE OF TWO NUMBER
#include<stdio.h>
#include<conio.h>
{
int a,b,c;
printf(“Enter two numbers to calculate multiplication :”);
scanf(“%d%d”,&a&b);
c=a*b;
printf(Multiplication=%d”,c);
getch();
}
OUT PUT:
Enter two numbers to calculate multiplication :4 5
Multiplication=20
4.WRITE A C
PROGRAM TO DISPLAY YOUR NAME FIVE TIME IN
PROGRAM :
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf(“My
name 5 times in”);
while(i<=5)
{
printf(“RAM \n”);
i=i+1;
getch();
}
}
OUT PUT :
My
name 5 time in
RAM
RAM
RAM
RAM
RAM
5.WRITE A
C PROGRAM TO DISPLAY THE FOLLOWING
*
**
***
****
PROGRAM :
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
clrscr();
printf(“In the required display is \n”);
while(i<=4)
{
j=1;
while(j<=i)
{
printf(“*\t”);
j++;
}
i++;
printf(“/n”);
}
getch();
}
OUT PUT :
In the
required display is
*
**
***
****
6.WRITE A C PROGRAM TO DISPLAY ALL EVEN NO
BETWEEN A
RANGE
PROGRAM :
#include<stdio.h>
#include<conio.h>
void main()
{
Int i,start,end;
clrscr();
printf(“Enter the range to display all even no. between a range\n”);
scanf(“%d%d”,&start,&end);
i=start;
printf(“All even no.between %d to %d are\n”,start,end);
while(i<=end)
{
if(i%2==0)
printf(“%6d”,i);
i++;
}
getch();
}
OUT PUT :
Enter the range to display all even no. between a range
1
10
All even no. between 1 to 10 are
2 4 6
8 10
7.WRITE A C PROGRAM
TO DISPLAY ALL NUMBERS BETWEEN A RANGE
PROGRAM :
#include<stdio.h>
#include<conio.h>
void main()
{
int i,start,end;
printf(“Enter the range to display the no.\n”);
scanf(“%d%d”,&start,&end);
i=start;
printf(“All number between %d to %d
are \n”,start,end);
while(i<=end)
{
printf(“%6d”,i);
i++;
}
getch();
}
OUT PUT :
Enter the range to display the no.
1
10
All number between 1 to 10 are
1 2 3
4 5 6 7 8
9 10
8.WRITE A C
PROGRAM TO COUNT NUMBER OF
DIGIT
OF A NUMBER
PROGRAM :
#include<stdio.h>
#include<coio.h>
void main()
{
int n,c=0,i,t;
printf(“Enter a no. to count the digit \n”);
scanf(“%d”,&n);
t=n;
while(t!=0)
{
c++;
t=t/10;
}
printf(“The no. %d is %d digits”,n,c);
getch();
}
OUTPUT :
Enter a no. to count a digit
123
The no. 123 is 3 digit
9.WRITE A C PROGRAM
TO CHECK A NO IS PRIME OR
NOT
PROGRAM :
#include<stdio.h>
#include<conoio.h>
void main()
{
int n,i=2,f=0;
clescr();
printf(“Enter a no. to check prime or not \n”);
scanf(“%d”,&n);
while(i<=n/2)
{
if(n%i==0)
{
f++;
break;
}
i++;
}
if(f==0)
printf(“%d is a prime no.”,n);
else
printf(“%d is not a prime no.”,n)
getch();
}
OUTPUT :
Enter a no. to check prime or not
12
12 is a prime no.
Enter a no. to check prime or not
11
11 is not a prime no.
10.WRITE A C PROGRAM
TO DISPLAY ALL PRIME NO.
UPTO n
PROGRAM :
#include<stdio.h>
#include<comio.h>
void main()
{
int n,i,f,j=0;
clrscr();
printf(“Enter a no. to
find the all prime no.s\n”);
scanf(“%d”,&n);
printf(“All prime no.s
up to %d”,n);
while(j<=n)
{
f=0;
i=2;
while(i<=j/2)
{
if(n%i==0)
{
{
f++;
break;
}
i++;
}
if(f==0)
printf(“%d\t”,j);
j++;
}
getch();
}
OUT PUT :
Enter a no. to find all prime no.
6
All prime no. up to 6
1 2 3
0 Comments
Post a Comment