DataWare Housing Glossary of Terms - 'I' & 'J'

Monday, December 17, 2007

Indexing fastest searching records
Information Data that has been processed in such a way that it can increase the knowledge of the person who receives it.
Information Systems Architecture The authoritative definition of the business rules, systems structure, technical framework, and product backbone for business information systems.
Instance a set of values representing a specific entity belonging to a particular entity type.
Integrity a set of values representing a specific property of a data base that ensures that the data contained in the data base in accurate and consistent as possible.
Intelligent Data Base a data base that contains shared logic as well as shared data and automatically invokes that logic when the data base is accessed. Logic, constraints, and controls relating to the use of data are represented in an intelligent data model.
Interleaved Data data from different tables mixed into a simple table space where is commonality of physical colocation based on a common key value.
Iterative Analysis the mode of processing in which the next step of processing depends on the results obtained by the existing step in execution.

Join an operation that takes two relations as operands and produces a new relation by concatenating the tuples and matching the corresponding columns when a stated condition holds between the two.

Read more...

DataWare Housing Glossary of Terms - 'G' & 'H'

Global Business Models Provides access to information scattered throughout an enterprise under the control of different divisions or departments with different databases and data models. This type of data warehouse is difficult to build because it requires users from different divisions to come together to define a common data model for the warehouse.
Granularity The level of detail of the data stored in a data warehouse.

Hetergeneous Environment Within an enterprise, a network of different types of servers and databases.
Heuristic the mode of analysis in which the next step is determined by the results of the current step of analysis.
Hierarchy The organization of data into a logical tree structure.
Homogeneous Environment Within an enterprise, a network consisting of the same type of servers and databases.
Horizontal Distribution the splitting of a table across different sites by rows. With horizontal distribution rows of a single table residing at different sites in a distributed data base network.
Hub and Spoke Configuration A configuration of interconnected systems where a single system (the hub) acts as the central point for exchanging data with and between the other systems (spokes).
Huffman Code a code for data compaction in which frequently used characters are encoded with fewer bits than infrequently used characters.
HyperCube See CUBE.

Read more...

DataWare Housing Glossary of Terms - 'F'

Fact Table The tables which are extracted from heterogeneous sources and used in the Data Wareahouse
Factless Fact A fact table without any metrics in it
Flat File a collection of records containing no data aggregates, nested repeated data items, or groups of data items.
Functional Decomposition the division of operations into hierarchical functions that form the basis for procedures.

Read more...

DataWare Housing Glossary of Terms - 'E'

EDI (Electronic Data Interchange) is a standard format for exchanging business data.
Encryption the transformation of data from a recognizable format to a form unrecognizable without the algorithm used for the transformation.
ETL (Extract, Transform and Load) ETL refers to the process of getting data out of one data store (extract), modifying it (transfer), and inserting it into a different data store (load).
ETT ETL is sometimes referred as ETT- Extraction, Transformation and Transportation. It is a series of batch interface between the systems.
Executive/Enterprise Information Systems (EIS) Tools programmed to provide canned reports or briefing books to top-level executives. They offer strong reporting and drill-down capabilities. Today these tools allow ad-hoc querying against a multi-dimensional database, and most offer analytical applications along functional lines such as sales or financial analysis. (Also known as Decision Support System.)
Extendibility The ability to easily add new functionality to existing services without major software rewrites or without redefining the basic architecture.
External Schema a logical description of a user's method of organizing and structuring data.

Read more...

DataWare Housing Glossary of Terms - 'D'

