C-Programs
C-Programs
PROGRAM 1:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf(“\t\t Welcome to ‘C’ Programming\n”);
getch();
}
PROGRAM 2:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d;
clrscr();
printf(“Enter the first value=\n”);
scanf(“%d”,&a);
printf(“Enter the second value=\n”);
scanf(“%d”,&b);
printf(“Enter the third value=\n”);
scanf(“%d”,&c);
d=a+b+c;
printf(“The result =%d”,d);
getch();
}
PROGRAM 3:
#include<stdio.h>
#include<conio.h>
1
void main()
{
float si,p,n,r;
clrscr();
printf(“Enter the principal amount=\n”);
scanf(“%f”,&p);
printf(“Enter the number of years=\n”);
scanf(“%f”,&n);
printf(“Enter the rate of interest=\n”);
scanf(“%f”,&r);
si=(p*n*r)/100;
printf(“the simple interest=%f”,si);
getch();
}
PROGRAM 4:
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf(“Enter the age=\n”);
scanf(“%d”,&a);
if(a<18)
{
printf(“\n YOU ARE MINOR”);
}
else if(a>=18&&a<=60)
{
printf(“\n YOU ARE MAJOR”);
}
else
printf(“\n YOU ARE OLD PERSON”);
getch();
}
2
PROGRAM 5:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,ch;
clrscr();
printf(“Enter your choice=\n”);
printf(“\n1.ADDITION”);
printf(“\n2.SUBTRACTION”);
printf(“\n3.MULTIPLY”);
printf(“\n4.DIVIDE”);
printf(“\n5.END”);
printf(“\n\nEnter your choice (1 to 5)=”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
printf(“\nEnter the first number =\n”); scanf(“%d”,&a);
printf (“\nEnter the second number =\n”); scanf(“%d”,&b);
c=a+b;
printf(“\nAddition of two numbers=%d”,c);
break;
case 2:
printf(“\nEnter the first number =\n”); scanf(“%d”,&a);
printf (“\nEnter the second number =\n”); scanf(“%d”,&b);
d=a-b;
printf(“\n Subtraction of two numbers=%d”,d);
break;
case 3:
printf(“\nEnter the first number =\n”); scanf(“%d”,&a);
printf (“\nEnter the second number =\n”); scanf(“%d”,&b);
e=a*b;
printf(“\nMultiplication of two numbers=%d”,e);
break;
case 4:
printf(“\nEnter the first number =\n”); scanf(“%d”,&a);
printf (“\nEnter the second number =\n”); scanf(“%d”,&b);
f=a/b;
3
printf(“\nDivision of two numbers=%d”,f);
break;
case 5:
printf(“\nTHANKS”);
break;
}
getch();
}
PROGRAM 6:
#include<stdio.h>
#include<conio.h>
void main()
{
float f,c;
clrscr();
printf(“Enter the Fahrenheit value=\n”);
scanf(“%f”,&f);
c=((f-32.0)/1.8);
printf(“\nCelsius=%f”,c);
getch();
}
PROGRAM 7:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“Enter the number=\n”);
scanf(“%d”,&a);
b=(a%2);
if(b==0)
{
printf(“\n%d is Even Number”,a);
4
}
else
{
printf(“\n%d is Odd Number”,a);
}
getch();
}
PROGRAM 8:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10];
int i,j,temp;
clrscr();
printf(”Enter the number=\n”);
for(i=0;i<=9;i++)
{
scanf(“%d”,&a[i]);
}
for(i=0;i<=9;i++)
{
for(j=i+1;j<=10;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[j]=a[i];
a[j]=temp;
}
}
}
printf(“\n The Biggest Number=%d”,temp);
getch();
}