Sunday, July 31, 2016

PROGRAM FOR PRIME NO- C Language

/*PROGRAM FOR PRIME NO.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,flag=0,n;
clrscr();
printf("Enter the no.::");
scanf("%d",&n);
for (i=2;i<=n/2;i++)
{
if(n%i==0)
{
printf("Not prime");
}
flag==1;
break;
}
if(flag==0)
{
printf("Prime");
}
getch();
}

/* ***********************OUTPUT***************************
Enter the no.::17
Prime*/

FACTORIAL OF A NUMBER- C Language

/* FACTORIAL OF A NUMBER*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=1,fact=1;
clrscr();
printf("\n Enter the no.::");
scanf("%d",&i);
while(j<=i)
{
fact=fact*j;
j++;
}
printf("The Factorial of the number is %d",fact);
getch();
}

/************************OUTPUT***************************
Enter the no.::5
The Factorial of the number is 120*/

TABLE USING DO-WHILE- C Language

/*TABLE USING  DO-WHILE*/

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j=1,c;
clrscr();
printf("\n Enter the no.::");
scanf("%d",&i);
do
{
c=i*j;
printf("\n%d",c);
j++;
}
while(j<=10);
getch();
}

/************************OUTPUT***************************
Enter the no.::
5
10
15
20
25
30
35
40
45
50*/

TABLE USING WHILE- C Language

/*TABLE USING WHILE*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=1,c;
clrscr();
printf("\n Enter the no.::");
scanf("%d",&i);
while(j<=10)
{
c=i*j;
printf("\n%d",c);
j++;
}
getch();
}

/* ***********************OUTPUT***************************
Enter the no.::
2
4
6
8
10
12
14
16
18
20 */


SIMPLE INTEREST- C Language

/* SIMPLE INTEREST*/

#include<conio.h>
#include<stdio.h>
void main()
{
float p,r,t,si,ta;
clrscr();
printf("Enter the principal amount,rate of interest and time\n");
scanf("%f%f%f",&p,&r,&t);
si=(p*r*t)/100;
printf("The simple interest is %f",si);
ta=p+si;
printf(“Total amount after the desire period is %f”,ta);
getch();
}

/************************OUTPUT***************************
Enter the principal amount, rate of interest and time
1000
2
2
The simple interest is 40

Total amount after the desire period is 1040*/

TO FIND GREATEST NUMBER - C Language

/* TO FIND GREATEST NUMBER*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,max;
clrscr();
printf("Enter the three number\n");
scanf("%d%d%d",&a,&b,&c);
max=a;
if(b>max)
max=b;
if(c>max)
max=c;
printf("The gerater no. is %d",max);
getch();
}

/************************OUTPUT***************************
Enter the three number
23
65
95
The greatest no. is 95*/







To find the average using function- C Language

/*To find the average using function*/

#include<stdio.h>
#include<conio.h>
void main()
{
float avg(float,float);
float a,b,c;
clrscr();
printf("Enter the value ofa&b::\n");
scanf("%f%f",&a,&b);
c=avg(a,b);
printf("\n Avg is %f",c);
getch();
}

float avg(float a,float b)
{
float d;
d=(a+b)/2;
return(d);
}

/* ***********************OUTPUT***************************
Enter the value ofa&b::
2
3
Avg is::2.500000*/

To find the square using function - C Language

/*To find the square using function*/


#include<stdio.h>
#include<conio.h>
void main()
{
int square(int);
int a,b;
clrscr();
printf("enter the value of a:: ");
scanf("%d",&a);
b=square(a);
printf("square is %d ::",b);
getch();
}
int square(int x)
{
int y;
y=x*x;
return(y);
}


/************************OUTPUT***************************
  enter the value of a:: 12

  square is::144 */

EVEN OR ODD- C Language

/*EVEN OR ODD*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a;
clrscr();
printf("Enter the number::\n");
scanf("%d",&a);
if(a%2 == 0)
{
printf("Number is ev
en");
}
else
{
printf("Number is odd");
}
getch();
}


/************************OUTPUT***************************
Enter the number::6
Number is even*/

TABLE FROM 1 TO 20- C Language

/*TABLE FROM 1 TO 20*/

#include<conio.h>
#include<stdio.h>
void main()
{
int a,b,c;
clrscr();
for (a=1;a<=20;a++)
{
for (b=1;b<=10;b++)
{
c=a*b;
printf("\n%d*%d=%d",a,b,c);
}
getch();
}

}

MARK SHEET- C Language

/* MARK SHEET */

#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
float per;
clrscr();
int m1,m2,m3,m4,m5,m6,t,x=0;
printf("Enter the marks m1,m2,m3,m4,m5,m6\n");
scanf("%d%d%d%d%d%d",&m1,m2,&m3,&m4,&m5,&m6);
t= m1+m2+m3+m4+m5+m6;
per=t/6;
if(m1<40||m2<40||m3<40||m4<40||m5<40||m6<40)
{
printf("Student is fail & per. is %f",per);
x=1;
}
if (x==1)
exit(0);
else
if (per<40)
{
printf("student is failed & per.is %f",per);
}
if (per>=40 && per<50)
{
printf("student is passed with third division & per.is%f",per);
}
if (per>=50 && per<60)
{
printf("student is passed with second division & per.is %f",per);
}
if (per>=60 && per<75)
{
printf("student is passed with first division & per. is %f.",per);
}
if (per>75)
{
printf("student is passed with hons.& per.is %f",per);
}
getch();
}

/************************OUTPUT***************************
Enter the marks m1,m2,m3,m4,m5,m6
45
69
35
33
96
83
student is failed & per.is 58.000000*/