DataFacts, concepts, or instructions that a
computer records, stores and processes.
Used in conjunction with INFORMATION
SYSTEMS, “raw data” is organized in
such a way that people can understand the
results.
Data CleansingRemoving errors and inconsistencies
from data being inported to a data
warehouse.
Data Dictionarya software tool for recording the definition
of data, the relationship of one category of
data to another, the attributes and keys of
groups of data, and so forth.
Data Driven Developmentthe approach to development that centers
around identifying the commonality of data
through a data model and building programs
that have a broader scope thn the immediate application.
Data Driven Processa process whose resource consumption
depends on the data on which it operates.
Data MartA department-specific data warehouse.
A) Independent – fed from legacy systems
within the department
B) Dependent – fed from the enterprise data
warehouse (preferred)
Data MiningThe process of finding hidden patterns and
relationships in data. For instance, a consumer
goods company may track 200 variables
about each consumer. There are scores of
possible relationships among the 200 variables.
Data mining tools will identify the significant
relationships.
Data ScrubbingRemoving errors and inconsistencies from
data being imported into a data warehouse.
Data TransformationThe modification or alteration of data as it
is being moved into the data warehouse.
Data TypeA data type defines the type of data stored
in a specific database column, such as date,
numeric or character data. Significant
differences in data types exist between
different platforms’ databases.
Data WarehouseA data warehouse is a subject oriented,
integrated, non volatile, time variant collection
of data. The data warehouse contains atomic
level data and summarized data specifically
structured for querying and reporting.
Data WarehousingAn enterprise-wide implementation that
replicates data from the same publication
table on different servers/platforms to a
single subscription table. This implementation
effectively consolidates data from multiple
sources.
Database SchemaThe logical and physical definition of a database structure.
Date/Time StampA stamp added by an application that identifies
a task or activity by the date and time it was
initiated and/or completed. This can appear as
part of a transaction log, message queue content
in job logs.
Decentralized DatabaseA centralized database that has been partitioned according to a business or end-user defined
subject area. Typically ownership is also
moved to the owners of the subject area.
Decentralized WarehouseA remote data source what users can query/
access via a central gateway that provides a
logical view of corporate data in terms that
users can understand. The gateway parses
and distributes queries in real time to
remote data sources and returns result
sets back to users.
Decision Support Systems (DSS)Software that supports exception reporting,
stop light reporting, standard repository,
data analysis and rule-based analysis. A
database created for end-user ad-hoc query
processing.
Denormalizationthe technique of placing normalized data
in a physical location that optimizes the
performance of the system.
Derived DataData whose values are determined by
equations or algorithms.
DimensionA Dimension is typically a qualifiable and
text value, such as a region, product line,
and includes date values. It defines the
secondary headings or labels that make up
the body of the report.
Each of the dimensions is repeated within
each group. Usually, you use items containing
text values (for example, Year or item type)
for table dimensions. For example, if you
select Item Type to be your table dimension,
Item Type is a dimension within each group
header. Under the dimension "Item Type,"
appears the name of each kind of item
(for example, CD ROM, or HARD Drive). and corresponds to the . A fact is an quantifiable
value, such amount of sales, budget or revenue.
Drill Down/UpThe ability to move between levels of the hierarchy when viewing data with multiple levels.
A) Drill down – changing a view to a greateer level of detail
B) Drill up – changing a view to a greater level of aggregation.

Read more...

DataWare Housing Glossary of Terms - 'C'

Sunday, December 16, 2007

Canonical modelA data model that represents the inherent
structure of data without regard to either
individual use or hardware or software
implementation.
Cardinalityno of unique rows divided by total no of
columns
CellA single point in a CUBE.
Conceptual SchemaA consistent collection of data structures
expressing the data needs of the organization.
This schema is a comprehensive, base level,
and logical description of the environment in
which an organization exists, free of physical
structure and application system considerations.
CondensationThe process of reducing the volume of data
managed without reducing the logical
consistency of the data.
ConnectorA symbol used to indicate that one occurrence
of data has a relationship with another
occurrence of data. Connectors are used
in conceptual data base design and can be
implemented hierarchically, relationally, in
an inverted fashion, or by a network.
ContentionTthe condition that occurs when two or more
programs try to access the same data at the
same time.
Cooperative ProcessingTthe ability to distribute resources (programs,
files and data bases) across the network.
Corporate DataAll the databases of the company.This includes
legacy systems,old and new transaction
systems,general business systems,client/server databases,data warehouses and data marts.
Corporate Information Warehouse (CIF)The architectural framework that houses the
ODS, data warehouse, data marts, i/t interface,
and the operational environment. The cif is held together logically by metadata and physically
by a network such as the Internet.
Cube – (also Hypercube, Multi-dimensional Cube)The fundamental structure for information in
an OLAP system. A structure that stores multi-dimensional information, having one CELL
for each possible combination of dimensions.

