C Programs Basic
C Programs Basic
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello World");
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 2
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();d
printf("Hello World\nThis is C language");
getch();
}
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 3
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
float p,r,t,si;
clrscr();
printf("Enter Principle:");
scanf("%f",&p);
printf("Enter Rate:");
scanf("%f",&r);
printf("Enter Time:");
scanf("%f",&t);
si=(p*r*t)/100;
printf("Simple Interest is : %f",si);
getch();
}
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 4
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
float r,a;
clrscr();
printf("Enter Radius of The Circle:");
scanf("%f",&r);
a=3.14*r*r;
printf("Area of The Circle is:%f",a);
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 5
#include<stdio.h>
#include<conio.h>
void main()
{
float s,a;
clrscr();
printf("Enter Side of Square:");
scanf("%f",&s);
a=s*s;
printf("Area of the Square is:%f",a);
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 6
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
float s,p;
clrscr();
printf("Enter Side of Square:");
scanf("%f",&s);
p=4*s;
printf("Perimeter of the Square is:%f",p);
getch();
}
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 7
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b;
clrscr();
printf("Enter Distance in Meters:");
scanf("%f",&a);
b=a/1000;
printf("This Distance in Kilometer Will be:%f",b);
getch();
}
OUTPUT
MOHIT MINOCHA
15001003028
MOHIT MINOCHA
15001003028
PROGRAM : 8
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter Any Number:");
scanf("%d",&n);
if (n%2==0)
{ printf("Number is Even"); }
else
{ printf("Number is Odd"); }
getch();
}
OUTPUT
MOHIT MINOCHA
15001003028
MOHIT MINOCHA
15001003028
PROGRAM : 9
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,a;
clrscr();
printf("Enter values of x and y\n");
scanf("%d%d",&x,&y);
printf("Before Swaping\nx=%d\ny=%d\n",x,y);
a=x;
x=y;
y=a;
printf("After Swaping\nx=%d\ny=%d",x,y);
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 10
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c; clrscr();
printf("Enter values of a,b and c respectively\n");
scanf("%d%d%d",&a,&b,&c);
if (a>b&&a>c)
{ printf("a is Greatest"); }
else
if (b>a&&b>c)
{ printf("b is Greatest"); }
else
if (c>a&&c>b)
{ printf("c is Greatest"); }
else
{ printf("ENTER DISTINCT NUMBERS"); }
getch(); }
OUTPUT
MOHIT MINOCHA
15001003028
MOHIT MINOCHA
15001003028
PROGRAM : 11
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
int x;
float a,b,c,x1,x2,d;
clrscr();
printf("Enter the values of a,b and c of a quadratic equation\n");
scanf("%f%f%f",&a,&b,&c);
d=(b*b)-(4*a*c);
printf("Discreminant,d=%f\n",d);
printf("press\n1 if d is positive\n2 if d is zero\n3 if d is negative\n");
scanf("%d",&x);
switch(x)
{
case 1:x1=(-b+sqrt(d))/2*a;x2=(-b-sqrt(d))/2*a;
printf("Roots are Real and Distinct and are %f and %f",x1,x2);break;
MOHIT MINOCHA
15001003028
case 2:x1=(-b)/2*a;
printf("Both roots are Equal to %f",x1);break;
case 3:printf("Roots are Imaginary");break;
default:printf("Wrong Choice Entered");
}
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028
PROGRAM : 12
MOHIT MINOCHA
15001003028
#include<stdio.h>
#include<conio.h>
void main()
{
float p;
clrscr();
printf("Enter percentage of Marks obtained:");
scanf("%f",&p);
if (p>=91)
printf("Grade A");
else
if (p>=81&&p<=90)
printf("Grade B");
else
if (p>=71&&p<=80)
printf("Grade C");
else
if (p>=61&&p<=70)
printf("Grade D");
else
if (p>=51&&p<=60)
printf("Grade E");
MOHIT MINOCHA
15001003028
else
printf("Grade F");
getch();
}
MOHIT MINOCHA
15001003028
OUTPUT
MOHIT MINOCHA
15001003028