E.Balagurusamy ANSI C Programming solution Chapter-01

ANSI C Programming solution Chapter-01
Overview of C
Chapter One(01) Contains
01.History of C
02.Importance of  C
03.Sample Programs
04.Basic Structure of C Programs
05.Programming Style
06.Executing a C Program
07.Unix System
08.Ms-Dos System
 Solution of problem exercise no 1.1&1.2:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("---------------------------------------\n");
printf("I First line :A.Z.M.Shakilur Rahman I\nI Second line :12/a ,Ali sonar lane I\nI Third line:Bogra,5800 I\n");
printf("---------------------------------------");
getch();
}
Output:
 Solution of problem exercise no:1.3
#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
printf("*\n* *\n* * *\n* * * * ");
getch();
}
Output:
*
* *
* * *
* * * *
 Solution of problem exercise no :1.4
#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
printf("a>>------------------>b");
getch();
}
Output:
a>>------------------>b
 Solution of problem exercise no:1.5
#include<stdio.h>
#include<conio.h>
#define pi 3.14159
void main()
{
float r,A;
clrscr();
printf("\n\tENTER THE RADIUS OF A CIRCLE=");
scanf("%f",&r);
A=pi*r*r;
printf("\n\n\tArea=%f sqr unit",A);
getch();
}
Output:
ENTER THE RADIUS OF A CIRCLE=2
Area=12.566360 sqr unit
 Solution of problem exercise no:1.6
#include<stdio.h>
#include<conio.h>
void main()
{
int b,c;
clrscr();
for(b=1;b<=10;b++)
{
c=5*b;
printf("\n\t%d*%d=%d\n",5,b,c);
getch();
}
}
Output :
 Solution of problem exercise no:1.7
#include<stdio.h>
#include<conio.h>
void add();
void sub();
void main()
{
clrscr();
add();
sub();
getch();
}
void add()
{
printf("\n\t%d+%d=%d",20,10,30);
}
void sub()
{
printf("\n\t%d-%d=%d",20,10,10);
}
Output :
20+10=30
20-10=10
 Solution of problem exercise no:1.8
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,x;
clrscr();
printf("Enter values of a,b&c\n");
scanf("%d%d%d",&a,&b,&c);
x=a/(b-c);
printf("result=%d",x);
getch();
}
Output:
a)
Enter values of a,b&c
250
85
25
result=4
b)NO OUTPUT
 Solution of problem exercise no:1.9 (b)
#include<stdio.h>
#include<conio.h>
void main()
{
float a,F,C;
clrscr();
printf("ENTER TEMPERATURE IN FARENHITE\n");
scanf("%f",&F);
a=5*(F-32);
C=a/9;
printf("\nIn celsius scale=%f",C);
getch();
}
Output :
ENTER TEMPERATURE IN FARENHITE
10
In Celsius scale=-12.222222
 Solution of problem exercise no:1.9 (a)
#include<stdio.h>
#include<conio.h>
void main()
{
float a,F,C;
clrscr();
printf("ENTER TEMPERATURE IN CELSIUS\n");
scanf("%f",&C);
a=(9*C)/5;
F=a+32;
printf("\nIn farenhite scale=%f",F);
getch();
}
Output:
ENTER TEMPERATURE IN CELSIUS
10
In frenhite scale=50.00000

 Solution of problem exercise no: 1.10
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,S,A;
printf("\n\tENTER THE THREE SIDES OF A TRIANGLE=");
scanf("%f%f%f",&a,&b,&c);
S=(a+b+c)/2;
A=sqrt(S*(S-a)*(S-b)*(S-c));
printf("\n\tArea of the triangle=%f",A);
getch();
}
Sample output:
ENTER THE THREE SIDES OF A TRIANGLE=10
12
14
Area of the triangle=58.787754

 Solution of problem exercise no:1.11
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float D,x1,x2,y1,y2;
clrscr();
printf("ENTER CO-ORDINATES x1,x2,y1,y2=\n");
scanf("%f%f%f%f",&x1,&x2,&y1,&y2);
D=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
printf("Result=%f",D);
getch();
}
Output :
ENTER CO-ORDINATES x1,x2,y1,y2=
2
4
8
5
Result=3.605551

 Solution of problem exercise no:1.12
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.14159
void main()
{
float r,x1,x2,y1,y2,A;
clrscr();
x1=0;
x2=0;
y1=4;
y2=5;
r=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
A=pi*r*r;
printf("Result=%f",A);
getch();
}
Output :
Result=3.14159

 Solution of problem exercise no:1.13
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.14159
void main()
{
float D,r,x1,x2,y1,y2,A;
clrscr();
x1=2;
x2=2;
y1=5;
y2=6;
D=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
r=D/2;
A=pi*r*r;
printf("Result=%f",A);
getch();
}
Output :
Result=0.785398

 Solution of problem exercise no:1.15
#include<stdio.h>
#include<conio.h>
void main()
{ float x,y,sum,difference,product,division;
clrscr();
printf("ENTER TWO NUMBERS=\n");
scanf("%f%f",&x,&y);
sum=x+y;
difference=x-y;
product=x*y;
division=x/y;
printf("\n\tSum=%f\tDifference=%f\n\n\tProduct=%f\tDivision=%f",sum,difference,product,division);
getch();
}
Output :
ENTER TWO NUMBERS=
10
5
Sum=15.000000 Difference=5.000000
Product=50.000000 Division=2.000000


 Solution of problem exercise no:1.14
#include<stdio.h>
#include<conio.h>
void main()
{ int a,b,c;
clrscr();
a=5;
b=8;
c=18;
printf("%dx+%dy=%d",a,b,c);
getch();
}
Output :
5x+8y=18

E.Balagurusamy ANSI C Programming solution Chapter-01,Chapter one solution of ANSI C programming book.Now download the E.Balagurusamy ANSI C Programming whole book Solution.To download check the button
   

After finishing this chapter you can acquire knowledge about Importance of C, History of C, Basic Structure of C Programs, Programming Style, Unix System, Sample Programs, Executing a C Program, Ms-Dos System etc.

Popular Posts