Read more...

DataWare Housing Glossary of Terms - 'B'

Binary SearchA dichotomizing search with steps in
which the sets of remaining items are
partioned into two equal parts.
Bit MapA specialized form of an index indicating
the existence or non-existence of a
condition for a group of blocks or records.
BusThe hardware connection that allows data
to flow from one component to another.
Business Intelligence ToolsSoftware that allows business users to see
and use large amounts of complex data.

Read more...

DataWare Housing Glossary of Terms - 'A'

AgentAn application that searches data and
sends an alert when a certain situation
occurs. (See ALERT)
Aggregate data

Individual data items, data groups,
arrays, tables etc. that can be
assembled to form a whole.

Alerts and AlarmsMessages sent automatically by a
computer system when an AGENT
identifies a certain situation. For
example, if stock of an item in a
warehouse drops to a certain level,
key personnel can be immediately
informed.
AlgorithmA set of statements organized to solve
a problem in a finite number of steps
Analytical ProcessingThe usage of the computer to produce
an analysis for management decision,
usually involving trend analysis, drill
down analysis, demographic analysis,
profiling, etc.
Architecture PhaseThe establishment of the framework,
scope and standards and procedures
for a data warehouse at the enterprise
level.
Atomic level dataData with the lowest level of granularity.
Atomic level data sits in a data warehouse
and is time variant (i.e., accurate as of
some moment in time now passed).
AttributeA property or characteristic of an
application entity. For example, the
attributes of an EMPLOYEE entity
in a business application may be:
IDFirstname
Lastname
Job_Title
Email_ID
An attribute usually represents a column
in a table in a relational database, or
a field in a file.
Audit TrailRecording of any changes made to
specific data. Details can include date
and time of change, how the change
was detected, reason for the change
and before-and-after data values.

Read more...

(C++) CPP Programs - 29

Friday, December 14, 2007

29. Write a C program to read N integers and store them in an array A, and so find the sum of all these elements using pointer. Output the given array and the computed sum with suitable heading.

/* Addition using pointers */

#include
#include

void main()
{
int a[45],*p;
int sum=0,i,n;
clrscr();

printf("\nEnter no. of elements\n");
scanf("%d",&n);

printf("Enter the numbers one by one\n");
for(i=0;i < n;i++)
scanf("%d",&a[i]);
p=a;
for(i=0;i < n;i++)
sum+=*p++;

printf("The sum of %d numbers=%d\n\a",n,sum);

getch();
}

Read more...

(C++) CPP Programs - 28

28. Write a C program to read two integers M and N and to swap their values. Use a user defined functions for swapping. Output the values of M and N before and after swapping with suitable message.

/* Swapping*/

#include
#include

void main()
{
int m,n;
clrscr();

printf("Enter the values for m,n\n\a");
scanf("%d%d",&m,&n);

swap(&m,&n);

printf("Function after swapping\n\a");
printf("\n m=%d n=%d\n",m,n);

getch();
}

swap(int *m,int *n)
{
int temp;
temp=*m;
*m=*n;
*n=temp;
}

Read more...

(C++) CPP Programs - 27

27. Write a C program to read a matrix A (M*N) and to find the following using functions.
a) Sum of elements of each row.
b) Sum of elements of each column.
c) Find the sum of all the elements of the matrix. Output the computed results with suitable heading.

/* Sum of rows and coloumns*/

#include
#include

int a[5][5],m,n;

void main()
{
int i,j;
clrscr();

printf("\nEnter the order of the matrix\n");
scanf("%d%d",&m,&n);

printf("\nEnter the elements\n\b");
for(i=0;i < m;i++)
for(j=0;j < n;j++)
scanf("%d",&a[i][j]);

printf("\nThe given matrix is\n\a");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
printf("%4d",a[i][j]);
printf("\n");
}
rowsum(a);
colsum(a);
allsum(a);

getch();
}

rowsum()
{
int rsum,i,j;
for(i=0;i < m;i++)
{
rsum=0;
for(j=0;j < n;j++)
rsum=rsum+a[i][j];
printf("\nSum of %d row = %d",i+1,rsum);
}
printf("\n");
}



colsum()
{
int csum,i,j;
for(j=0;j < n;j++)
{
csum=0;
for(i=0;i < m;i++)
csum=csum+a[i][j];
printf("\nSum of %d col = %d",j+1,csum);
}
printf("\n");
}
allsum()
{
int i,j,asum=0;
for(i=0;i < m;i++)
for(j=0;j < n;j++)
asum=asum+a[i][j];
printf("\nThe sum of entire matrix = %d",asum);

}

Read more...

(C++) CPP Programs - 26

26. Develop functions
a) To read a given matrix
b) To output a matrix
c) To compute the product of two matrices.
Use the above-developed functions to read in two matrices A(M*N) and (P*Q), to compute the product of the input matrices, to output the given matrices and the computed product matrix in a function.

/* Product of a matrix*/

#include
#include

int a[5][5],b[5][5],c[5][5],m,n,p,q;

void main()
{
clrscr();

read_mat();

printf("\nMatrix a is\n");
output(a,m,n);

printf("\nMatrix b is\n");
output(b,p,q);

mat_mul();

printf("\nMatrix c is\n");
output(c,m,q);

getch();
}

read_mat()
{
int i,j;
printf("\nEnter order of a\n");
scanf("%d%d",&m,&n);

printf("\nEnter the matrix b\n");
scanf("%d%d",&p,&q);

if(p!=n)
{
printf("\nNot multiplicable\n");
getch();
exit(0);
}

printf("\nMultiplicable\n");
printf("\nEnter the matrix a\n");
for(i=0;i < m;i++)
for(j=0;j < n;j++)
scanf("%d",&a[i][j]);

printf("\nEnter matrix b\n");
for(i=0;i < p;i++)
for(j=0;j < q;j++)
scanf("%d",&b[i][j]);
}

output(int x[5][5],int ro,int col)
{
int i,j;
for(i=0;i < ro;i++)
{
for(j=0;j < col;j++)
printf("%4d",x[i][j]);
printf("\n");
}
}

mat_mul()
{
int i,j,k;
for(i=0;i < m;i++)
for(j=0;j < q;j++)
{
c[i][j]=0;
for(k=0;k < p;k++)
c[i][j]+=a[i][k]*b[k][i];
}
}

Read more...

(C++) CPP Programs - 25

25. Write a C program to read ‘N’ elements by selection sort method using functions
a) To find the position of a minimum elements in an array
b) To swap the contents of two positions.

/* Selection sort*/

#include
#include
#include

void main()
{
int i,n,a[45],pos;
clrscr();

printf("\nEnter how many elements\n");
scanf("%d",&n);

printf("\nEnter the numbers one by one\n");
for(i=0;i < n;i++)
scanf("%d",&a[i]);

printf("\nThe given array is\n");
for(i=0;i < n;i++)
printf("%4d",a[i]);

for(i=0;i < n-1;i++)
{
pos=min_ele(a,n,i);
exchange(a,i,pos);
}

printf("\nArray after sorting\n");
for(i=0;i < n;i++)
printf("%4d",a[i]);
getch();
}

min_ele(int a[ ],int n,int i)
{
int pos,j;
pos=i;
for(j=i+1;j < n;j++)
if(a[pos]>a[j])
pos=j;
return(pos);
}

exchange(int a[ ],int i,int pos)
{
int temp;
temp=a[i];
a[i]=a[pos];
a[pos]=temp;
return;
}

Read more...

(C++) CPP Programs - 24

24. Write a C program to read N names, store them in the form of an array and sort them in alphabetical order. Output the given names and the sorted names with suitable headings.

/* Alphabetical order*/

#include
#include
#include

void main()
{
char names[45][43],temp[78],names1[45][56];
int i,n,j;
clrscr();

printf("\nEnter how many names\n");
scanf("%d",&n);

printf("\nEnter the names one dy one\n");
for(i=0;i < n;i++)
scanf("%s",names[i]);

for(i=0;i < n-1;i++)
for(j=0;j < n-1-i;j++)
{
if (strcmp(names[j],names[j+1])>0)
{
strcpy(temp,names[j]);
strcpy(names[j],names[j+1]);
strcpy(names[j+1],temp);
}
}
printf("\nSorted names\n");
for(i=0;i < n;i++)
printf("%s\n",names[i]);

getch();
}

Read more...

(C++) CPP Programs - 23

23. Write a C program to read a sentence and count the number of vowels and consonants in the given sentence. Output the results on two lines with suitable headings.

/* vowels and consonants*/

#include
#include
#include
#include

void main()
{
char str[50];
int i,n,vow=0,con=0;

clrscr();
printf("\nEnter an string\n");
gets(str);

printf("\nThe given string is\n");
puts(str);

n=strlen(str);

for(i=0;i < n;i++)
{
if(isalpha(str[i]))
switch(tolower(str[i]))
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u': vow++;
break;

default: con++;
}
}
printf("\nThe number of vowels=%d\n",vow);
printf("\nThe number of consonants=%d\n",con);

getch();
}

Read more...

(C++) CPP Programs - 22

22. Write a C program to read a sentence and replace lower case characters by uppercase and vice-versa. Output the given sentence as well as the case converted sentence on two different lines.



/*Upper case to Lower case and vice-versa*/



#include

#include

#include



void main()

{

char str[45];

int i,n,j;



clrscr();



printf("\nEnter a string\n");

gets(str);



printf("\nThe given string is\n");

puts(str);



n=strlen(str);



for(i=0;i < n;i++)

{

if(isupper(str[i]))

str[i]=tolower(str[i]);

else if(islower(str[i]))

str[i]=toupper(str[i]);

}

printf("\nThe new string is\n");

puts(str);



getch();

}

Read more...

(C++) CPP Programs - 21

21. Write a C program to read two strings and concatenate them (without using library functions). Output the string along with suitable messages.

/* Concatenation of 2 strings*/

#include
#include

void main()
{
char str1[67],str2[98],str[56];
int i,j;
clrscr();

printf("\nEnter string1\n");
gets(str1);

printf("\nEnter string2\n");
gets(str2);

printf("\nThe string1 is\n");
puts(str1);

printf("\nThe string2 is\n");
puts(str2);

i=0;j=0;

while(str1[i]!='\0')
{
str[j]=str1[i];
i++;
j++;
}

str[j]=2;
j++;
i=0;

while(str2[i]!='\0')
{
str[j]=str2[i];
i++;
j++;
}
str[j]='\0';

printf("\nThe new string after concatenation is\n");
puts(str);

getch();
}

Read more...

(C++) CPP Programs - 20

20. Write a C program to read a string and check whether it is palindrome or not (without using library functions). Output the given string along with suitable messages.

/*Palindrome*/

#include
#include

void main()
{
char word[56];
int n=0,i,j,palin;

clrscr();

printf("Enter a word\n\a");
gets(word);

while(word[n]!='\0')
n++;

i=0;
j=n-1;
palin=1;

while(i < j)
{
if(word[i]!=word[j])
{
palin=0;
break;
}
i++;
j--;
}
if(palin==1)
printf("%s is a palindrome\n\a",palin);
else
printf("%s is not a palindrome\n\a");

getch();
}

Read more...

(C++) CPP Programs - 19

19. Write a C program to read a matrix A(M*N), find the transpose of the given matrix and output both the matrix and the transposed matrix.

/* Transpose of a matrix*/

#include
#include

void main()
{
int a[5][5],m,n,i,j,opt;
clrscr();

printf("Enter the order of matrix\n\a");
scanf("%d%d",&m,&n);

printf("Enter the elements of a\n");
for(i=0;i < m;i++)
for(j=0;j < n;j++)
scanf("%d",&a[i][j]);

printf("The matrix a is\n");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
printf("%4d",a[i][j]);
printf("\n");
}

printf("\nThe transpose is\n");
for(i=0;i < n;i++)
{
for(j=0;j < m;j++)
printf("%4d",a[j][i]);
printf("\n");
}

getch();
}

Read more...

(C++) CPP Programs - 18

18. Write a C program to read matrixes A (M*N) and B (M*N) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrices, their sum OR difference and the trace.

/*Addition, Subtraction of matrix*/

#include
#include

void main()
{
int a[5][5],b[5][5],c[5][5],m,n,trace=0,i,j,opt;
clrscr();

printf("Enter the order of matrix\n\a");
scanf("%d%d",&m,&n);

printf("Enter the elements of a\n");
for(i=0;i < m;i++)
for(j=0;j < n;j++)
scanf("%d",&a[i][j]);

printf("Enter the elements for matrix b\n\a");
for(i=0;i < m;i++)
for(j=0;j < n;j++)
scanf("%d",&b[i][j]);

printf("\n1.Addition\n2.Subtraction\nEnter any one option\n");
scanf("%d",&opt);

printf("The matrix a is\n");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
printf("%4d",a[i][j]);
printf("\n");
}

printf("The matrix b is\n");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
printf("%4d",b[i][j]);
printf("\n");
}

if(opt==1)
{
printf("The resultant matrix c is\n");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
c[i][j]=a[i][j]+b[i][j];
}
}

else
{
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
c[i][j]=a[i][j]-b[i][j];
}
}
printf("The obtained matrix c is\n\a");
for(i=0;i < m;i++)
{
for(j=0;j < n;j++)
printf("%4d",c[i][j]);
printf("\n");
}
if(m==n)
{
printf("The trace exist\n");
for(i=0;i < m;i++)
trace+=c[i][i];
printf("The trace =%d\n",trace);
}

getch();
}

Read more...

(C++) CPP Programs - 17

17. Write a C program to evaluate the given polynomial,

p(x) = anxn + an-1xn-1 + an-2xn-2………….+ a1x + a0, by reading its co-efficient into an array.

[HINT: rewrite the polynomial as

p(x) = a0+x(a1+x(a1+x(a2+x(a3+x(a4+…………..x(an-1+xan)))))

and evaluate the function starting from inner loop.]

/*Polynomial*/

#include

#include

#include

void main()

{

float a[34],psum=0,term,x;

int i,n;

clrscr();

printf("Enter the value for x\n");

scanf("%f",&x);

printf("Enter the n value\n\a");

scanf("%d",&n);

printf("Enter the %d co-efficients\n",n+1);

for(i=0;i < = n;i++)

scanf("%f",&a[i]);

for(i=n;i >= 0;i--)

{

term=a[i]*pow(x,i);

psum+=term;

}

printf("The sum of polynomial of given terms=%f\n",psum);

getch();

}

Read more...

(C++) CPP Programs - 16

16. Write a C program to input n real numbers and to find Mean, Variance and Standard deviation,

where Mean=( x[i] ) / n, Variance = ∑ ( x[i] – Mean ) 2 /n, Standard deviation = √(Variance) for 1<=i<=n. Output the computed results on different lines.

/*Program to find mean,std_dev,variance*/

#include

#include

#include

void main()

{

float x[45],nr=0.0,std_dev,var,mean,sum=0.0;

int n,i;

clrscr();

printf("Enter how many elements?\n\a");

scanf("%d",&n);

printf("Enter the numbers one by one\n\a");

for(i=0;i <>

scanf("%f",&x[i]);

for(i=0;i <>

sum+=x[i];

mean=sum/n;

for(i=0;i <>

nr+=pow((x[i]-mean),2);

var=nr/n;

std_dev=sqrt(var);

printf("Mean of all elements=%f\n",mean);

printf("Standard deviation of elements=%f\n",std_dev);

printf("Variance=%f\n",var);

getch();

}

Read more...

(C++) CPP Programs - 15

15. Write a C program to accept N numbers sorted in ascending order and to search for a given number using Binary search. Report success or failure in the form of suitable messages.

/* Binary Search*/

#include

#include

void main()

{

int a[34],first,last,mid,n,key,i,pos=0;

clrscr();

printf("Enter no of digits:\n\a");

scanf("%d",&n);

printf("Enter the elements one by one\n");

for(i=0;i <>

scanf("%d",&a[i]);

printf("The key element to be searched\n");

scanf("%d",&key);

printf("\nArray after sorting\n");

for(i=0;i <>

printf("%4d",a[i]);

first=0;

last=n-1;

while(first < = last)

{

mid=(first+last)/2;

if(a[mid] <>

last=mid-1;

else if(a[mid] > key)

first=mid+1;

else

{

pos=mid;

break;

}

}

if(a[mid]==key)

printf("\n Element found at location %d\n\a",pos);

else

printf("\nElement not found\n\a");

getch();

}

Read more...

(C++) CPP Programs - 14

14. Write a C program to sort n numbers in ascending order using Bubble sort and print both the given array and the sorted array with suitable headings.

/* Bubble sort*/

#include

#include

void main()

{

int n,i,j,a[30],temp;

clrscr();

printf("Enter how many digits?\n\a");

scanf("%d",&n);

printf("Enter the numbers one by one\n\a");

for(i=0;i <>

scanf("%d",&a[i]);

printf("\nThe array before sorting\n\a");

for(i=0;i <>

printf("%4d",a[i]);

/*bub now*/

for(i=0;i <>

{

for(j=0;j <>

if(a[j] > a[j+1])

{

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

}

}

printf("\nThe array after sorting\n\a");

for(i=0;i <>

printf("%4d",a[i]);

getch();

}

Read more...

(C++) CPP Programs - 13

13. Write a C program to input n numbers (integer or real) and store them in an array. Conduct a linear search for a given key number and report success or failure in the form of suitable message.

/* Linear Search*/

#include

#include

void main()

{

int a[32],pos=0,scount=0,key=0,n,i;

clrscr();

printf("Enter the no. of digits\n\a");

scanf("%d",&n);

printf("Enter the elements one by one\n");

for(i=0;i <>

scanf("%d",&a[i]);

printf("Enter the key element to be searched\n\a");

scanf("%d",&key);

for(i=0;i <>

{

if(a[i]==key)

{

scount=1;

pos=i;

}

}

if(scount==1)

printf("Element found at %d and the element is %d\n\a",pos,key);

else

printf("Element not found\n\a");

getch();

}

Read more...

(C++) CPP Programs - 12

12. Write a C program to read N integers (0, +ve and –ve) into an array A and to find

a) Sum of negative numbers.

b) Sum of positive numbers.

c) Average of all numbers.

Output the various results computed with proper headings.

/* Addition and Subtraction of array elements*/

#include

#include

#include

void main()

{

int a[44],psum=0,nsum=0,n,i;

float avg;

clrscr();

printf("Enter the no. of elements\n\a");

scanf("%d",&n);

printf("Enter the elements one by one\n\a");

for(i=0;i

scanf("%d",&a[i]);

for(i=0;i

{

if(a[i]>0)

psum+=a[i];

else if(a[i]<0)

nsum+=a[i];

}

avg=(fabs)(psum+nsum)/n;

printf("Sum of positive numbers=%d\n\a",psum);

printf("Sum of negative numbers=%d\n\a",nsum);

printf("Average of all numbers=%f\n\a",avg);

getch();

}

Read more...

(C++) CPP Programs - 11

11. Write a C program to generate and print prime numbers in a given range. Also print the number of prime numbers.

/*Print prime numbers in a given range*/

#include

#include

void main()

{

int i,j,m,n,found,count=0;

clrscr();

printf("Enter the lower range and upper range\n\a");

scanf("%d%d",&m,&n);

printf("List of the numbers in the given range\n\a");

for(i=m;i<=n;i++)

{

found=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

{

found=0;

break;

}

}

if(found==1)

{

printf("%d\n",i);

count++;

}

}

printf("Total prime numbers between %d and %d=%d\n\a",m,n,count);

getch();

}

Read more...

(C++) CPP Programs - 10

10. Write a C program to find whether the given number is prime or not and output the given number with suitable message.

/* Prime or Not*/

#include

#include

void main()

{

int i,k,num;

clrscr();

printf("Enter the value to check whether it is prime or not\n");

scanf("%d",&num);

k=0;

for(i=2;i<=num/2;i++)

{

if(num%i==0)

{

k=1;

break;

}

}

if(k==0)

printf("%d is a prime number\n\a",num);

else

printf("%d is not a prime number\n\a",num);

getch();

}

Read more...

(C++) CPP Programs - 9

9. Write a C program to find the value of Cos(x) using the series

Cos(x) = 1 - x2/2! + x4/4! + x6/6!.......... upto N terms accuracy( without using user defined function. Also print Cos(x) using library function)

/*Cosine Series*/

#include

#include

#include

void main()

{

float xd,xr,acc,term,sum=0;

int i,n,option;

clrscr();

printf("1.Number of terms\n2.Accuracy\nEnter the option\n");

scanf("%d",&option);

if(option==1)

{

printf("Enter number of terms\n\a");

scanf("%d",&n);

printf("Enter angle in degrees\n\a");

scanf("%f",&xd);

xr=(xd*3.142)/180.0;

term=1;

sum=1;

for(i=1;i<=n;i++)

{

sum=-(term*xr*xr)/((2*i)*(2*i-1));

sum+=term;

}

printf("sum of cosine series:cos(%f)=%f\n\a",xd,sum);

printf("Using lib function:cos(%f)=%f\n\a",xd,cos(xr));

}

else if(option==2)

{

printf("Enter the angles in degrees\n\a");

scanf("%f",&xd);

printf("Enter the acc.level[0.01-0.000001]\n\a");

scanf("%f",&acc);

xr=(xd*3.142)/180.0;

sum=1;

term=1;

i=1;

do

{

term=-(term*xr*xr)/((2*i)*(2*i-1));

sum+=term;

i++;

}while(fabs(term)>acc);

printf("cosine series:cos(%f)=%f\n\a",xd,sum);

printf("Lib function:cos(%f)=%f\n\a",xd,cos(xr));

}

getch();

}

Read more...

(C++) CPP Programs - 8

8. Write a C program to find the value of Sin(x) using the series

Sin(x) = x - x3/3! + x5/5! + x7/7!.......... upto N terms accuracy( without using user defined function. Also print Sin(x) using library function)

/* Sine series*/

#include

#include

#include

void main()

{

float xd,xr,acc,term,sum=0;

int i,n,option;

clrscr();

printf("1.number of terms\n2.accuracy\nEnter the option\n");

scanf("%d",&option);

if(option==1)

{

printf("Enter number of terms\n\a");

scanf("%d",&n);

printf("Enter angle in degrees\n\a");

scanf("%f",&xd);

xr=(xd*3.142)/180.0;

term=xr;

sum=xr;

for(i=1;i<=n;i++)

{

sum=-(term*xr*xr)/((2*i)*(2*i+1));

sum+=term;

}

printf("sum of sine series:sin(%f)=%f\n\a",xd,sum);

printf("Using lib function:sin(%f)=%f\n\a",xd,sin(xr));

}

else if(option==2)

{

printf("Enter the angles in degrees\n\a");

scanf("%f",&xd);

printf("Enter the acc.level[0.01-0.000001]\n\a");

scanf("%f",&acc);

xr=(xd*3.142)/180.0;

sum=xr;

term=xr;

i=1;

do

{

term=-(term*xr*xr)/((2*i)*(2*i+1));

sum+=term;

i++;

}while(fabs(term)>acc);

printf("sine series:sin(%f)=%f\n\a",xd,sum);

printf("Lib function:sin(%f)=%f\n\a",xd,sin(xr));

}

getch();

}

Read more...

Chitika

About This Blog

Followers

Blog Archive

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP