#include"stdio.h"
int main()
{
FILE *fpRead;
char ch;
int No_tab=0;
fpRead=fopen("E://WORK//FileTab//a.txt","r");
if(fpRead==NULL)
{
printf("File cant Opened");
}else if(fpRead!=NULL)
{
printf("Opened correctly...");
}
ch=fgetc(fpRead);
while(1)
{
if(ch==EOF)
break;
if(ch=='\t')
{
No_tab++;
}
ch=fgetc( fpRead );
}
fclose(fpRead);
printf("Total Numberof Tabs in file %d",No_tab);
return 0;
}
Wednesday, December 23, 2009
Monday, December 7, 2009
fast process
http://www.microsoft.com/windows/windowsmedia/howto/articles/optimize_web.aspx#performance_faststreaming
Monday, October 19, 2009
proverb meanings l-z
Proverb
Explanation / Meaning
L
Laughter is the best medicine.
Learn to walk before you run. Don't rush into doing something until you know how to do it.
Learning is a treasure that will follow its owner
everywhere. Education is something you keep forever.
Least said soonest mended. The more discreet you are, the less damage you cause.
Let bygones be bygones. Let's forgive and forget past quarrels.
Liars need good memories.
Lightning never strikes in the same place twice An unusual event is not likely to occur again in exactly the same circumstances.
Like father, like son. A son's character can be expected to resemble his father's.
Look before you leap. Consider possible consequences before taking action.
Loose lips sink ships. Disclosing important information ( to the enemy or a competitor) could result in large
losses.
Losers weepers, finders keepers. If you lose something you weep, if you find something you keep it.
Love is blind. A person in love does not see the faults of the person he/she loves.
M
Make a silk purse out of a sow's ear Manage to produce something good using poor material.
Man is the head of the family;
woman is the neck that turns the head.
Man proposes, God disposes. Our destiny depends on God's will.
Manners make the man. Possibly: a person's manners show their origins.
Many hands make light work. Sharing work makes work easier.
Marry in haste, repent at leisure.
If you get married too quickly, you may spend all your life regretting it.
Memory is the treasure of the mind.
Men make houses, women make homes.
Might as well be hanged for a sheep as (for) a lamb If the penalty is going to be the same, you might as well commit the greater offence.
Money begets money. If you have money you can make more money.
Money doesn't grow on trees. You shouldn't waste money because it is not plentiful.
Money is the root of all evil. Money is the main cause of wrongdoing and problems.
N
Necessity is the mother of invention. The need for something forces people to find a way of obtaining it.
Need teaches a plan. Necessity will make you find a solution.
Never put off till tomorrow what can be done today Don't postpone something you can do now.
Never say die. Never give up.
Nobody is perfect.
No man can serve two masters. It's impossible to follow instructions from two different sources.
No man is an island. We all need other people.
No news is good news. If the news was bad, we would hear of it. Since we have heard nothing,
we can assume that all is well.
No smoke without fire. There could be some truth in the rumour...
No wind, no waves. Similar to : 'no smoke without fire'.
Nothing ventured, nothing gained. You cannot expect to achieve anything if you don't take risks.
O Once bitten, twice shy. After an unpleasant experience, people are careful to avoid something similar.
One father is more than a hundred schoolmasters.
One good turn deserves another. You should be helpful to someone who helps you.
One of these days is none of these days. 'One of these days' remains vague.
One today is worth two tomorrow.
What you have today is better than what is promised or hoped for.
One man's meat is another man's poison People don't always like the same things.
One man's trash is another man's treasure. What is useless to one person could be valuable to another.
One swallow doesn't make a summer. A single satisfactory event does not mean that all the others will be as good.
Only real friends will tell you when your face is
dirty. Only a real friend will tell you the truth.
Opportunity seldom knocks twice. Don't miss opportunities that come along.
Out of the mouths of babes and sucklings Children often speak wisely.
Out of sight, out of mind.
We tend to forget people who are absent.
P Penny wise, pound foolish. Refers to a person who is careful about spending small amounts of money, but
not careful about spending large amounts of money.
People who live in glass houses should not throw
stones. One should not criticize others for faults similar to one's own.
Practice makes perfect.
Doing something repeatedly is the only way to become good at it.
Practise what you preach Do yourself what you advise others to do.
Prevention is better than cure
It is easier to prevent something from happening than to repair the damage or cure the
disease later.
Pride comes before a fall. Don't be too self-confident or proud; something may happen to make you look foolish.
Procrastination is the thief of time Delaying an action for too long is a waste of time.
Put all your eggs in one basket Risk everything by relying on one plan (by putting all one's money in one business).
R Revenge is sweet. There is satisfaction in returning an injury.
Rome was not built in a day. It takes a long time to do a job properly. You should not expect to do it quickly.
S
Save me from my friends. Friends can be more dangerous than enemies.
Saying is one thing, doing is another. People don't always do what they announce.
Short reckonings make long friends. Debts paid quickly encourage friendship.
Sickness in the body brings sadness to the mind.
Snug as a bug in a rug. Feeling very comfortable.
Spare the rod and spoil the child If you don't punish a child when he does wrong, you will spoil his character.
Sticks and stones will break my bones but names
will never hurt me
Physical attacks may harm me, but cruel words will not.
Still waters run deep. A quiet person can have much knowledge or wisdom.
A stitch in time saves nine It's better to deal with a problem in its early stages, because if you don't, it will get
worse.
Stolen fruit is the sweetest. What is forbidden is the most tempting.
T Tall oaks grow from little acorns. Great things may come from small beginnings.
The apple doesn't fall far from the tree. Children resemble their parents.
The best advice is found on the pillow. After a good night's sleep we may find an answer to our problem.
The devil looks after his own. Success comes to those who deserve it least .
The devil makes work for idle hands People who have no work, or are idle, often get into or make trouble.
The die is cast. A decision has been made and it's impossible to change it.
The early bird catches the worm. If you want to do something successfully, you should do it as soon as you can.
The end justifies the means. Wrong or unfair methods may be used if the result of the action is good.
The first step is the hardest. The most difficult thing is to begin.
The more haste, the less speed. A person makes more progress if they do things less quickly.
The more you have, the more you want.
The mouse that has but one hole is quickly taken. If you depend on just one thing, and it fails you, you will have no alternatives.
The pen is mightier than the sword Words and communication have greater effect than war and fighting.
The proof of the pudding is in the eating. The real value of something can be judged only after it has been tried or tested.
The road to hell is paved with good intentions. It's not enough to intend to do something, you must actually do it.
The tongue wounds more than a lance. Insults can be more hurtful than physical injuries.
The truth is in the wine. People speak more freely under the influence of alcohol.
The way to a man's heart is through his stomach. Feed a man well and he will love you.
The wish is father to the thought.
You think that something is true because you want it to be so.
There is a black sheep in every flock. There is always one who doesn't behave or perform like the others.
There is a trick in every trade. There is an established way of doing things.
There is no fool like an old fool. A older person is expected to behave more sensibly.
There is safety in numbers Being in a crowd makes you feel more confident.
Time and tide wait for no man. Delaying a decision will not prevent events from taking place.
Time has wings.
Time goes by quickly.
Time is money. Time is valuable and should not be wasted.
To err is human, to forgive divine It is human nature to make mistakes, therefore one should forgive.
Too many cooks spoil the broth.
If too many people are involved in something, it will not be done properly.
(Humoristic version of above :
Too many clicks spoil the browse!)
Trust not a horse's heel nor a dog's tooth.
Truth is stranger than fiction. Events in real life are sometimes stranger than in fiction.
Two wrongs don't make a right It is wrong to harm someone because they have harmed you.
U
Union is strength.
V
Variety is the spice of life.
Doing a lot of different things makes life more interesting.
Virtue is its own reward. You should not expect praise for acting in a correct or moral way.
W Walls have ears. Be careful. People could be listening.
Waste not, want not. If you never waste anything, you will have it when you need it.
What the eye doesn't see, the heart doesn't grieve
over. If a person doesn't know about something, it cannot hurt them.
What a man says drunk, he thinks sober.
People speak more freely under the influence of alcohol.
What soberness conceals, drunkenness reveals. People are less discreet under the influence of alcohol.
When the cat's away, the mice play. People misbehave when their boss, or the person in authority, is absent.
When in Rome, do as the Romans do. You should adopt the customs of the people or country you are visiting,
and behave in the same way.
When poverty come in the door, love goes out the
window.
Where there's life there's hope.
Where there's a will, there's a way. A person with determination will find a way of doing something.
Who makes himself a sheep will be eaten by the wolves. Possible interpretation: an easily influenced person can be mislead.
Wisdom is better than strength.
Wonders will never cease! Expresses surprise at an unexpected pleasure or event (ironic).
Worry often gives a small thing a big shadow. Worrying over small details can make them seem worse.
Y
You are what you eat. What you eat has an effect on your well-being.
You are never too old to learn.
You can lead a horse to water but you can't
make it drink. You can offer someone an opportunity to do something but you can't force them.
You can't teach an old dog new tricks. A person who is used to doing things a certain way cannot change.
You never know what you can do until you try. Try first before deciding not to do something.
You scratch my back and I'll scratch yours. You help me and I'll help you.
Explanation / Meaning
L
Laughter is the best medicine.
Learn to walk before you run. Don't rush into doing something until you know how to do it.
Learning is a treasure that will follow its owner
everywhere. Education is something you keep forever.
Least said soonest mended. The more discreet you are, the less damage you cause.
Let bygones be bygones. Let's forgive and forget past quarrels.
Liars need good memories.
Lightning never strikes in the same place twice An unusual event is not likely to occur again in exactly the same circumstances.
Like father, like son. A son's character can be expected to resemble his father's.
Look before you leap. Consider possible consequences before taking action.
Loose lips sink ships. Disclosing important information ( to the enemy or a competitor) could result in large
losses.
Losers weepers, finders keepers. If you lose something you weep, if you find something you keep it.
Love is blind. A person in love does not see the faults of the person he/she loves.
M
Make a silk purse out of a sow's ear Manage to produce something good using poor material.
Man is the head of the family;
woman is the neck that turns the head.
Man proposes, God disposes. Our destiny depends on God's will.
Manners make the man. Possibly: a person's manners show their origins.
Many hands make light work. Sharing work makes work easier.
Marry in haste, repent at leisure.
If you get married too quickly, you may spend all your life regretting it.
Memory is the treasure of the mind.
Men make houses, women make homes.
Might as well be hanged for a sheep as (for) a lamb If the penalty is going to be the same, you might as well commit the greater offence.
Money begets money. If you have money you can make more money.
Money doesn't grow on trees. You shouldn't waste money because it is not plentiful.
Money is the root of all evil. Money is the main cause of wrongdoing and problems.
N
Necessity is the mother of invention. The need for something forces people to find a way of obtaining it.
Need teaches a plan. Necessity will make you find a solution.
Never put off till tomorrow what can be done today Don't postpone something you can do now.
Never say die. Never give up.
Nobody is perfect.
No man can serve two masters. It's impossible to follow instructions from two different sources.
No man is an island. We all need other people.
No news is good news. If the news was bad, we would hear of it. Since we have heard nothing,
we can assume that all is well.
No smoke without fire. There could be some truth in the rumour...
No wind, no waves. Similar to : 'no smoke without fire'.
Nothing ventured, nothing gained. You cannot expect to achieve anything if you don't take risks.
O Once bitten, twice shy. After an unpleasant experience, people are careful to avoid something similar.
One father is more than a hundred schoolmasters.
One good turn deserves another. You should be helpful to someone who helps you.
One of these days is none of these days. 'One of these days' remains vague.
One today is worth two tomorrow.
What you have today is better than what is promised or hoped for.
One man's meat is another man's poison People don't always like the same things.
One man's trash is another man's treasure. What is useless to one person could be valuable to another.
One swallow doesn't make a summer. A single satisfactory event does not mean that all the others will be as good.
Only real friends will tell you when your face is
dirty. Only a real friend will tell you the truth.
Opportunity seldom knocks twice. Don't miss opportunities that come along.
Out of the mouths of babes and sucklings Children often speak wisely.
Out of sight, out of mind.
We tend to forget people who are absent.
P Penny wise, pound foolish. Refers to a person who is careful about spending small amounts of money, but
not careful about spending large amounts of money.
People who live in glass houses should not throw
stones. One should not criticize others for faults similar to one's own.
Practice makes perfect.
Doing something repeatedly is the only way to become good at it.
Practise what you preach Do yourself what you advise others to do.
Prevention is better than cure
It is easier to prevent something from happening than to repair the damage or cure the
disease later.
Pride comes before a fall. Don't be too self-confident or proud; something may happen to make you look foolish.
Procrastination is the thief of time Delaying an action for too long is a waste of time.
Put all your eggs in one basket Risk everything by relying on one plan (by putting all one's money in one business).
R Revenge is sweet. There is satisfaction in returning an injury.
Rome was not built in a day. It takes a long time to do a job properly. You should not expect to do it quickly.
S
Save me from my friends. Friends can be more dangerous than enemies.
Saying is one thing, doing is another. People don't always do what they announce.
Short reckonings make long friends. Debts paid quickly encourage friendship.
Sickness in the body brings sadness to the mind.
Snug as a bug in a rug. Feeling very comfortable.
Spare the rod and spoil the child If you don't punish a child when he does wrong, you will spoil his character.
Sticks and stones will break my bones but names
will never hurt me
Physical attacks may harm me, but cruel words will not.
Still waters run deep. A quiet person can have much knowledge or wisdom.
A stitch in time saves nine It's better to deal with a problem in its early stages, because if you don't, it will get
worse.
Stolen fruit is the sweetest. What is forbidden is the most tempting.
T Tall oaks grow from little acorns. Great things may come from small beginnings.
The apple doesn't fall far from the tree. Children resemble their parents.
The best advice is found on the pillow. After a good night's sleep we may find an answer to our problem.
The devil looks after his own. Success comes to those who deserve it least .
The devil makes work for idle hands People who have no work, or are idle, often get into or make trouble.
The die is cast. A decision has been made and it's impossible to change it.
The early bird catches the worm. If you want to do something successfully, you should do it as soon as you can.
The end justifies the means. Wrong or unfair methods may be used if the result of the action is good.
The first step is the hardest. The most difficult thing is to begin.
The more haste, the less speed. A person makes more progress if they do things less quickly.
The more you have, the more you want.
The mouse that has but one hole is quickly taken. If you depend on just one thing, and it fails you, you will have no alternatives.
The pen is mightier than the sword Words and communication have greater effect than war and fighting.
The proof of the pudding is in the eating. The real value of something can be judged only after it has been tried or tested.
The road to hell is paved with good intentions. It's not enough to intend to do something, you must actually do it.
The tongue wounds more than a lance. Insults can be more hurtful than physical injuries.
The truth is in the wine. People speak more freely under the influence of alcohol.
The way to a man's heart is through his stomach. Feed a man well and he will love you.
The wish is father to the thought.
You think that something is true because you want it to be so.
There is a black sheep in every flock. There is always one who doesn't behave or perform like the others.
There is a trick in every trade. There is an established way of doing things.
There is no fool like an old fool. A older person is expected to behave more sensibly.
There is safety in numbers Being in a crowd makes you feel more confident.
Time and tide wait for no man. Delaying a decision will not prevent events from taking place.
Time has wings.
Time goes by quickly.
Time is money. Time is valuable and should not be wasted.
To err is human, to forgive divine It is human nature to make mistakes, therefore one should forgive.
Too many cooks spoil the broth.
If too many people are involved in something, it will not be done properly.
(Humoristic version of above :
Too many clicks spoil the browse!)
Trust not a horse's heel nor a dog's tooth.
Truth is stranger than fiction. Events in real life are sometimes stranger than in fiction.
Two wrongs don't make a right It is wrong to harm someone because they have harmed you.
U
Union is strength.
V
Variety is the spice of life.
Doing a lot of different things makes life more interesting.
Virtue is its own reward. You should not expect praise for acting in a correct or moral way.
W Walls have ears. Be careful. People could be listening.
Waste not, want not. If you never waste anything, you will have it when you need it.
What the eye doesn't see, the heart doesn't grieve
over. If a person doesn't know about something, it cannot hurt them.
What a man says drunk, he thinks sober.
People speak more freely under the influence of alcohol.
What soberness conceals, drunkenness reveals. People are less discreet under the influence of alcohol.
When the cat's away, the mice play. People misbehave when their boss, or the person in authority, is absent.
When in Rome, do as the Romans do. You should adopt the customs of the people or country you are visiting,
and behave in the same way.
When poverty come in the door, love goes out the
window.
Where there's life there's hope.
Where there's a will, there's a way. A person with determination will find a way of doing something.
Who makes himself a sheep will be eaten by the wolves. Possible interpretation: an easily influenced person can be mislead.
Wisdom is better than strength.
Wonders will never cease! Expresses surprise at an unexpected pleasure or event (ironic).
Worry often gives a small thing a big shadow. Worrying over small details can make them seem worse.
Y
You are what you eat. What you eat has an effect on your well-being.
You are never too old to learn.
You can lead a horse to water but you can't
make it drink. You can offer someone an opportunity to do something but you can't force them.
You can't teach an old dog new tricks. A person who is used to doing things a certain way cannot change.
You never know what you can do until you try. Try first before deciding not to do something.
You scratch my back and I'll scratch yours. You help me and I'll help you.
proverb meanings
www.learn-english-today.com
• lessons-exercises • vocabulary • business english • idioms • wordgames • phrasal verbs • links-resources • fun • news • home •
ENGLISH PROVERBS & SAYINGS
(proverbs and sayings commonly used in everyday conversation)
What is a proverb? A proverb is a short well-known expression that states a general truth or gives advice.
What is a saying? A saying is a well-known expression, or a remark often made, also known as a proverb.
Alphabetical list of proverbs - A - K
with an explanation where necessary
Proverb
Explanation / Meaning
A
Absence makes the heart grow fonder. When you are away from someone you love, you love them even more.
Accidents will happen. Some unfortunate events must be accepted as inevitable.
Actions speak louder than words. What a person actually does is more important that what they say they will do.
Advice is cheap. It doesn't cost anything to offer advice.
Advice is least heeded when most needed. When a problem is serious, people often do not follow the advice given.
Advisers run no risks. It's easier to give advice than to act.
All cats are grey in the dark. People are undistinguished until they have made a name.
All good things come to those who wait. Patience brings rewards.
All that glitters is not gold. Appearances can be deceptive.
All days are short to Industry and long to Idleness. Time goes by slowly when you have nothing to do.
All is fair in love and war Things that are done in love or war can often be excused.
All's well that ends well There is a solution to everything even though there are doubts.
All that glitters is not gold. What look good on the outside may not be so in reality.
All things grow with time - except grief. As time goes by, grief subsides little by little.
All things are difficult before they are easy. With practice things become easier.
All work and no play makes Jack a dull boy. Everybody needs a certain amount of relaxation. It is not good to work all
the time.
An apple a day keeps the doctor away.* Eating an apple every day can help to keep you healthy.
Other interpretation : A small preventive treatment wards off serious problems.
An empty purse frightens away friends.
When one's financial situation deteriorates, friends tend to disappear.
An Englishman's home is his castle. An Englishman's home is a place where he feels safe, enjoys privacy
and can do as he wishes.
An idle brain is the devil's workshop. When you work you avoid temptation.
An onion a day keeps everyone away.* *A humoristic version of "an apple a day..."
An ounce of prevention is worth a pound of cure. It is easier to prevent something from happening than to repair the damage or
cure the disease later.
Anger is the one thing made better by delay. When you are angry, it is best not to speak or act immediately.
Any time means no time. If the date of an event remains vague, it will never happen.
April showers bring May flowers. Something bad or unpleasant today may bring good things in the future.
A bad tree does not yield good apples.
A bad workman blames his tools. Blaming the tools for bad workmanship is an excuse for lack of skill.
A bird in hand is worth two in a bush. It's better to keep what you have than to risk losing it by searching for something better.
A broken friendship may be soldered but will
never be sound. Friendships can be rebuilt after a dispute but will never be as strong as before.
A burden of one's own choice is not felt. Something difficult seems easier when it is done voluntarily.
A burnt child dreads the fire. A bad experience will make people stay away from certain things.
A cat has nine lives. 1) Cats can survive many accidents because they land on their feet without injury.
2) Three lives = 3 years to play, 3 years to stray, 3 years to stay.
A chain is no stronger than its weakest link. The strength of a group depends on each individual member.
A change is as good as a rest.
A dry March, a wet April and a cool May
fill barn and cellar and bring much hay.
A fault confessed is half redressed. Confession is the beginning of forgiveness.
A flower blooms more than once. If you miss an occasion, you can avail of it at another time.
A fool and his money are soon (easily) parted. A foolish person usually spends money carelessly.
A fool at forty is a fool forever. If a person hasn't matured by the age of 40, they never will.
A friend in need is a friend indeed. Someone who helps you when you are in trouble is a real friend.
A friend to all is a friend to none. Someone who is a friend to everyone makes none of them feel special.
A good example is the best sermon. Giving an example is better than giving advice.
A good beginning makes a good end.
If a task is carefully planned, there's a better chance that it will be done well.
A good conscience is a soft pillow. You sleep well when you have nothing to feel guilty about.
A guilty conscience needs no accuser.
A leopard cannot change its spots. It is not possible for a bad or unpleasant person to become good or pleasant.
A loaded wagon makes no noise. Really wealthy don't talk about money.
A loveless life is a living death.
A man can die but once.
A man is as old as he feels himself to be.
A man is known by the company he keeps. A person's character is judged by the type of people with whom they spend
their time.
A monkey in silk is a monkey no less. No matter how someone dresses, it's the same person underneath.
A new broom sweeps clean. A newly-appointed person makes changes energetically.
A rising tide lifts all boats. Describes something that will be helpful to all.
A rolling stone gathers no moss. If a person keeps moving from place to place, they gain neither friends nor
possessions.
Another interpretation is that, by moving often, one avoids being tied down!
A rotten apple spoils the barrel. A dishonest or immoral person can have a bad influence on a group.
A smooth sea never made a skilled mariner. Overcoming adversity leads to competence.
A stitch in time saves nine. It's better to deal with a problem at an early stage, to prevent it from getting
worse.
A stumble may prevent a fall. Correcting a small mistake may help you to avoid making a bigger one.
A swallow does not make the summer. One good event does not mean that everything is alright.
A tree is known by its fruit. A man is judged by his actions.
A watched pot never boils If you wait anxiously for something, it seems to take a long time.
A young idler, an old beggar. If you don't work, you won't have any money when you're old.
After dinner rest a while, after supper walk a mile.
As you sow, so shall you reap You have to accept the consequences of your actions.
B Bad news travels fast.
People tend to circulate bad news (accidents, illness etc.) very quickly.
Beauty is only skin deep.
A person's character is more important than their appearance.
Beauty is in the eye of the beholder.
Different people have different tastes.
Beauty is the wisdom of women. Wisdom is the
beauty of men.
Be swift to hear, slow to speak.
Listen carefully before speaking.
Better be alone than in bad company.
Be careful in the choice of the people you associate with.
Better be the head of a dog then the tail of a lion.
It's better to be the leader of a small group than a subordinate in a bigger one.
Better flatter a fool than fight him.
It's better to avoid disputes with stupid people.
Better the devil you know than the devil you
don't know
It's better to deal with somebody difficult but familiar, than change and risk dealing
with somebody worse.
Better late than never.
It's better to do something, even if it's late, than not do it at all.
Better lose the saddle than the horse.
It's better to stop and accept a small loss, rather than continue and risk losing
everything.
Better safe than sorry It's better to be too careful than to be careless and regret it later.
Better untaught than ill-taught It's better not to be taught at all than to be taught badly.
Birds of a feather flock together.
People of the same sort are usually found together.
Blood is thicker than water Family relationships are stronger than relationships with other people.
Blood will out. A person's background or education will eventually show.
C Charity begins at home. A person's first duty is to help and care for his own family.
Children and fools tell the truth.
Cleanliness is next to godliness. A clean body is just as important as a pure soul.
Clear moon, frost soon. If the atmosphere is clear, frost may form.
Clothes don't make the man. Appearances can be deceiving.
Constant occupation prevents temptation. When you work you avoid temptation.
D
Dead men tell no tales A dead person cannot cause difficulties by revealing something that it would be preferable to conceal.
Diamond cuts diamond. Refers to two people equally matched in wit or cunning.
Diligence is the mother of good fortune. Hard work brings rewards.
Discretion is the better part of valour It is useless to take unnecessary risks.
Diseases of the soul are more dangerous than
those of the body.
Distance makes the heart grow fonder. When you are separated from the person you love, your feelings are even stronger.
Dogs of the same street bark alike.
People from the same background have the same behaviour.
Don't bark if you can't bite. Don't complain if you can't enforce your point of view.
Don't count your chickens before they're hatched. You must not be too confident that something will be successful.
Don't dig your grave with your own knife and fork. Don't do something yourself which causes your own downfall.
Don't judge a book by its cover. Don't judge by appearances.
E
Early to bed and early to rise makes a man healthy,
wealthy and wise.
Easier said than done. What is suggested sounds easy but it is more difficult to actually do it.
Elbow grease is the best polish. Hard work gives the best results.
Empty vessels make the most noise. The least intelligent people are often the most talkative or noisy.
Every ass likes to hear himself bray. People like to listen to themselves talking.
Every cloud has a silver lining There is a positive or hopeful side to every unpleasant situation.
Every man for himself. You must think of your own interests before the interests of others.
Every man has his price. Everyone's loyalty can be bought for a price.
Every man is the architect of his own fortune. Life is what you make it.
Every path has its puddle. Progress is rarely without difficulty.
Every why has a wherefore. There is an explanation for everything.
Everything in the garden is rosy. Everything is satisfactory.
Experience is the father of wisdom.
Experience and knowledge result in better judgement.
F Facts speak louder than words.
People show what they are really like by what they do, rather than by what
they say.
Failure teaches success.
False friends are worse than open enemies.
Familiarity breeds contempt Knowing somebody very well may lead to a lack of respect for them.
Fine words butter no parsnips. No amount of talking can replace action.
First come, first served. The first person in the line will be attended to first.
Fool me once, shame on you;
fool me twice, shame on me. One should learn from one's mistakes.
Fools rush in where angels fear to tread Inexperienced people act in situations that more intelligent people would avoid
Friendship is love with understanding.
G Gardens are not made by sitting in the shade. Nothing is achieved without effort.
Give someone an inch and they will take a
mile (or yard). Give someone a little and they will want more - some people are never satisfied.
Give someone enough rope and they will hang
themselves. Give someone enough time and freedom and they will get into trouble.
God helps those who help themselves.
Good and quickly seldom meet. A well-done job takes time.
Good management is better than good income.
Great minds think alike.
Great oaks grow from little acorns. Large successful operations can begin in a small way.
Grief divided is made lighter
H Half a loaf is better than none. You should be grateful for something, even if it's not as much as you wanted.
Hard words break no bones.
Haste makes waste. If something is done too quickly, it may be done carelessly and need to be redone.
Hatred is a blind as love. A person who feels hatred does not see any qualities in the person he/she hates.
He has enough who is content.
He who hesitates is lost. If you delay your decision too long, you may miss a good opportunity.
He who is everywhere is nowhere. It's not good to do too many things at the same time.
He who knows nothing, doubts nothing. Knowledge leads us to make choices.
He who pays the piper calls the tune. The person who provides the money for something should control how it is spent
He who plays with fire gets burnt.
If you behave in a risky way, you are likely to have problems.
He who wills the end wills the means. If you are determined to do something you will find a way.
He laughs best who laughs last. Don't express your joy, or your triumph, too soon!
Health is better than wealth.
Home is where the heart is. You call home the place where the people you love are.
Honesty is the best policy.
Honey catches more flies than vinegar. You can obtain more cooperation from others by being nice.
However long the night, the dawn will break Bad things don't last forever.
I
In times of prosperity friends are plentiful. You have many friends when you have no difficulties.
If a camel gets his nose in a tent, his body will
follow.
If you let something intrusive enter your life, your life will become difficult .
If in February there be no rain, 'tis neither good
for hay nor grain.
If you are patient in one moment of anger,
you will avoid 100 days of sorrow.
If you chase two rabbits, you will not catch either
one. If you try to do two things at the same time, you won't succeed in doing either of them.
If two ride a horse, one must ride behind. When two people do something together, one will be the leader
and the other will be the subordinate.
If you want a friend, be a friend.
If wishes were horses, then beggars would ride. Wishing alone is of no use; you must act as well.
Ignorance is bliss. Possible interpretation: What you do not know causes no worry or sadness.
In for a penny, in for a pound. If you start something, it's better to spend the time or money necessary to complete it.
In the land of the blind, the one-eyed man is king. A man of even limited ability has an advantage over a person who is less able.
It never rains but it pours. Misfortunes usually come in large numbers.
It is always darkest before the dawn The most difficult time is just before a problem is solved.
It's no use crying over spilt milk. Don't express regret for something that has happened and cannot be remedied.
It takes all sorts to make a world. People vary in character and abilities, and this is a good thing.
J Justice delayed is justice denied. If the law is applied too late, there is no justice.
K Knowledge in youth is wisdom in age.
Knowledge is power.
Kill one to warn a hundred. Warn many by punishing a few.
Kill the goose that lays the golden egg. Destroy something that would be a source of wealth or success.
Kindness begets kindness. If you are kind to people, they will be kind to you.
• lessons-exercises • vocabulary • business english • idioms • wordgames • phrasal verbs • links-resources • fun • news • home •
ENGLISH PROVERBS & SAYINGS
(proverbs and sayings commonly used in everyday conversation)
What is a proverb? A proverb is a short well-known expression that states a general truth or gives advice.
What is a saying? A saying is a well-known expression, or a remark often made, also known as a proverb.
Alphabetical list of proverbs - A - K
with an explanation where necessary
Proverb
Explanation / Meaning
A
Absence makes the heart grow fonder. When you are away from someone you love, you love them even more.
Accidents will happen. Some unfortunate events must be accepted as inevitable.
Actions speak louder than words. What a person actually does is more important that what they say they will do.
Advice is cheap. It doesn't cost anything to offer advice.
Advice is least heeded when most needed. When a problem is serious, people often do not follow the advice given.
Advisers run no risks. It's easier to give advice than to act.
All cats are grey in the dark. People are undistinguished until they have made a name.
All good things come to those who wait. Patience brings rewards.
All that glitters is not gold. Appearances can be deceptive.
All days are short to Industry and long to Idleness. Time goes by slowly when you have nothing to do.
All is fair in love and war Things that are done in love or war can often be excused.
All's well that ends well There is a solution to everything even though there are doubts.
All that glitters is not gold. What look good on the outside may not be so in reality.
All things grow with time - except grief. As time goes by, grief subsides little by little.
All things are difficult before they are easy. With practice things become easier.
All work and no play makes Jack a dull boy. Everybody needs a certain amount of relaxation. It is not good to work all
the time.
An apple a day keeps the doctor away.* Eating an apple every day can help to keep you healthy.
Other interpretation : A small preventive treatment wards off serious problems.
An empty purse frightens away friends.
When one's financial situation deteriorates, friends tend to disappear.
An Englishman's home is his castle. An Englishman's home is a place where he feels safe, enjoys privacy
and can do as he wishes.
An idle brain is the devil's workshop. When you work you avoid temptation.
An onion a day keeps everyone away.* *A humoristic version of "an apple a day..."
An ounce of prevention is worth a pound of cure. It is easier to prevent something from happening than to repair the damage or
cure the disease later.
Anger is the one thing made better by delay. When you are angry, it is best not to speak or act immediately.
Any time means no time. If the date of an event remains vague, it will never happen.
April showers bring May flowers. Something bad or unpleasant today may bring good things in the future.
A bad tree does not yield good apples.
A bad workman blames his tools. Blaming the tools for bad workmanship is an excuse for lack of skill.
A bird in hand is worth two in a bush. It's better to keep what you have than to risk losing it by searching for something better.
A broken friendship may be soldered but will
never be sound. Friendships can be rebuilt after a dispute but will never be as strong as before.
A burden of one's own choice is not felt. Something difficult seems easier when it is done voluntarily.
A burnt child dreads the fire. A bad experience will make people stay away from certain things.
A cat has nine lives. 1) Cats can survive many accidents because they land on their feet without injury.
2) Three lives = 3 years to play, 3 years to stray, 3 years to stay.
A chain is no stronger than its weakest link. The strength of a group depends on each individual member.
A change is as good as a rest.
A dry March, a wet April and a cool May
fill barn and cellar and bring much hay.
A fault confessed is half redressed. Confession is the beginning of forgiveness.
A flower blooms more than once. If you miss an occasion, you can avail of it at another time.
A fool and his money are soon (easily) parted. A foolish person usually spends money carelessly.
A fool at forty is a fool forever. If a person hasn't matured by the age of 40, they never will.
A friend in need is a friend indeed. Someone who helps you when you are in trouble is a real friend.
A friend to all is a friend to none. Someone who is a friend to everyone makes none of them feel special.
A good example is the best sermon. Giving an example is better than giving advice.
A good beginning makes a good end.
If a task is carefully planned, there's a better chance that it will be done well.
A good conscience is a soft pillow. You sleep well when you have nothing to feel guilty about.
A guilty conscience needs no accuser.
A leopard cannot change its spots. It is not possible for a bad or unpleasant person to become good or pleasant.
A loaded wagon makes no noise. Really wealthy don't talk about money.
A loveless life is a living death.
A man can die but once.
A man is as old as he feels himself to be.
A man is known by the company he keeps. A person's character is judged by the type of people with whom they spend
their time.
A monkey in silk is a monkey no less. No matter how someone dresses, it's the same person underneath.
A new broom sweeps clean. A newly-appointed person makes changes energetically.
A rising tide lifts all boats. Describes something that will be helpful to all.
A rolling stone gathers no moss. If a person keeps moving from place to place, they gain neither friends nor
possessions.
Another interpretation is that, by moving often, one avoids being tied down!
A rotten apple spoils the barrel. A dishonest or immoral person can have a bad influence on a group.
A smooth sea never made a skilled mariner. Overcoming adversity leads to competence.
A stitch in time saves nine. It's better to deal with a problem at an early stage, to prevent it from getting
worse.
A stumble may prevent a fall. Correcting a small mistake may help you to avoid making a bigger one.
A swallow does not make the summer. One good event does not mean that everything is alright.
A tree is known by its fruit. A man is judged by his actions.
A watched pot never boils If you wait anxiously for something, it seems to take a long time.
A young idler, an old beggar. If you don't work, you won't have any money when you're old.
After dinner rest a while, after supper walk a mile.
As you sow, so shall you reap You have to accept the consequences of your actions.
B Bad news travels fast.
People tend to circulate bad news (accidents, illness etc.) very quickly.
Beauty is only skin deep.
A person's character is more important than their appearance.
Beauty is in the eye of the beholder.
Different people have different tastes.
Beauty is the wisdom of women. Wisdom is the
beauty of men.
Be swift to hear, slow to speak.
Listen carefully before speaking.
Better be alone than in bad company.
Be careful in the choice of the people you associate with.
Better be the head of a dog then the tail of a lion.
It's better to be the leader of a small group than a subordinate in a bigger one.
Better flatter a fool than fight him.
It's better to avoid disputes with stupid people.
Better the devil you know than the devil you
don't know
It's better to deal with somebody difficult but familiar, than change and risk dealing
with somebody worse.
Better late than never.
It's better to do something, even if it's late, than not do it at all.
Better lose the saddle than the horse.
It's better to stop and accept a small loss, rather than continue and risk losing
everything.
Better safe than sorry It's better to be too careful than to be careless and regret it later.
Better untaught than ill-taught It's better not to be taught at all than to be taught badly.
Birds of a feather flock together.
People of the same sort are usually found together.
Blood is thicker than water Family relationships are stronger than relationships with other people.
Blood will out. A person's background or education will eventually show.
C Charity begins at home. A person's first duty is to help and care for his own family.
Children and fools tell the truth.
Cleanliness is next to godliness. A clean body is just as important as a pure soul.
Clear moon, frost soon. If the atmosphere is clear, frost may form.
Clothes don't make the man. Appearances can be deceiving.
Constant occupation prevents temptation. When you work you avoid temptation.
D
Dead men tell no tales A dead person cannot cause difficulties by revealing something that it would be preferable to conceal.
Diamond cuts diamond. Refers to two people equally matched in wit or cunning.
Diligence is the mother of good fortune. Hard work brings rewards.
Discretion is the better part of valour It is useless to take unnecessary risks.
Diseases of the soul are more dangerous than
those of the body.
Distance makes the heart grow fonder. When you are separated from the person you love, your feelings are even stronger.
Dogs of the same street bark alike.
People from the same background have the same behaviour.
Don't bark if you can't bite. Don't complain if you can't enforce your point of view.
Don't count your chickens before they're hatched. You must not be too confident that something will be successful.
Don't dig your grave with your own knife and fork. Don't do something yourself which causes your own downfall.
Don't judge a book by its cover. Don't judge by appearances.
E
Early to bed and early to rise makes a man healthy,
wealthy and wise.
Easier said than done. What is suggested sounds easy but it is more difficult to actually do it.
Elbow grease is the best polish. Hard work gives the best results.
Empty vessels make the most noise. The least intelligent people are often the most talkative or noisy.
Every ass likes to hear himself bray. People like to listen to themselves talking.
Every cloud has a silver lining There is a positive or hopeful side to every unpleasant situation.
Every man for himself. You must think of your own interests before the interests of others.
Every man has his price. Everyone's loyalty can be bought for a price.
Every man is the architect of his own fortune. Life is what you make it.
Every path has its puddle. Progress is rarely without difficulty.
Every why has a wherefore. There is an explanation for everything.
Everything in the garden is rosy. Everything is satisfactory.
Experience is the father of wisdom.
Experience and knowledge result in better judgement.
F Facts speak louder than words.
People show what they are really like by what they do, rather than by what
they say.
Failure teaches success.
False friends are worse than open enemies.
Familiarity breeds contempt Knowing somebody very well may lead to a lack of respect for them.
Fine words butter no parsnips. No amount of talking can replace action.
First come, first served. The first person in the line will be attended to first.
Fool me once, shame on you;
fool me twice, shame on me. One should learn from one's mistakes.
Fools rush in where angels fear to tread Inexperienced people act in situations that more intelligent people would avoid
Friendship is love with understanding.
G Gardens are not made by sitting in the shade. Nothing is achieved without effort.
Give someone an inch and they will take a
mile (or yard). Give someone a little and they will want more - some people are never satisfied.
Give someone enough rope and they will hang
themselves. Give someone enough time and freedom and they will get into trouble.
God helps those who help themselves.
Good and quickly seldom meet. A well-done job takes time.
Good management is better than good income.
Great minds think alike.
Great oaks grow from little acorns. Large successful operations can begin in a small way.
Grief divided is made lighter
H Half a loaf is better than none. You should be grateful for something, even if it's not as much as you wanted.
Hard words break no bones.
Haste makes waste. If something is done too quickly, it may be done carelessly and need to be redone.
Hatred is a blind as love. A person who feels hatred does not see any qualities in the person he/she hates.
He has enough who is content.
He who hesitates is lost. If you delay your decision too long, you may miss a good opportunity.
He who is everywhere is nowhere. It's not good to do too many things at the same time.
He who knows nothing, doubts nothing. Knowledge leads us to make choices.
He who pays the piper calls the tune. The person who provides the money for something should control how it is spent
He who plays with fire gets burnt.
If you behave in a risky way, you are likely to have problems.
He who wills the end wills the means. If you are determined to do something you will find a way.
He laughs best who laughs last. Don't express your joy, or your triumph, too soon!
Health is better than wealth.
Home is where the heart is. You call home the place where the people you love are.
Honesty is the best policy.
Honey catches more flies than vinegar. You can obtain more cooperation from others by being nice.
However long the night, the dawn will break Bad things don't last forever.
I
In times of prosperity friends are plentiful. You have many friends when you have no difficulties.
If a camel gets his nose in a tent, his body will
follow.
If you let something intrusive enter your life, your life will become difficult .
If in February there be no rain, 'tis neither good
for hay nor grain.
If you are patient in one moment of anger,
you will avoid 100 days of sorrow.
If you chase two rabbits, you will not catch either
one. If you try to do two things at the same time, you won't succeed in doing either of them.
If two ride a horse, one must ride behind. When two people do something together, one will be the leader
and the other will be the subordinate.
If you want a friend, be a friend.
If wishes were horses, then beggars would ride. Wishing alone is of no use; you must act as well.
Ignorance is bliss. Possible interpretation: What you do not know causes no worry or sadness.
In for a penny, in for a pound. If you start something, it's better to spend the time or money necessary to complete it.
In the land of the blind, the one-eyed man is king. A man of even limited ability has an advantage over a person who is less able.
It never rains but it pours. Misfortunes usually come in large numbers.
It is always darkest before the dawn The most difficult time is just before a problem is solved.
It's no use crying over spilt milk. Don't express regret for something that has happened and cannot be remedied.
It takes all sorts to make a world. People vary in character and abilities, and this is a good thing.
J Justice delayed is justice denied. If the law is applied too late, there is no justice.
K Knowledge in youth is wisdom in age.
Knowledge is power.
Kill one to warn a hundred. Warn many by punishing a few.
Kill the goose that lays the golden egg. Destroy something that would be a source of wealth or success.
Kindness begets kindness. If you are kind to people, they will be kind to you.
Thursday, October 15, 2009
digit vice addition
#include"stdio.h"
#include"conio.h"
//increment digit vice
int main()
{
int td,i;
printf("enter the total digit to be entered (1-9)\n");
scanf("%d",&td);
int ch[10];
printf("Enter the %d digit value :\n",td);
for(i=0;i<td;i++)
{
scanf("%d",&ch[i]);
}
printf("enter the value to be add with number\n");
int k;
scanf("%d",&k);
int j=ch[0]+k;
for(i=td-1;i>=0;i--)
{
ch[i]=ch[i]+k;
if(ch[i]>9)
{
ch[i]=ch[i]-10;
ch[i-1]=ch[i-1]+1;
}
}
//msb bit
if(j>9)
{
j=j-10;
printf("%d",j);
}
for(i=0;i<td;i++)
{
printf("%d",ch[i]);
}
getch();
return 0;
}
#include"conio.h"
//increment digit vice
int main()
{
int td,i;
printf("enter the total digit to be entered (1-9)\n");
scanf("%d",&td);
int ch[10];
printf("Enter the %d digit value :\n",td);
for(i=0;i<td;i++)
{
scanf("%d",&ch[i]);
}
printf("enter the value to be add with number\n");
int k;
scanf("%d",&k);
int j=ch[0]+k;
for(i=td-1;i>=0;i--)
{
ch[i]=ch[i]+k;
if(ch[i]>9)
{
ch[i]=ch[i]-10;
ch[i-1]=ch[i-1]+1;
}
}
//msb bit
if(j>9)
{
j=j-10;
printf("%d",j);
}
for(i=0;i<td;i++)
{
printf("%d",ch[i]);
}
getch();
return 0;
}
showbits for integer value
#include"stdio.h"
#include"conio.h"
//show bits program
void showbits(int number)
{
int i=15;
printf("integer value represented in 16bits\n");
for(i=15;i>=0;i--)
{
int mask,bit;
mask=1<<i;
bit=number & mask;
bit==0? printf("0"):printf("1");
}
}
int main()
{
int number;
printf("Enter the integer number like(0-65535)\n");
scanf("%d",&number);
showbits(number);
getch();
return 0;
}
#include"conio.h"
//show bits program
void showbits(int number)
{
int i=15;
printf("integer value represented in 16bits\n");
for(i=15;i>=0;i--)
{
int mask,bit;
mask=1<<i;
bit=number & mask;
bit==0? printf("0"):printf("1");
}
}
int main()
{
int number;
printf("Enter the integer number like(0-65535)\n");
scanf("%d",&number);
showbits(number);
getch();
return 0;
}
Tuesday, October 13, 2009
bubble with pointer
#include"stdio.h"
#include"string.h"
#include"conio.h"
/*12. Implement the bubble
* sort algorithm using pointer concept. */
#include"stdio.h"
#include"conio.h"
int i,j,n;
int bubble(int *a,int n);
int main()
{
int a[20];
printf("enter the limits\n");
scanf("%d",&n);
printf("\nenter the elements wants to sort\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
//a[i]=&t[i];
//a++;
}
// for(i=0;i<n;i++)
// printf("\n%d",a[i]);
bubble(a,n); //call function
getch();
return 0;
}
int bubble(int *a,int n)
{
int i,j,temp;
// for(i=0;i<n;i++)
// printf("\n%d",a[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j] > a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
// printf("%d",*(a+j));
}
}//printf("number of iteration %d",i+1);
}
printf("\n the sorted list is:\n");
for(j=0;j<n;j++)
{
printf("%d\n",a[j]);
//a++;
}
//getch();
return 0;
}
#include"string.h"
#include"conio.h"
/*12. Implement the bubble
* sort algorithm using pointer concept. */
#include"stdio.h"
#include"conio.h"
int i,j,n;
int bubble(int *a,int n);
int main()
{
int a[20];
printf("enter the limits\n");
scanf("%d",&n);
printf("\nenter the elements wants to sort\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
//a[i]=&t[i];
//a++;
}
// for(i=0;i<n;i++)
// printf("\n%d",a[i]);
bubble(a,n); //call function
getch();
return 0;
}
int bubble(int *a,int n)
{
int i,j,temp;
// for(i=0;i<n;i++)
// printf("\n%d",a[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j] > a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
// printf("%d",*(a+j));
}
}//printf("number of iteration %d",i+1);
}
printf("\n the sorted list is:\n");
for(j=0;j<n;j++)
{
printf("%d\n",a[j]);
//a++;
}
//getch();
return 0;
}
matrix element sorting
#include"stdio.h"
#include"string.h"
#include"conio.h"
/*11. Write a program to pick up the
* largest number from any matrix using pointer*/
int main()
{
int i,j,k,r,c;
int a[100][100],*temp[100],*b,*mat[100][100];
printf("enter the matrix row and column size\n");
scanf("%d%d",&r,&c);
printf("enter the matrix elements\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
mat[i][j]=&a[i][j];
}printf("\n");
}
printf("***matrix***\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",*mat[i][j]);
}printf("\n");
}
k=0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
temp[k]=mat[i][j];
k++;
}
}
int len=r * c;
/*for(i=0;i<len;i++){
printf("%d\t",*temp[i]);
}*/
b=temp[0];
for(i=0;i<len;i++)
{
if(b<temp[i])
{
b=temp[i];
}
}
printf("\n largest value in matrix:%d",*b);
getch();
return 0;
}
#include"string.h"
#include"conio.h"
/*11. Write a program to pick up the
* largest number from any matrix using pointer*/
int main()
{
int i,j,k,r,c;
int a[100][100],*temp[100],*b,*mat[100][100];
printf("enter the matrix row and column size\n");
scanf("%d%d",&r,&c);
printf("enter the matrix elements\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
mat[i][j]=&a[i][j];
}printf("\n");
}
printf("***matrix***\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",*mat[i][j]);
}printf("\n");
}
k=0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
temp[k]=mat[i][j];
k++;
}
}
int len=r * c;
/*for(i=0;i<len;i++){
printf("%d\t",*temp[i]);
}*/
b=temp[0];
for(i=0;i<len;i++)
{
if(b<temp[i])
{
b=temp[i];
}
}
printf("\n largest value in matrix:%d",*b);
getch();
return 0;
}
pointer sorting
#include"stdlib.h"
#include"string.h"
#include"stdio.h"
#include"conio.h"
/*10. Write a program to sort a set of names stored
* in array in alphabetical order using pointer
*/
int main()
{
char *t,*a[10],ch[10][10];
int i,k,j,n;
printf("enter the total number of string\n");
scanf("%d",&n);
printf("total length%d \n",n);
for(i=0;i<n;i++)
{
printf("enter the string%d\n",i+1);
scanf("%s",ch[i]);
a[i]=ch[i];
}
for(i=0;i<n;i++)
{
printf("%s\n",a[i]);
}
for(j=0;j<n;j++)
{
for(i=0;i<n-1;i++)
{
if((k=strcmp(a[i],a[i+1]))>0)
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
printf("\n sorted list is:\n");
for(j=0;j<n;j++)
{
printf("%s\n",a[j]);
}
getch();
return 0;
}
#include"string.h"
#include"stdio.h"
#include"conio.h"
/*10. Write a program to sort a set of names stored
* in array in alphabetical order using pointer
*/
int main()
{
char *t,*a[10],ch[10][10];
int i,k,j,n;
printf("enter the total number of string\n");
scanf("%d",&n);
printf("total length%d \n",n);
for(i=0;i<n;i++)
{
printf("enter the string%d\n",i+1);
scanf("%s",ch[i]);
a[i]=ch[i];
}
for(i=0;i<n;i++)
{
printf("%s\n",a[i]);
}
for(j=0;j<n;j++)
{
for(i=0;i<n-1;i++)
{
if((k=strcmp(a[i],a[i+1]))>0)
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
printf("\n sorted list is:\n");
for(j=0;j<n;j++)
{
printf("%s\n",a[j]);
}
getch();
return 0;
}
student with pointer
include"stdio.h"
#include"string.h"
#include"conio.h"
#include"stdlib.h"
/*9. Allocate memory for number of students, take those marks, and find average, by
* using pointer concept */
struct student
{
int mark;
};
struct student *no[10];
int main()
{
int i=0,sum=0,n,avg;
printf("enter the number of students list want to create\n");
scanf("%d",&n);
while(i {
no[i]=(struct student *)malloc(sizeof(struct student ));
printf("enter the %d student mark\n",i+1);
scanf("%d",&no[i]->mark);
i++;
}
printf("****display****");
i=0;
while(i {
printf(" the %d student mark is %d\n",i+1,no[i]->mark);
sum=sum+no[i]->mark;
i++;
}
avg=sum/n;
printf("the average value of %d student mark is:%d",n,avg);
getch();
return 0;
}
#include"string.h"
#include"conio.h"
#include"stdlib.h"
/*9. Allocate memory for number of students, take those marks, and find average, by
* using pointer concept */
struct student
{
int mark;
};
struct student *no[10];
int main()
{
int i=0,sum=0,n,avg;
printf("enter the number of students list want to create\n");
scanf("%d",&n);
while(i
no[i]=(struct student *)malloc(sizeof(struct student ));
printf("enter the %d student mark\n",i+1);
scanf("%d",&no[i]->mark);
i++;
}
printf("****display****");
i=0;
while(i
printf(" the %d student mark is %d\n",i+1,no[i]->mark);
sum=sum+no[i]->mark;
i++;
}
avg=sum/n;
printf("the average value of %d student mark is:%d",n,avg);
getch();
return 0;
}
pointer
8. By using the given below information answer the questions which follow,
Var. Name Address Contents
P 2568 425
Q 4284 2568
R 6242 4284
A[10] 8468 232
B [10] 8478 2568
a. &p =? 2568
b. *q =? 425
c. **r =? 425
d. &q =? 4284
e. *(&q) =? 2568
f. &(*r) = ? 4284
Var. Name Address Contents
P 2568 425
Q 4284 2568
R 6242 4284
A[10] 8468 232
B [10] 8478 2568
a. &p =? 2568
b. *q =? 425
c. **r =? 425
d. &q =? 4284
e. *(&q) =? 2568
f. &(*r) = ? 4284
star
#include"stdio.h"
#include"string.h"
#include"conio.h"
/*Write a program to print the following output
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
*/
int main()
{
int i,k=1,j=1,len,size;
char let[]={'A','B','C','D','E','F','G','\0'};
len=strlen(let);
size=len;
printf("string len is %d\n\n",len);
for(i=0;i printf("%c",let[i]);
for(i=len-2;i>=0;i--)
printf("%c",let[i]);
printf("\n");printf("\n");
while(k<size)
{
for(i=0;i<len-1;i++)
printf("%c",let[i]);
for(i=0;i<(1*j);i++)
printf(" ");
for(i=len-2;i>=0;i--)
printf("%c",let[i]);
j=j+2;
k++;
len--;
printf("\n");printf("\n");
}
getch();
return 0;
}
#include"string.h"
#include"conio.h"
/*Write a program to print the following output
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
*/
int main()
{
int i,k=1,j=1,len,size;
char let[]={'A','B','C','D','E','F','G','\0'};
len=strlen(let);
size=len;
printf("string len is %d\n\n",len);
for(i=0;i
for(i=len-2;i>=0;i--)
printf("%c",let[i]);
printf("\n");printf("\n");
while(k<size)
{
for(i=0;i<len-1;i++)
printf("%c",let[i]);
for(i=0;i<(1*j);i++)
printf(" ");
for(i=len-2;i>=0;i--)
printf("%c",let[i]);
j=j+2;
k++;
len--;
printf("\n");printf("\n");
}
getch();
return 0;
}
string manipulation without library
#include
#include
#include
/*b. Without using library
*
function doing the above operation.
1.string copy,
2.string length
3. String concatenation and
study the function like stricmp, strrev.*/
int main()
{
char str[100];
char str1[100];
char temp[100];
printf("enter the string\n");
scanf("%s",str);
int k,i=0,j=0; //1.string length
while(str[i]!='\0')
{
i++;
}printf("\nstring %s length is:%d\n",str,i);
int length=i; //2.string copy
for(k=0;k<length;k++)
{
str1[k]=str[k];
}
str1[k]='\0';
printf("\n string copy str to str1 like %s to %s\n",str,str1);
//string concatenation
i=0;
while(str1[i]!='\0')
{
i++;
}printf("\n string %s length is:%d\n",str1,i);
int length2=i;
for(k=0;k<(length2+length);k++)
{
if(k {
str[k]=str[k];
}else
{
str[k]=str1[j];
j++;
}
}
str[k] = '\0';
printf("string concatenation like :%s\n",str);
//string reverse
j=0;
for(k=length2-1;k>=0;k--)
{
temp[j]=str1[k];
j++;
}
temp[j]='\0';
printf("\n string reverse %s is %s",str1,temp);
//6.stricmp
printf("\n enter the first string\n");
scanf("%s",str);
printf("enter the second string\n");
scanf("%s",str1);
i=0;
while(str[i]!='\0')
{
i++;
}length=i;
while(str1[i]!='\0')
{
i++;
}length2=i;
if(length==length2)
{
k=0;i=0;
while(k<length)
{
if(str[k]==str1[k] || str[k]==str1[k]+32 || str[k]==str1[k]-32)
{
i++;
}
k++;
}if(i==length)
{
printf("str %s and str1 %s is matched",str,str1);
}else
{
printf("str %s and str1 %s is not matched",str,str1);
}
}
getch();
return 0;
}
#include
#include
/*b. Without using library
*
function doing the above operation.
1.string copy,
2.string length
3. String concatenation and
study the function like stricmp, strrev.*/
int main()
{
char str[100];
char str1[100];
char temp[100];
printf("enter the string\n");
scanf("%s",str);
int k,i=0,j=0; //1.string length
while(str[i]!='\0')
{
i++;
}printf("\nstring %s length is:%d\n",str,i);
int length=i; //2.string copy
for(k=0;k<length;k++)
{
str1[k]=str[k];
}
str1[k]='\0';
printf("\n string copy str to str1 like %s to %s\n",str,str1);
//string concatenation
i=0;
while(str1[i]!='\0')
{
i++;
}printf("\n string %s length is:%d\n",str1,i);
int length2=i;
for(k=0;k<(length2+length);k++)
{
if(k
str[k]=str[k];
}else
{
str[k]=str1[j];
j++;
}
}
str[k] = '\0';
printf("string concatenation like :%s\n",str);
//string reverse
j=0;
for(k=length2-1;k>=0;k--)
{
temp[j]=str1[k];
j++;
}
temp[j]='\0';
printf("\n string reverse %s is %s",str1,temp);
//6.stricmp
printf("\n enter the first string\n");
scanf("%s",str);
printf("enter the second string\n");
scanf("%s",str1);
i=0;
while(str[i]!='\0')
{
i++;
}length=i;
while(str1[i]!='\0')
{
i++;
}length2=i;
if(length==length2)
{
k=0;i=0;
while(k<length)
{
if(str[k]==str1[k] || str[k]==str1[k]+32 || str[k]==str1[k]-32)
{
i++;
}
k++;
}if(i==length)
{
printf("str %s and str1 %s is matched",str,str1);
}else
{
printf("str %s and str1 %s is not matched",str,str1);
}
}
getch();
return 0;
}
strtok
#include
#include
#include
/*Write a Program to split the given string like
str [] ="1>2>3>4>5>" using string tokenizer*/
int main()
{
char str[]="1>2>3>4>5>";
char *a;
a=strtok(str,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
getch();
return 0;
}
#include
#include
/*Write a Program to split the given string like
str [] ="1>2>3>4>5>" using string tokenizer*/
int main()
{
char str[]="1>2>3>4>5>";
char *a;
a=strtok(str,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
a=strtok(NULL,">");
printf("%s\n",a);
getch();
return 0;
}
structure student
#include
#include
#include
/*Write a Program to create a
*
Structure that has
name of student,
Roll number,
mark1, mark2, and mark3
are the member variables to maintain many records.
If I want to access particular record,
then you should search the records
based on either their name or their roll number.*/
//int n;
struct stu
{
char name[50];
int rollno;
int mark1,mark2,mark3;
}b[100];
int main()
{
char data[50];
int i,n,key,flag=0;
printf("enter the number of students record in database\n");
scanf("%d",&n);
printf("enter the student details in the following sequence\n");
printf("name,rollno,mark1,mark2,mark3\n");
for(i=0;i<n;i++)
{
printf("\tenter the %d student details\n",i+1);
scanf("%s%d%d%d%d",b[i].name,&b[i].rollno,&b[i].mark1,&b[i].mark2,&b[i].mark3);
}
printf("****database details**");
for(i=0;i {
printf(" \n \nthe %d student details\n\n",i+1);
printf("\nname %s\t rollno %6.d\t mark1 %6.d\t mark2 %6.d\t mark3 %6.d",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
}
printf("\nenter the particular students rollno\n");
scanf("%d",&key);
for(i=0;i {
if(key==b[i].rollno)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
flag=0;
printf("\n enter the particular students name\n");
scanf("%s",data);
for(i=0;i {
if(strcmp(data,b[i].name)==0)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
getch();
return 0;
}
#include
#include
/*Write a Program to create a
*
Structure that has
name of student,
Roll number,
mark1, mark2, and mark3
are the member variables to maintain many records.
If I want to access particular record,
then you should search the records
based on either their name or their roll number.*/
//int n;
struct stu
{
char name[50];
int rollno;
int mark1,mark2,mark3;
}b[100];
int main()
{
char data[50];
int i,n,key,flag=0;
printf("enter the number of students record in database\n");
scanf("%d",&n);
printf("enter the student details in the following sequence\n");
printf("name,rollno,mark1,mark2,mark3\n");
for(i=0;i<n;i++)
{
printf("\tenter the %d student details\n",i+1);
scanf("%s%d%d%d%d",b[i].name,&b[i].rollno,&b[i].mark1,&b[i].mark2,&b[i].mark3);
}
printf("****database details**");
for(i=0;i
printf(" \n \nthe %d student details\n\n",i+1);
printf("\nname %s\t rollno %6.d\t mark1 %6.d\t mark2 %6.d\t mark3 %6.d",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
}
printf("\nenter the particular students rollno\n");
scanf("%d",&key);
for(i=0;i
if(key==b[i].rollno)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
flag=0;
printf("\n enter the particular students name\n");
scanf("%s",data);
for(i=0;i
if(strcmp(data,b[i].name)==0)
{
printf("\n****found***\n");
printf("\n name %s\trollno %d\tmark1 %d\tmark2 %d\tmark3 %d\n",b[i].name,b[i].rollno,b[i].mark1,b[i].mark2,b[i].mark3);
flag=1;
}
}
if(flag==0)
{
printf("\n***not found**\n");
}
getch();
return 0;
}
book to be boaoak
#include
#include
#include
/*Write a Program to insert a particular character in a string
* after one specific character like
Str1 [] ="book"
Then in the above given string after character
'o' it should append a character 'a’, so output will be
Boaoak*/
int main()
{
char str1[100]="book";
char str2[100];
int i=0,j=0;
while(str1[i]!='\0')
{
if(str1[i]=='o')
{
str2[j]=str1[i];
j++;
str2[j]='a';
j++;i++;
}else
{
str2[j]=str1[i];
j++;i++;
}
}str2[j]='\0';
printf("replaced string is :%s",str2);
getch();
return 0;
}
#include
#include
/*Write a Program to insert a particular character in a string
* after one specific character like
Str1 [] ="book"
Then in the above given string after character
'o' it should append a character 'a’, so output will be
Boaoak*/
int main()
{
char str1[100]="book";
char str2[100];
int i=0,j=0;
while(str1[i]!='\0')
{
if(str1[i]=='o')
{
str2[j]=str1[i];
j++;
str2[j]='a';
j++;i++;
}else
{
str2[j]=str1[i];
j++;i++;
}
}str2[j]='\0';
printf("replaced string is :%s",str2);
getch();
return 0;
}
first letter in word to caps
#include
#include
#include
/* Write a Program to in which
* the given strings like str []
* ="second week test exercise" should be outputted as
* “Second Week Test Exercise”.
* WITOUT USING ANY STANDARD FUNCTION*/
int main()
{
char str[]="second week test exercise";
int i=0;
int j=0;
while(str[i]!='\0')
{
i++;
}
printf("length of the string %d \n",i);
str[0]=str[0]-32;
while(j<=i)
{
if(str[j]==' ')
{
str[j+1]=str[j+1]-32;
}j++;
}
printf("%s",str);
getch();
return 0;
}
#include
#include
/* Write a Program to in which
* the given strings like str []
* ="second week test exercise" should be outputted as
* “Second Week Test Exercise”.
* WITOUT USING ANY STANDARD FUNCTION*/
int main()
{
char str[]="second week test exercise";
int i=0;
int j=0;
while(str[i]!='\0')
{
i++;
}
printf("length of the string %d \n",i);
str[0]=str[0]-32;
while(j<=i)
{
if(str[j]==' ')
{
str[j+1]=str[j+1]-32;
}j++;
}
printf("%s",str);
getch();
return 0;
}
rotational string
1. Rotate the String and display. For example, “SCOPE” “COPES” “OPESC” “PESCO”….
#include<stdio.h>
#include<string.h>
#include"conio.h"
int main()
{
int i,j=0;
char a[100]="scope";
//printf("enter the word\n");
//scanf("%s",a);
int length;
length=strlen(a);
while(j<length)
{
for(i=0+j;i<length;i++)
{
printf("%c",a[i]);
}
for(i=0;i<j;i++)
{
printf("%c",a[i]);
}
printf("\t");
j++;
}getch();
return 0;
}
#include<stdio.h>
#include<string.h>
#include"conio.h"
int main()
{
int i,j=0;
char a[100]="scope";
//printf("enter the word\n");
//scanf("%s",a);
int length;
length=strlen(a);
while(j<length)
{
for(i=0+j;i<length;i++)
{
printf("%c",a[i]);
}
for(i=0;i<j;i++)
{
printf("%c",a[i]);
}
printf("\t");
j++;
}getch();
return 0;
}
Thursday, October 8, 2009
find the smallest number of a array?
main()
{
int a[20],n,i,s;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
s=a[0];
for(i=0;i<n;i++)
{
if(s>a[i])
{
s=a[i];
}
}
printf("the smallest number is %d",s);
}
2..#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[50],temp;
printf("enter the max limit :");
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
for(int j=0;j<n-1;j++)
{
if(a[j+1]<a[j])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
printf("the smnallest is : %d",*(a+0));
getch();
}
{
int a[20],n,i,s;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
s=a[0];
for(i=0;i<n;i++)
{
if(s>a[i])
{
s=a[i];
}
}
printf("the smallest number is %d",s);
}
2..#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[50],temp;
printf("enter the max limit :");
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
for(int j=0;j<n-1;j++)
{
if(a[j+1]<a[j])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
printf("the smnallest is : %d",*(a+0));
getch();
}
Wednesday, October 7, 2009
temperatures
1.
#include<stdio.h>
int main()
{
int big;
float abc,g;
scanf("%d%f",&big,&abc);
g=big/2+big*4/big-big+abc/3;
printf("%f",g);
return 0;
}
Answer 3.833
2.
#include<stdio.h>
int main()
{
int on,ink=4,act=1;
float tig=3.2;
on=ink*act/2+3/2*act+2+tig;
printf("%d",on);
return 0;
}
Answer 8
3.
#include<stdio.h>
int main()
{
int qui=4,s,add=2,god;
s=qui*add/4-6/2+2/3*6/god;
printf("%d",s);
return 0;
}
Answer -1
4.
#include<stdio.h>
int main()
{
int a,b;
a=-3 - -3;
b=-3 - - (-3);
printf("a=%d b=%d",a,b);
return 0;
}
Answer a=0 b=-6
5.
#include<stdio.h>
int main()
{
float a=5,b=2;
int c;
c= a / b;
printf("%d",c);
return 0;
}
Answer 2
6. fahrengeit to celsius
#include <stdio.h>
/*
* print a table for Fahrenheit to Celsius
* from 0 F to 300 F
*/
void main(void)
{
int fahr; /* fahrenheit temperature */
int celsius; /* celsius temperature */
register int lower = 0; /* begin table here */
register int upper = 300; /* end table here */
register int step = 20; /* increment */
/*
* print out the lines for the table
*/
fahr = lower;
while(fahr <= upper){
/* get corresponding temp in degrees C */
celsius = 5 * (fahr - 32) / 9;
/* print it */
printf("%d\t%d\n", fahr, celsius);
fahr += step;
}
/*
* say goodbye
*/
exit(0);
}
#include<stdio.h>
int main()
{
int big;
float abc,g;
scanf("%d%f",&big,&abc);
g=big/2+big*4/big-big+abc/3;
printf("%f",g);
return 0;
}
Answer 3.833
2.
#include<stdio.h>
int main()
{
int on,ink=4,act=1;
float tig=3.2;
on=ink*act/2+3/2*act+2+tig;
printf("%d",on);
return 0;
}
Answer 8
3.
#include<stdio.h>
int main()
{
int qui=4,s,add=2,god;
s=qui*add/4-6/2+2/3*6/god;
printf("%d",s);
return 0;
}
Answer -1
4.
#include<stdio.h>
int main()
{
int a,b;
a=-3 - -3;
b=-3 - - (-3);
printf("a=%d b=%d",a,b);
return 0;
}
Answer a=0 b=-6
5.
#include<stdio.h>
int main()
{
float a=5,b=2;
int c;
c= a / b;
printf("%d",c);
return 0;
}
Answer 2
6. fahrengeit to celsius
#include <stdio.h>
/*
* print a table for Fahrenheit to Celsius
* from 0 F to 300 F
*/
void main(void)
{
int fahr; /* fahrenheit temperature */
int celsius; /* celsius temperature */
register int lower = 0; /* begin table here */
register int upper = 300; /* end table here */
register int step = 20; /* increment */
/*
* print out the lines for the table
*/
fahr = lower;
while(fahr <= upper){
/* get corresponding temp in degrees C */
celsius = 5 * (fahr - 32) / 9;
/* print it */
printf("%d\t%d\n", fahr, celsius);
fahr += step;
}
/*
* say goodbye
*/
exit(0);
}
Thursday, September 17, 2009
log
1.Which statement will you add in the following program to work it correctly?
#include
int main()
{
printf("%f\n", log(36.0));
return 0;
}
answer:#include"math.h"
2.We want to round off x, a float, to an int value, The correct way to do is
A.
y = (int)(x + 0.5)
B.
y = int(x + 0.5)
C.
y = (int)x + 0.5
D.
y = (int)((int)x + 0.5)
3.
Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
A.
rem = (5.5 % 1.3)
B.
rem = modf(5.5, 1.3)
C.
rem = fmod(5.5, 1.3)
D.
Error: we can't divide
#include
int main()
{
printf("%f\n", log(36.0));
return 0;
}
answer:#include"math.h"
2.We want to round off x, a float, to an int value, The correct way to do is
A.
y = (int)(x + 0.5)
B.
y = int(x + 0.5)
C.
y = (int)x + 0.5
D.
y = (int)((int)x + 0.5)
3.
Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
A.
rem = (5.5 % 1.3)
B.
rem = modf(5.5, 1.3)
C.
rem = fmod(5.5, 1.3)
D.
Error: we can't divide
Difference between combinational logic circuit and sequential logic circuit?
The main difference between sequential circuits and combinational circuits is that sequential circuits compute their output based on input and state, and that the state is updated based on a clock.
Combinational logic circuits implement Boolean functions, so they are functions only of their inputs, and are not based on clocks.
combinational =========================== sequencial
1.memory unit is not required =============1 it is require to store the past history
2.it is faster =================== 2. less compare to that one
3.easy to design ====== 3. comparatively garder
4.parallel adder ============== 4. serial adder
Combinational logic circuits implement Boolean functions, so they are functions only of their inputs, and are not based on clocks.
combinational =========================== sequencial
1.memory unit is not required =============1 it is require to store the past history
2.it is faster =================== 2. less compare to that one
3.easy to design ====== 3. comparatively garder
4.parallel adder ============== 4. serial adder
latch and flipflops
tch is a level triggered device but flip flop is a edge triggered device.
Latch takes less gates but flipflop takes more.
Latch faster flipflop
slower.
Latch does'nt have a clock signal but flip flop depends on the
clock signal but both are having one bit memory.
latch is a device which is used as switch,f/f is a storing
element
Latch takes less gates but flipflop takes more.
Latch faster flipflop
slower.
Latch does'nt have a clock signal but flip flop depends on the
clock signal but both are having one bit memory.
latch is a device which is used as switch,f/f is a storing
element
Write a C program to determine the number of elements (or size) in a tree.
Try this C program
int tree_size(struct node* node)
{
if (node==NULL)
{
return(0);
}
else
{
return(tree_size(node->left) + tree_size(node->right) + 1);
}
int tree_size(struct node* node)
{
if (node==NULL)
{
return(0);
}
else
{
return(tree_size(node->left) + tree_size(node->right) + 1);
}
Write C code to determine if two trees are identical
Here is a C program using recursion
int identical(struct node* a, struct node* b)
{
if (a==NULL && b==NULL){return(true);}
else if (a!=NULL && b!=NULL)
{
return(a->data == b->data &&
identical(a->left, b->left) &&
identical(a->right, b->right));
}
else return(false);
}
int identical(struct node* a, struct node* b)
{
if (a==NULL && b==NULL){return(true);}
else if (a!=NULL && b!=NULL)
{
return(a->data == b->data &&
identical(a->left, b->left) &&
identical(a->right, b->right));
}
else return(false);
}
Write a C program to find the mininum value in a binary search tree.
Here is some sample C code. The idea is to keep on moving till you hit the left most node in the tree
int minValue(struct node* node)
{
struct node* current = node;
while (current->left != NULL)
{
current = current->left;
}
return(current->data);
}
On similar lines, to find the maximum value, keep on moving till you hit the right most node of the tree.
int minValue(struct node* node)
{
struct node* current = node;
while (current->left != NULL)
{
current = current->left;
}
return(current->data);
}
On similar lines, to find the maximum value, keep on moving till you hit the right most node of the tree.
Write a C program to compute the maximum depth in a tree?
int maxDepth(struct node* node)
{
if (node==NULL)
{
return(0);
}
else
{
int leftDepth = maxDepth(node->left);
int rightDepth = maxDepth(node->right);
if (leftDepth > rightDepth) return(leftDepth+1);
else return(rightDepth+1);
}
}
{
if (node==NULL)
{
return(0);
}
else
{
int leftDepth = maxDepth(node->left);
int rightDepth = maxDepth(node->right);
if (leftDepth > rightDepth) return(leftDepth+1);
else return(rightDepth+1);
}
}
Tuesday, September 15, 2009
Interview questions
aptitude
1..1 8 27 64 ....? 125
2. some diagram representation oriented q's?
3. card's question ?
like they given six cards ..we want to arrange some specified order..
4.
c question
1.mention lib function for appending one string to another string ?
strcat
2. for strlen() fuction can run under which lib funtion?
string.h
3. fseek syntax
fseek(char #buffer,offset,seek-end);
4. is there any direct function for exponential?
ya its possible by exp(x)
5. write a program for finding a strlen without using lib function?
for(i=0;str[i]<null;i++);
6. following function which one is odd?
alloc calloc malloc realloc
i think it is calloc
7. pickout file function below?
scanf printf put get
but nothing be the file opreratin...file operation handle by fscanf,fprintf, fgetc,fputc
8. main()
{
int a=0;
int b=10;
int c=3;
a=b%c;
printf("%d ", a);
}
out put:: 1
9. main()
{
int a=0;
int b=-10;
int c=-3;
a=b%c;
printf("%d ", a);
}
out put:: -1
10.#include
#include
main()
{
int a=0;
int b=-10;
int c=-3;b%c;
printf("%d",a);
getch();
}
output:
warning:1
o/p: 0
electronics question
1. in tv transmission what modultion we used?
AM AND FM
2. nyquist criteria equation?
fs>=2fm
3. opamp pin diagram?
4. bridge rectifier with l c circuit?
5. l c tank circuit frequency?
f=1/(2*3.14*(l c)^.5)
6. universal gates?
NAND AND NOR
7.xor and xnor gate diagram?
1..1 8 27 64 ....? 125
2. some diagram representation oriented q's?
3. card's question ?
like they given six cards ..we want to arrange some specified order..
4.
c question
1.mention lib function for appending one string to another string ?
strcat
2. for strlen() fuction can run under which lib funtion?
string.h
3. fseek syntax
fseek(char #buffer,offset,seek-end);
4. is there any direct function for exponential?
ya its possible by exp(x)
5. write a program for finding a strlen without using lib function?
for(i=0;str[i]<null;i++);
6. following function which one is odd?
alloc calloc malloc realloc
i think it is calloc
7. pickout file function below?
scanf printf put get
but nothing be the file opreratin...file operation handle by fscanf,fprintf, fgetc,fputc
8. main()
{
int a=0;
int b=10;
int c=3;
a=b%c;
printf("%d ", a);
}
out put:: 1
9. main()
{
int a=0;
int b=-10;
int c=-3;
a=b%c;
printf("%d ", a);
}
out put:: -1
10.#include
#include
main()
{
int a=0;
int b=-10;
int c=-3;b%c;
printf("%d",a);
getch();
}
output:
warning:1
o/p: 0
electronics question
1. in tv transmission what modultion we used?
AM AND FM
2. nyquist criteria equation?
fs>=2fm
3. opamp pin diagram?
4. bridge rectifier with l c circuit?
5. l c tank circuit frequency?
f=1/(2*3.14*(l c)^.5)
6. universal gates?
NAND AND NOR
7.xor and xnor gate diagram?
Sunday, September 13, 2009
aptitude
if the area of the square is increased as a69%..then what ll be the side of the square increased %??
ans:
100+69=x^2
side=13
if x^y=2x+y defined,,2^a=a^3 then what ll be 'a' value ??
ans:
4+a=2a+3
a=1;
ans:
100+69=x^2
side=13
if x^y=2x+y defined,,2^a=a^3 then what ll be 'a' value ??
ans:
4+a=2a+3
a=1;
Saturday, September 12, 2009
quantum paper
main()
{
int c=5,a=4;
clrscr();
printf("%d%d",main||c,main||a);
getch();
}
output: 11
(2).storage class and their types?
C has a concept of 'Storage classes' which are used to define the scope (visability) and life time of variables and/or functions.
storage classes is important part of c language.WHENEVER we define any funtion in c program then we can call that in every definend class.
there are four types of storage class. these are...
1 AUTO OR AUTOMATIC STORAGE CLASS
2 REGISTER STORAGE CLASS
3 STATIC STORAGE CLASS
4 EXTERNALSTORAGE CLASS
1) The features of "AUTOMETIC" storage class are as under some conditions:
storage : storage will be in memory.
value : garbage value.
scope : scope is local to block to the variable.
life : till, controls remain within the block.
2) The featurs of "STATIC" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : Till control remains within the block.
3) The featurs of "REGISTER" storage class are as under some conditions:
storage : register.
value : garbage value.
scope : local to the block.
life : value persists between variable.
4) The feature of "EXTERNAL" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : till controls remains within the block
(3).how can open the image file in c?
In C, generally we?can open files having text format...
other types of files can be opened in binary format only using
file *fp;
fp=fopen("filename","rb+");// where b stands for binary format
(4).
#include
main()
{
clrscr();
printf("%d",i);
getch();
}
int i=10;
output:
Error Undefined symbol 'i' in function main
(5).syntax for fwrite,fopen,fread,fseek
fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
fread( void *buffer, size_t size, size_t num, FILE *stream );
fseek( FILE *stream, long offset, int origin );
fopen(const char *FileName, const char *Mode);
(6).how to find string length wihtout using c function?
#include<stdio.h>
#include<conio.h>
int str_len(char *)
void main()
{
char s[30];
int count;
printf("enter the string :");
gets(s);
count=str_len(s);
printf("the length is :%d",count);
getch();
}
int str_len(char *a)
{
int i=0;
while(*a!='\0')
a++;
i++;
}
return i;
}
(7).
main()
{
char s[]={'a','b','c','\0','a'};
char *p;
p=&s[3];
char *s1;
s1=s;
printf("%d",++(*p)+ ++(*str1));
getch();
}error: cant giving input through array to pointer..
pointer to array is possible in c.
(8).
#include
#include
struct set
{
int x;
char name[];
}set;
main()
{
set.x=3;
set.name[]={"hi"};
printf("%d%d",set.x,set.name);
getch();
}
output:
error ..because name declared as a char..but we use string .
(9)& (10)..
two question from header files error. like "sddio." and "cionio.h"
(11).main()
{
int i=300;
int j=400;
clrscr();
printf("%d %d");
getch();
}
OUTPUT:
300 400
{
int c=5,a=4;
clrscr();
printf("%d%d",main||c,main||a);
getch();
}
output: 11
(2).storage class and their types?
C has a concept of 'Storage classes' which are used to define the scope (visability) and life time of variables and/or functions.
storage classes is important part of c language.WHENEVER we define any funtion in c program then we can call that in every definend class.
there are four types of storage class. these are...
1 AUTO OR AUTOMATIC STORAGE CLASS
2 REGISTER STORAGE CLASS
3 STATIC STORAGE CLASS
4 EXTERNALSTORAGE CLASS
1) The features of "AUTOMETIC" storage class are as under some conditions:
storage : storage will be in memory.
value : garbage value.
scope : scope is local to block to the variable.
life : till, controls remain within the block.
2) The featurs of "STATIC" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : Till control remains within the block.
3) The featurs of "REGISTER" storage class are as under some conditions:
storage : register.
value : garbage value.
scope : local to the block.
life : value persists between variable.
4) The feature of "EXTERNAL" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : till controls remains within the block
(3).how can open the image file in c?
In C, generally we?can open files having text format...
other types of files can be opened in binary format only using
file *fp;
fp=fopen("filename","rb+");// where b stands for binary format
(4).
#include
main()
{
clrscr();
printf("%d",i);
getch();
}
int i=10;
output:
Error Undefined symbol 'i' in function main
(5).syntax for fwrite,fopen,fread,fseek
fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
fread( void *buffer, size_t size, size_t num, FILE *stream );
fseek( FILE *stream, long offset, int origin );
fopen(const char *FileName, const char *Mode);
(6).how to find string length wihtout using c function?
#include<stdio.h>
#include<conio.h>
int str_len(char *)
void main()
{
char s[30];
int count;
printf("enter the string :");
gets(s);
count=str_len(s);
printf("the length is :%d",count);
getch();
}
int str_len(char *a)
{
int i=0;
while(*a!='\0')
a++;
i++;
}
return i;
}
(7).
main()
{
char s[]={'a','b','c','\0','a'};
char *p;
p=&s[3];
char *s1;
s1=s;
printf("%d",++(*p)+ ++(*str1));
getch();
}error: cant giving input through array to pointer..
pointer to array is possible in c.
(8).
#include
#include
struct set
{
int x;
char name[];
}set;
main()
{
set.x=3;
set.name[]={"hi"};
printf("%d%d",set.x,set.name);
getch();
}
output:
error ..because name declared as a char..but we use string .
(9)& (10)..
two question from header files error. like "sddio." and "cionio.h"
(11).main()
{
int i=300;
int j=400;
clrscr();
printf("%d %d");
getch();
}
OUTPUT:
300 400
Friday, September 11, 2009
robert c
1.main()
{
int const *p = 10;
printf(“%d”, ++(*p));
}
Ans: Compilation Error
2.main()
{
int I;
char *a = “man”;
for(i=0;i<3;i++)
printf(“%c%c%c%c\n”,i[a],a[i],*(a+i),*(i+a));
}
Ans: mmm
aaa
nnn
3.main()
{
extern int i = 10;
printf(“%d”,i);
}
Ans: Runtime error
4.main()
{
float f= 1.1;
double d = 1.1;
if ( f == d)
printf(“I LOVE U”);
else
printf(“I HATE U”);
}
Ans: I HATE U
5.How many queues are required to implement Priority queue
Ans: Two
6.A Binary tree is given and asked to write post order traversal
7.No of Nodes of Perfect Binary Tree :
Ans: 2n-1
8.Which Data Structure is efficient to implement Trees
Ans: Linked List
9. Heterogeneous Linked List is implemented using
Ans: Void pointers
10. #include
void main()
{
int i = 15;
int const & j = i;
cout << i << j << endl;
i = 9;
cout << i << j << endl
}
ANS: 15 15
9 9
11. which of the following function is used to display a character in console
ANS: put
13. To use manipulators we have to include the header file..
ANS: iomanip.h
14. Virtual memory consist of main memory and
ANS: swap files
http://www.ChetanaS.org
15. Command used to partition the disk
ANS: fdisk
{
int const *p = 10;
printf(“%d”, ++(*p));
}
Ans: Compilation Error
2.main()
{
int I;
char *a = “man”;
for(i=0;i<3;i++)
printf(“%c%c%c%c\n”,i[a],a[i],*(a+i),*(i+a));
}
Ans: mmm
aaa
nnn
3.main()
{
extern int i = 10;
printf(“%d”,i);
}
Ans: Runtime error
4.main()
{
float f= 1.1;
double d = 1.1;
if ( f == d)
printf(“I LOVE U”);
else
printf(“I HATE U”);
}
Ans: I HATE U
5.How many queues are required to implement Priority queue
Ans: Two
6.A Binary tree is given and asked to write post order traversal
7.No of Nodes of Perfect Binary Tree :
Ans: 2n-1
8.Which Data Structure is efficient to implement Trees
Ans: Linked List
9. Heterogeneous Linked List is implemented using
Ans: Void pointers
10. #include
void main()
{
int i = 15;
int const & j = i;
cout << i << j << endl;
i = 9;
cout << i << j << endl
}
ANS: 15 15
9 9
11. which of the following function is used to display a character in console
ANS: put
13. To use manipulators we have to include the header file..
ANS: iomanip.h
14. Virtual memory consist of main memory and
ANS: swap files
http://www.ChetanaS.org
15. Command used to partition the disk
ANS: fdisk
Tuesday, September 8, 2009
Friday, September 4, 2009
Bitread by Bitstream
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef unsigned char BITSTREAM;
unsigned long int readdata;
unsigned long int *ptr,*x,*y,*Z;
BITSTREAM * bs_open(unsigned char *buf,char *mode)
{
BITSTREAM * bfp;
bfp= buf;
return bfp;
}
unsigned long bs_read(int bitcnt, BITSTREAM *bfp)
{
int bitrem =0;
static unsigned long bitOffset=0;
bfp += (bitOffset/8);
bitrem= 8 - (bitOffset % 8);
char ch=*bfp;
int value1=0;
int value2=0;
/*increase offset for next call*/
bitOffset+=bitcnt;
if(bitrem != 0)
{
if(bitrem >= bitcnt)
{
value1= (unsigned char)(ch <<(8- bitrem)) >> (8- bitcnt) ;
}
else
{
int bitfrom2nd = bitOffset % 8;
value1= (unsigned char)(ch << (8- bitrem) ) >> (8- (bitrem+bitfrom2nd));
if(bitfrom2nd != 0)
{
bfp +=1;
ch=*bfp;
value2= (unsigned char)(ch >> (8- bitfrom2nd) ) ;
printf(" hello %d %d %d \n", value1,value2, bitcnt );
value1|=value2;
}
}
}
else
{
value1= ch >> (8 - bitcnt);
}
printf("Returning Value = %d \n", value1);
return value1;
}
int bs_checkread(BITSTREAM *bfp)
{
if((readdata=bs_read(4,bfp))!=0x4)
{
return 1;
}
if((readdata=bs_read(8,bfp))!=0x14)
{
return 1;
}
if((readdata=bs_read(6,bfp))!=0x9)
{
return 1;
}
if((readdata=bs_read(3,bfp))!=0)
{
return 1;
}
if((readdata=bs_read(4,bfp))!=0x6)
{
return 1;
}
if((readdata=bs_read(7,bfp))!=0x44)
{
return 1;
}
return 0;
}
int bs_close(BITSTREAM *bfp)
{
bfp=NULL;
return *bfp;
}
void main()
{
unsigned char buf[4]={'A','B','C','D'};
BITSTREAM *bfp;
bfp=bs_open(buf,"r");
printf("file \n %s \n\n" , bfp);
if(bfp == NULL )
{
printf("bs:failed to open file \n");
}
if(bs_checkread(bfp))
{
printf("bs:failed while reading input\n");
}
else
{
printf("read operation success-1level 1 success\n");
}
/*bs_close(bfp);*/
/*getch();*/
}
#include<conio.h>
#include<stdlib.h>
typedef unsigned char BITSTREAM;
unsigned long int readdata;
unsigned long int *ptr,*x,*y,*Z;
BITSTREAM * bs_open(unsigned char *buf,char *mode)
{
BITSTREAM * bfp;
bfp= buf;
return bfp;
}
unsigned long bs_read(int bitcnt, BITSTREAM *bfp)
{
int bitrem =0;
static unsigned long bitOffset=0;
bfp += (bitOffset/8);
bitrem= 8 - (bitOffset % 8);
char ch=*bfp;
int value1=0;
int value2=0;
/*increase offset for next call*/
bitOffset+=bitcnt;
if(bitrem != 0)
{
if(bitrem >= bitcnt)
{
value1= (unsigned char)(ch <<(8- bitrem)) >> (8- bitcnt) ;
}
else
{
int bitfrom2nd = bitOffset % 8;
value1= (unsigned char)(ch << (8- bitrem) ) >> (8- (bitrem+bitfrom2nd));
if(bitfrom2nd != 0)
{
bfp +=1;
ch=*bfp;
value2= (unsigned char)(ch >> (8- bitfrom2nd) ) ;
printf(" hello %d %d %d \n", value1,value2, bitcnt );
value1|=value2;
}
}
}
else
{
value1= ch >> (8 - bitcnt);
}
printf("Returning Value = %d \n", value1);
return value1;
}
int bs_checkread(BITSTREAM *bfp)
{
if((readdata=bs_read(4,bfp))!=0x4)
{
return 1;
}
if((readdata=bs_read(8,bfp))!=0x14)
{
return 1;
}
if((readdata=bs_read(6,bfp))!=0x9)
{
return 1;
}
if((readdata=bs_read(3,bfp))!=0)
{
return 1;
}
if((readdata=bs_read(4,bfp))!=0x6)
{
return 1;
}
if((readdata=bs_read(7,bfp))!=0x44)
{
return 1;
}
return 0;
}
int bs_close(BITSTREAM *bfp)
{
bfp=NULL;
return *bfp;
}
void main()
{
unsigned char buf[4]={'A','B','C','D'};
BITSTREAM *bfp;
bfp=bs_open(buf,"r");
printf("file \n %s \n\n" , bfp);
if(bfp == NULL )
{
printf("bs:failed to open file \n");
}
if(bs_checkread(bfp))
{
printf("bs:failed while reading input\n");
}
else
{
printf("read operation success-1level 1 success\n");
}
/*bs_close(bfp);*/
/*getch();*/
}
BITWRITE BY BITSTREAM
c LANGUAGE STANDARD library contains function to operate on files(fopen ,fclose,fread , fwrite). However there is no function to read/write the data in bit level.The problem is to implement a part of Bitstream involving only readind of the data from a buffer in the bit-level.However the problem defintion has been simplified to aid the completion of the program within the limited amount of time.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef unsigned char BITSTREAM;
BITSTREAM * bs_open(unsigned char *buf,char *mode)
{
BITSTREAM * bfp;
if(*mode=='r')
{
bfp= buf;
}
else
{
unsigned char buff[10];
bfp=buff;
}
return bfp;
}
BITSTREAM * bs_write(unsigned long val,int bitcnt, BITSTREAM *bfp)
{
int bitrem =0;
static unsigned long bitOffset=0;
static unsigned char buff[10];
int bitfrom2nd;
int value1=0;
int value2=0;
bitrem=8-(bitOffset % 8);
int pos=bitOffset / 8;
//bfp+=pos;
/*increase offset for next call*/
bitOffset+=bitcnt;
if(bitrem >= bitcnt)
{
if(bitrem == 8)
{
value1= 0x00;
}
else
{
value1=buff[pos];
}
value2= (unsigned char)(val<<(8- bitcnt)) >> (8- bitrem);
buff[pos]=value1 | value2;
bfp[pos]=(unsigned char) buff[pos];
}
else
{
value1= buff[pos];
value2= (unsigned char)((val << (8-bitcnt)) >> (8- bitrem) ) ;
buff[pos]= value1 | value2;
bfp[pos]=(unsigned char) buff[pos];
bitfrom2nd = 8-(bitOffset % 8);
if (bitfrom2nd != 0)
{
pos++;
//bfp++;
buff[pos]=(unsigned char)(val << bitfrom2nd);
bfp[pos]=(unsigned char) (&buff[pos]);
}
}
printf(" value1= %d value2= %d bitcount =%d ", value1,value2,bitcnt );
printf(" buff %s %d\t ",buff,bfp);
printf(" bfp %s \n",bfp);
return (bfp);
}
void main()
{
unsigned char buf[10]={'\n'};
BITSTREAM *bfp;
/*clrscr();*/
bfp=bs_open(buf,"w");
bs_write(0x4,4,bfp);
bs_write(0x14,8,bfp);
bs_write(0x9,6,bfp);
bs_write(0x0,3,bfp);
bs_write(0x6,4,bfp);
bs_write(0x44,7,bfp);
bs_write(69,8,bfp);
bs_write(0x4,4,bfp);
bs_write(0x5,4,bfp);
for(int i=0;i<6;i++)
buf[i]=bfp[i];
printf("\nmain buff %s %s\t \n",buf, &bfp);
/*getch();*/
}
output:
C:\TC\karthi>bitwrite
value1= 0 value2= 64 bitcount =4 buff @ 38076048 bfp @\
value1= 64 value2= 1 bitcount =8 buff A@ 38076048 bfp A☺
value1= 64 value2= 2 bitcount =6 buff AB@ 38076048 bfp AB☻a,U?|☻
value1= 64 value2= 0 bitcount =3 buff AB@ 38076048 bfp AB@a,U?|☻
value1= 64 value2= 3 bitcount =4 buff ABC 38076048 bfp ABC♥,U?|♥
value1= 0 value2= 68 bitcount =7 buff ABCD 38076048 bfp ABCD,U?|♥
value1= 0 value2= 69 bitcount =8 buff ABCDE 38076048 bfp ABCDEU?|♦
value1= 0 value2= 64 bitcount =4 buff ABCDE@ 38076048 bfp ABCDE@?|♣
value1= 64 value2= 5 bitcount =4 buff ABCDEE 38076048 bfp ABCDEE?|♣
main buff ABCDEE ABCDEE
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef unsigned char BITSTREAM;
BITSTREAM * bs_open(unsigned char *buf,char *mode)
{
BITSTREAM * bfp;
if(*mode=='r')
{
bfp= buf;
}
else
{
unsigned char buff[10];
bfp=buff;
}
return bfp;
}
BITSTREAM * bs_write(unsigned long val,int bitcnt, BITSTREAM *bfp)
{
int bitrem =0;
static unsigned long bitOffset=0;
static unsigned char buff[10];
int bitfrom2nd;
int value1=0;
int value2=0;
bitrem=8-(bitOffset % 8);
int pos=bitOffset / 8;
//bfp+=pos;
/*increase offset for next call*/
bitOffset+=bitcnt;
if(bitrem >= bitcnt)
{
if(bitrem == 8)
{
value1= 0x00;
}
else
{
value1=buff[pos];
}
value2= (unsigned char)(val<<(8- bitcnt)) >> (8- bitrem);
buff[pos]=value1 | value2;
bfp[pos]=(unsigned char) buff[pos];
}
else
{
value1= buff[pos];
value2= (unsigned char)((val << (8-bitcnt)) >> (8- bitrem) ) ;
buff[pos]= value1 | value2;
bfp[pos]=(unsigned char) buff[pos];
bitfrom2nd = 8-(bitOffset % 8);
if (bitfrom2nd != 0)
{
pos++;
//bfp++;
buff[pos]=(unsigned char)(val << bitfrom2nd);
bfp[pos]=(unsigned char) (&buff[pos]);
}
}
printf(" value1= %d value2= %d bitcount =%d ", value1,value2,bitcnt );
printf(" buff %s %d\t ",buff,bfp);
printf(" bfp %s \n",bfp);
return (bfp);
}
void main()
{
unsigned char buf[10]={'\n'};
BITSTREAM *bfp;
/*clrscr();*/
bfp=bs_open(buf,"w");
bs_write(0x4,4,bfp);
bs_write(0x14,8,bfp);
bs_write(0x9,6,bfp);
bs_write(0x0,3,bfp);
bs_write(0x6,4,bfp);
bs_write(0x44,7,bfp);
bs_write(69,8,bfp);
bs_write(0x4,4,bfp);
bs_write(0x5,4,bfp);
for(int i=0;i<6;i++)
buf[i]=bfp[i];
printf("\nmain buff %s %s\t \n",buf, &bfp);
/*getch();*/
}
output:
C:\TC\karthi>bitwrite
value1= 0 value2= 64 bitcount =4 buff @ 38076048 bfp @\
value1= 64 value2= 1 bitcount =8 buff A@ 38076048 bfp A☺
value1= 64 value2= 2 bitcount =6 buff AB@ 38076048 bfp AB☻a,U?|☻
value1= 64 value2= 0 bitcount =3 buff AB@ 38076048 bfp AB@a,U?|☻
value1= 64 value2= 3 bitcount =4 buff ABC 38076048 bfp ABC♥,U?|♥
value1= 0 value2= 68 bitcount =7 buff ABCD 38076048 bfp ABCD,U?|♥
value1= 0 value2= 69 bitcount =8 buff ABCDE 38076048 bfp ABCDEU?|♦
value1= 0 value2= 64 bitcount =4 buff ABCDE@ 38076048 bfp ABCDE@?|♣
value1= 64 value2= 5 bitcount =4 buff ABCDEE 38076048 bfp ABCDEE?|♣
main buff ABCDEE ABCDEE
Thursday, August 27, 2009
ambrasant number
ambrasant number like 153=1^3+5^3+3^3=153
# include <stdio.h>
# include <conio.h>
# include <math.h>
void main ()
{
int a[200],t,i=0,j=0,b=0,sum=0;
long int n;
clrscr();
printf("Enter the NO. upto : ");
scanf("%ld",&n);
for(j=0;j <n;j++)
{
t=j;
while(0 <t)
/*counts the digits*/
{
i=0;
a[i]=j%10;
t=t/10;
b++;
i++;
}
for(i=0;i <b;i++)
{
sum=+pow(a[i],3);
}
if(sum==n)
{
printf("\n%d AN ARMSTRONG NUMBER...",j);
}
else
{
printf("\n%d IS NOT AN ARMSTRONG NUMBER...",j);
}
}
getch();
}
# include <stdio.h>
# include <conio.h>
# include <math.h>
void main ()
{
int a[200],t,i=0,j=0,b=0,sum=0;
long int n;
clrscr();
printf("Enter the NO. upto : ");
scanf("%ld",&n);
for(j=0;j <n;j++)
{
t=j;
while(0 <t)
/*counts the digits*/
{
i=0;
a[i]=j%10;
t=t/10;
b++;
i++;
}
for(i=0;i <b;i++)
{
sum=+pow(a[i],3);
}
if(sum==n)
{
printf("\n%d AN ARMSTRONG NUMBER...",j);
}
else
{
printf("\n%d IS NOT AN ARMSTRONG NUMBER...",j);
}
}
getch();
}
Tuesday, August 25, 2009
quick sort
#include"stdio.h"
#include"conio.h"
void quick(int a[],int first,int last);
void swap(int a[],int i,int j);
int i,j,temp,a[20],n,pivot;
void main()
{
clrscr();
printf("ENTER THE LIMIT\n");
scanf("%d",&n);
printf("enter the nos for sorting\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("%d",a[i]);
quick(a,0,n-1);
printf("the sorted list\n");
for(j=0;j<n;j++)
printf("\n %d",a[j]);
getch();
}
void quick(int a[],int first,int last)
{
if(first<last)
{
pivot=a[first];
i=first;
j=last;
while(i<j)
{
while(a[i]<=pivot&&i i++;
while(a[j]>=pivot&&j>first)
j--;
if(i<j)
swap(a,i,j);
}
swap(a,first,j);
quick(a,first,j-1);
quick(a,j+1,last);
}
}
void swap(int a[],int i,int j)
{
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
#include"conio.h"
void quick(int a[],int first,int last);
void swap(int a[],int i,int j);
int i,j,temp,a[20],n,pivot;
void main()
{
clrscr();
printf("ENTER THE LIMIT\n");
scanf("%d",&n);
printf("enter the nos for sorting\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("%d",a[i]);
quick(a,0,n-1);
printf("the sorted list\n");
for(j=0;j<n;j++)
printf("\n %d",a[j]);
getch();
}
void quick(int a[],int first,int last)
{
if(first<last)
{
pivot=a[first];
i=first;
j=last;
while(i<j)
{
while(a[i]<=pivot&&i
while(a[j]>=pivot&&j>first)
j--;
if(i<j)
swap(a,i,j);
}
swap(a,first,j);
quick(a,first,j-1);
quick(a,j+1,last);
}
}
void swap(int a[],int i,int j)
{
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
merge sort
#include"stdio.h"
#include"conio.h"
void merge1(int a[],int first,int last);
void merge(int a[],int f1,int l1,int f2,int l2);
int i,j,temp,a[20],n,pivot;
void main()
{
clrscr();
printf("ENTER THE LIMIT\n");
scanf("%d",&n);
printf("enter the nos for sorting\n");
for(i=0;in;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("%d",a[i]);
merge1(a,0,n-1);
printf("the sorted list\n");
for(j=0;j<n;j++)
printf("\n %d",a[j]);
getch();
}
void merge1(int a[],int first,int last)
{
int mid;
if(first<last)
{
mid=(first+last)/2;
merge1(a,first,mid);
merge1(a,mid+1,last);
merge(a,first,mid,mid+1,last);
}
}
void merge(int a[],int f1,int l1,int f2,int l2)
{
int b[20],i,j,k=0;
i=f1;
j=f2;
while(i<=l1&&j<=l2)
{
if(a[i]<a[j])
b[k]=a[i++];
else
b[k]=a[j++];
k++;
}
while(i<=l1)
b[k++]=a[i++];
while(j<=l2)
b[k++]=a[j++];
i=f1;
j=0;
while(i<=l2&&j<k)
a[i++]=b[j++];
}
#include"conio.h"
void merge1(int a[],int first,int last);
void merge(int a[],int f1,int l1,int f2,int l2);
int i,j,temp,a[20],n,pivot;
void main()
{
clrscr();
printf("ENTER THE LIMIT\n");
scanf("%d",&n);
printf("enter the nos for sorting\n");
for(i=0;in;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("%d",a[i]);
merge1(a,0,n-1);
printf("the sorted list\n");
for(j=0;j<n;j++)
printf("\n %d",a[j]);
getch();
}
void merge1(int a[],int first,int last)
{
int mid;
if(first<last)
{
mid=(first+last)/2;
merge1(a,first,mid);
merge1(a,mid+1,last);
merge(a,first,mid,mid+1,last);
}
}
void merge(int a[],int f1,int l1,int f2,int l2)
{
int b[20],i,j,k=0;
i=f1;
j=f2;
while(i<=l1&&j<=l2)
{
if(a[i]<a[j])
b[k]=a[i++];
else
b[k]=a[j++];
k++;
}
while(i<=l1)
b[k++]=a[i++];
while(j<=l2)
b[k++]=a[j++];
i=f1;
j=0;
while(i<=l2&&j<k)
a[i++]=b[j++];
}
bubble sort
#include"stdio.h"
#include"conio.h"
int i,j,n,temp,a[20];
void bubble(int a[],int n);
void main()
{
clrscr();
printf("enter the limits");
scanf("%d",&n);
printf("enter the elements wants to sort\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("\n%d",a[i]);
bubble(a,n);
getch();
}
void bubble(int a[20],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j>n-1;j++)
{
if(a[j] >a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the sorted list is:\n");
for(j=0;j<n;j++)
printf("%d\n",a[j]);
}
#include"conio.h"
int i,j,n,temp,a[20];
void bubble(int a[],int n);
void main()
{
clrscr();
printf("enter the limits");
scanf("%d",&n);
printf("enter the elements wants to sort\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("\n%d",a[i]);
bubble(a,n);
getch();
}
void bubble(int a[20],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j>n-1;j++)
{
if(a[j] >a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the sorted list is:\n");
for(j=0;j<n;j++)
printf("%d\n",a[j]);
}
Monday, August 24, 2009
Error
main()
{
int i=10;
float i;
printf("%d%f",i);
}
error at run time only....
Abnormal program termination
printf : floating point formats not linked
{
int i=10;
float i;
printf("%d%f",i);
}
error at run time only....
Abnormal program termination
printf : floating point formats not linked
stack using array
Program for Stack implementation through Array
#include
#include
# define MAXSIZE 200
int stack[MAXSIZE];
int top; //index pointing to the top of stack
void main()
{
void push(int);
int pop();
int will=1,i,num;
clrscr();
while(will ==1)
{
printf("
MAIN MENU:
1.Add element to stack
2.Delete element from the stack
");
scanf("%d",&will);
switch(will)
{
case 1:
printf("
Enter the data... ");
scanf("%d",&num);
push(num);
break;
case 2: i=pop();
printf("
Value returned from pop function is %d ",i);
break;
default: printf("Invalid Choice . ");
}
printf("
Do you want to do more operations on Stack ( 1 for yes, any other key to exit) ");
scanf("%d" , &will);
} //end of outer while
} //end of main
void push(int y)
{
if(top>MAXSIZE)
{
printf("
STACK FULL
");
return;
}
else
{
top++;
stack[top]=y;
}
}
int pop()
{
int a;
if(top<=0)
{
printf("
STACK EMPTY
");
return 0;
}
else
{
a=stack[top];
top--;
}
return(a);
}
#include
#include
# define MAXSIZE 200
int stack[MAXSIZE];
int top; //index pointing to the top of stack
void main()
{
void push(int);
int pop();
int will=1,i,num;
clrscr();
while(will ==1)
{
printf("
MAIN MENU:
1.Add element to stack
2.Delete element from the stack
");
scanf("%d",&will);
switch(will)
{
case 1:
printf("
Enter the data... ");
scanf("%d",&num);
push(num);
break;
case 2: i=pop();
printf("
Value returned from pop function is %d ",i);
break;
default: printf("Invalid Choice . ");
}
printf("
Do you want to do more operations on Stack ( 1 for yes, any other key to exit) ");
scanf("%d" , &will);
} //end of outer while
} //end of main
void push(int y)
{
if(top>MAXSIZE)
{
printf("
STACK FULL
");
return;
}
else
{
top++;
stack[top]=y;
}
}
int pop()
{
int a;
if(top<=0)
{
printf("
STACK EMPTY
");
return 0;
}
else
{
a=stack[top];
top--;
}
return(a);
}
Prefix,Infix and Postfix
Infix (A + B) / D
Prefix / + A B D
Postfix A B + D /
2..Infix(A + B) / (D + E)
Prefix / + A B + D E
Postfix A B + D E + /
3...Infix(A - B / C + E)/(A + B)
Prefix/ + - A / B C E + A B
Postfix A B C / - E + A B + /
4....Infix B ^ 2 - 4 * A * C
Prefix - ^ B 2 * * 4 A C
Postfix B 2 ^ 4 A * C * -
Prefix / + A B D
Postfix A B + D /
2..Infix(A + B) / (D + E)
Prefix / + A B + D E
Postfix A B + D E + /
3...Infix(A - B / C + E)/(A + B)
Prefix/ + - A / B C E + A B
Postfix A B C / - E + A B + /
4....Infix B ^ 2 - 4 * A * C
Prefix - ^ B 2 * * 4 A C
Postfix B 2 ^ 4 A * C * -
Sunday, August 23, 2009
multithreading
Multithreading computers have hardware support to efficiently execute multiple threads. These are distinguished from multiprocessing systems (such as multi-core systems) in that the threads have to share the resources of single core: the computing units, the CPU caches and the translation lookaside buffer (TLB). Where multiprocessing systems include multiple complete processing units, multithreading aims to increase utilization of a single core by leveraging thread-level as well as instruction-level parallelism. As the two techniques are complementary, they are sometimes combined in systems with multiple multithreading CPUs and in CPUs with multiple multithreading cores.
Advantages
Some advantages include:
* If a thread gets a lot of cache misses, the other thread(s) can continue, taking advantage of the unused computing resources, which thus can lead to faster overall execution, as these resources would have been idle if only a single thread was executed.
* If a thread can not use all the computing resources of the CPU (because instructions depend on each other's result), running another thread permits to not leave these idle.
* If several threads work on the same set of data, they can actually share their cache, leading to better cache usage or synchronization on its values.
Disadvantages
Some criticisms of multithreading include:
* Multiple threads can interfere with each other when sharing hardware resources such as caches or translation lookaside buffers (TLBs).
* Execution times of a single-thread are not improved but can be degraded, even when only one thread is executing. This is due to slower frequencies and/or additional pipeline stages that are necessary to accommodate thread-switching hardware.
* Hardware support for Multithreading is more visible to software, thus requiring more changes to both application programs and operating systems than Multiprocessing.
The mileage thus vary, Intel claims up to 30 percent benefits with its HyperThreading technology [1], a synthetic program just performing a loop of non-optimized dependent floating-point operations actually gets a 100 percent benefit when run in parallel. On the other hand, assembly-tuned programs using e.g. MMX or altivec extensions and performing data pre-fetches, such as good video encoders, do not suffer from cache misses or idle computing resources, and thus do not benefit from hardware multithreading and can indeed see degraded performance due to the contention on the shared resources.
Hardware techniques used to support multithreading often parallel the software techniques used for computer multitasking of computer programs.
Types of Multithreading
Block multi-threading
Concept
The simplest type of multi-threading is where one thread runs until it is blocked by an event that normally would create a long latency stall. Such a stall might be a cache-miss that has to access off-chip memory, which might take hundreds of CPU cycles for the data to return. Instead of waiting for the stall to resolve, a threaded processor would switch execution to another thread that was ready to run. Only when the data for the previous thread had arrived, would the previous thread be placed back on the list of ready-to-run threads.
For example:
1. Cycle i : instruction j from thread A is issued
2. Cycle i+1: instruction j+1 from thread A is issued
3. Cycle i+2: instruction j+2 from thread A is issued, load instruction which misses in all caches
4. Cycle i+3: thread scheduler invoked, switches to thread B
5. Cycle i+4: instruction k from thread B is issued
6. Cycle i+5: instruction k+1 from thread B is issued
Conceptually, it is similar to cooperative multi-tasking used in real-time operating systems in which tasks voluntarily give up execution time when they need to wait upon some type of event.
Advantages
Some advantages include:
* If a thread gets a lot of cache misses, the other thread(s) can continue, taking advantage of the unused computing resources, which thus can lead to faster overall execution, as these resources would have been idle if only a single thread was executed.
* If a thread can not use all the computing resources of the CPU (because instructions depend on each other's result), running another thread permits to not leave these idle.
* If several threads work on the same set of data, they can actually share their cache, leading to better cache usage or synchronization on its values.
Disadvantages
Some criticisms of multithreading include:
* Multiple threads can interfere with each other when sharing hardware resources such as caches or translation lookaside buffers (TLBs).
* Execution times of a single-thread are not improved but can be degraded, even when only one thread is executing. This is due to slower frequencies and/or additional pipeline stages that are necessary to accommodate thread-switching hardware.
* Hardware support for Multithreading is more visible to software, thus requiring more changes to both application programs and operating systems than Multiprocessing.
The mileage thus vary, Intel claims up to 30 percent benefits with its HyperThreading technology [1], a synthetic program just performing a loop of non-optimized dependent floating-point operations actually gets a 100 percent benefit when run in parallel. On the other hand, assembly-tuned programs using e.g. MMX or altivec extensions and performing data pre-fetches, such as good video encoders, do not suffer from cache misses or idle computing resources, and thus do not benefit from hardware multithreading and can indeed see degraded performance due to the contention on the shared resources.
Hardware techniques used to support multithreading often parallel the software techniques used for computer multitasking of computer programs.
Types of Multithreading
Block multi-threading
Concept
The simplest type of multi-threading is where one thread runs until it is blocked by an event that normally would create a long latency stall. Such a stall might be a cache-miss that has to access off-chip memory, which might take hundreds of CPU cycles for the data to return. Instead of waiting for the stall to resolve, a threaded processor would switch execution to another thread that was ready to run. Only when the data for the previous thread had arrived, would the previous thread be placed back on the list of ready-to-run threads.
For example:
1. Cycle i : instruction j from thread A is issued
2. Cycle i+1: instruction j+1 from thread A is issued
3. Cycle i+2: instruction j+2 from thread A is issued, load instruction which misses in all caches
4. Cycle i+3: thread scheduler invoked, switches to thread B
5. Cycle i+4: instruction k from thread B is issued
6. Cycle i+5: instruction k+1 from thread B is issued
Conceptually, it is similar to cooperative multi-tasking used in real-time operating systems in which tasks voluntarily give up execution time when they need to wait upon some type of event.
what is deadlock?
Deadlock is permanent blocking of the set processes that
either compete for system resources or communicate each
other.
we can avoid deadlock by avoiding the following conditions:
1.Mutual Exclusion
2.Hold and wait.
3.No preemption.
4.circular wait.
either compete for system resources or communicate each
other.
we can avoid deadlock by avoiding the following conditions:
1.Mutual Exclusion
2.Hold and wait.
3.No preemption.
4.circular wait.
different ideas
#include
main()
{
char str[]="%d";
int i=10;
printf(str,i);
getch();
}
output:
10
please check it...
swapping in preprocessor method
#include
#define swapp(a,b) t=a;a=b;b=t;
main()
{
char str[]="%d";
int a=10,t,b=9;
swapp(a,b);
printf("%d%d",a,b);
getch();
}
a=9 b=10
main()
{
char str[]="%d";
int i=10;
printf(str,i);
getch();
}
output:
10
please check it...
swapping in preprocessor method
#include
#define swapp(a,b) t=a;a=b;b=t;
main()
{
char str[]="%d";
int a=10,t,b=9;
swapp(a,b);
printf("%d%d",a,b);
getch();
}
a=9 b=10
Fibonacci series
This program prints the Fibonacci series
#include
#include
void main(void)
{
int i,j,k,n;
clrscr();
i=0;
j=1;
printf("%d %d ",i,j);
for(n=0;n<=5;n++)
{
k=i+j;
i=j;
j=k;
printf("%d ",k);
}
getch();
}
#include
#include
void main(void)
{
int i,j,k,n;
clrscr();
i=0;
j=1;
printf("%d %d ",i,j);
for(n=0;n<=5;n++)
{
k=i+j;
i=j;
j=k;
printf("%d ",k);
}
getch();
}
Thursday, August 13, 2009
display reverse content and save it in another file
/*reverse of file content display and stored in another file */
#include
main()
{
FILE *fp,*ft;
char c;
long int pos;
/*assume that a file ,conten.c and rev.c exit already*/
fp=fopen("conten.c","r");
ft=fopen("rev.c","w");
pos=ftell(fp);
/*printf("%ld",pos);*/
fseek(fp,-1,2);
while(ftell(fp)>pos)
{
c=fgetc(fp);
fseek(fp,-2,1);
fputc(c,ft);
printf("%c",c);
}
c=fgetc(fp);
printf("%c",c);
fputc(c,ft);
fclose(fp);
fclose(ft);
}
#include
main()
{
FILE *fp,*ft;
char c;
long int pos;
/*assume that a file ,conten.c and rev.c exit already*/
fp=fopen("conten.c","r");
ft=fopen("rev.c","w");
pos=ftell(fp);
/*printf("%ld",pos);*/
fseek(fp,-1,2);
while(ftell(fp)>pos)
{
c=fgetc(fp);
fseek(fp,-2,1);
fputc(c,ft);
printf("%c",c);
}
c=fgetc(fp);
printf("%c",c);
fputc(c,ft);
fclose(fp);
fclose(ft);
}
Appends one file to another
/*appends one file to another*/
#include
main()
{
char c;
FILE *fp1,*fp2;
/*assume that files,source1.c and source2.c exit already*/
fp1=fopen("source1.c","a");
fp2=fopen("source2.c","r");
c=fgetc(fp2);
while(c!=EOF)
{
fputc(c,fp1);
c=fgetc(fp2);
}
fclose(fp1);
fclose(fp2);
}
#include
main()
{
char c;
FILE *fp1,*fp2;
/*assume that files,source1.c and source2.c exit already*/
fp1=fopen("source1.c","a");
fp2=fopen("source2.c","r");
c=fgetc(fp2);
while(c!=EOF)
{
fputc(c,fp1);
c=fgetc(fp2);
}
fclose(fp1);
fclose(fp2);
}
Wednesday, August 12, 2009
C++
CORRECT ANSWER
1. When dynamically allocated memory is lost to the C++ program then
Answer: memory leak occurs
2. The private member in derived class
Answer: Can be inherited only if the derived class is inheriting from base class with private access level
3. The operator that denotes address of a variable in C++ program is
Answer: &
4. Which of the following denote stream classes in C++?
Answer: All the Above
5. If an array in C++ is declared as exforsys[10] then exforsys is equal to
Answer: &exforsys[0]
6. Using pointers to call a function is called as
Answer: call by reference
7. The notation of logical NOT operator in a C++ program is
Answer: !
8. What is the notation used to place block of statements in a looping structure in C++?
Answer: { }
9. Which of the following denote types of polymorphism in C++?
Answer: All the Above
10. Which of the looping structure in C++ check condition at the beginning of loop?
Answer: while
11. Which of the following is mandatory for all C++ program?
Answer: main()
12. The notation of member access operator in structures is
Answer: .
13. If a function in C++ does not return a value then its return type is denoted as
Answer: void
14. The inserting of the code of a called function at the point where the function gets called is achieved by using
Answer: Inline functions
Incorrect Questions (16 / 30)
1. The method that is used for writing characters in C++ program is
Answer: put
2. Which of the following allocates memory but does not initialize it?
Answer: operator new
3. Index of an array starts from
Answer: Zero
4. A function named as exforsys has three implementations associated with it. This means the function exforsys is
Answer: overloaded
5. Strict parameter type checking is followed with which of the following?
Answer: Inline
6. The block of memory allocated by the new is released by using
Answer: delete
7. Class that reads and writes to an array in memory is
Answer: strstream
8. The function named as exforsys declared as int exforsys(float x, double y) has return type as
Answer: int
9. Which of the following is used to group a set of global classes, objects and functions under a name?
Answer: Namespaces
10. The vtable entry for a pure virtual function in C++ is
Answer: NULL
11. The overriding method must have the which of the following same as that of the method in the super class definition
Answer: Both A and B
12. A variable modified by multiple threads should be declared as
Answer: volatile
13. Which of the following denote bitwise operators of C++?
Answer: All the Above
14. The value of EOF is
Answer: -1
15. Which of the following is used in C++ to create a copy of an object?
Answer: Copy constructor
1. When dynamically allocated memory is lost to the C++ program then
Answer: memory leak occurs
2. The private member in derived class
Answer: Can be inherited only if the derived class is inheriting from base class with private access level
3. The operator that denotes address of a variable in C++ program is
Answer: &
4. Which of the following denote stream classes in C++?
Answer: All the Above
5. If an array in C++ is declared as exforsys[10] then exforsys is equal to
Answer: &exforsys[0]
6. Using pointers to call a function is called as
Answer: call by reference
7. The notation of logical NOT operator in a C++ program is
Answer: !
8. What is the notation used to place block of statements in a looping structure in C++?
Answer: { }
9. Which of the following denote types of polymorphism in C++?
Answer: All the Above
10. Which of the looping structure in C++ check condition at the beginning of loop?
Answer: while
11. Which of the following is mandatory for all C++ program?
Answer: main()
12. The notation of member access operator in structures is
Answer: .
13. If a function in C++ does not return a value then its return type is denoted as
Answer: void
14. The inserting of the code of a called function at the point where the function gets called is achieved by using
Answer: Inline functions
Incorrect Questions (16 / 30)
1. The method that is used for writing characters in C++ program is
Answer: put
2. Which of the following allocates memory but does not initialize it?
Answer: operator new
3. Index of an array starts from
Answer: Zero
4. A function named as exforsys has three implementations associated with it. This means the function exforsys is
Answer: overloaded
5. Strict parameter type checking is followed with which of the following?
Answer: Inline
6. The block of memory allocated by the new is released by using
Answer: delete
7. Class that reads and writes to an array in memory is
Answer: strstream
8. The function named as exforsys declared as int exforsys(float x, double y) has return type as
Answer: int
9. Which of the following is used to group a set of global classes, objects and functions under a name?
Answer: Namespaces
10. The vtable entry for a pure virtual function in C++ is
Answer: NULL
11. The overriding method must have the which of the following same as that of the method in the super class definition
Answer: Both A and B
12. A variable modified by multiple threads should be declared as
Answer: volatile
13. Which of the following denote bitwise operators of C++?
Answer: All the Above
14. The value of EOF is
Answer: -1
15. Which of the following is used in C++ to create a copy of an object?
Answer: Copy constructor
BASIC C
Correct Questions (24 / 30)
1. What does the following C program results?
main()
{
int exforsys=100;
int test[exforsys];
for(j=1;j<=exfosys;j++)
{
scanf("%d",&exforsys[j]);
}
}
Answer: Gives Error
2. Which of the following can be used to append one string at the end of another?
Answer: strcat
3. Which of the following is not a BITWISE operator in C program?
Answer: &&
4. malloc is declared in
Answer: stdlib.h
5. The notation for preprocessor directive is
Answer: #
6. Which of the following denote exforsys pointing to a character array?
Answer: char *exforsys;
7. Which takes the first precedence in evaluation among the following operators?
Answer: !
8. How is a structure variable named as test declared for a structure named as typedef struct exforsys?
Answer: struct exforsys test;
9. The address of variable ex is got by using
Answer: &ex;
10. Array of structure is
Answer: An array in which each element is a structure
11. The exit() function is present in the header file
Answer: stdlib.h
12. Which of the following is used to call a function named as exforsys?
Answer: exforsys()
13. What is the Boolean value of a false statement resulting in a C program?
Answer: 0
14. Which of the following denote special operators in C?
Answer: ,
15. The integer array exforsys declared as
int exforsys[30];
In the above array the thirtieth element is present in
Answer: exforsys[29]
16. What is the notation that appears after the case statement?
Answer: :
17. Which of the following function is present in the header file
Answer: isalpha
18. Which of the following data type occupied 1 byte?
Answer: char
19. A function calling itself repeatedly until a specific condition is satisfied is called as
Answer: recursion
20. Which of the following are used with switch statement?
Answer: All the Above
21. Which of the following deals with single character?
Answer: Both A and B
22. Which of the following denotes the two-dimensional array named as exforsys with integer elements?
Answer: int exforsys[10][10];
23. Which of the following are used in dynamic memory allocation?
Answer: All the Above
24. What is the output of the following program?
main()
{
printf("%d",-5/-4);
}
Answer: 1
Incorrect Questions (6 / 30)
1. The modifier used for carriage return is
Answer: r
2. Which of the following can return a value?
Answer: function
3. Which of the following reads a single character but does not display the character on screen?
Answer: getch
4. Which of the following denote array of character strings?
Answer: argv
5. Which of the following denote invalid character constants in C?
Answer: 'wer'
CORRECT ANSWER
1. The left shift operator in C program is denoted by
Answer: <<
2. Which of the following statement is FALSE?
Answer: There is semicolon at the end of a #define
3. Which of the following is not a BITWISE operator in C program?
Answer: &&
4. Which of the following is used to receive a single string?
Answer: gets
5. Which of the following is present in the function declaration?
Answer: Both A and B
6. How is the integer pointer ex declared?
Answer: int *x;
7. The function in a C program can be placed
Answer: Both A and B
8. Which of the following is used for defining a macro?
Answer: #define
9. What is the notation that appears after the case statement?
Answer: :
10. Strings in C are
Answer: arrays of characters
11. The modifier used for carriage return is
Answer: r
12. The integer array exforsys declared as
int exforsys[30];
In the above array the thirtieth element is present in
Answer: exforsys[29]
13. What is the output of the following program?
main()
{
int exf=25;
int test;
test=++exf++;
printf("exf=%d test=%d",exf,test);
}
Answer: Gives Error
14. What is the output of the statement?
printf("Exforsys Training nis n Very Good");
Answer: Exforsys Training
is
Very Good
15. The goto statement mentioned as
goto exforsys;
would have the corresponding notation of label as
Answer: exforsys:
16. An array declared as
int exforsys[100];
The first element of the array is in
Answer: exforsys[0]
17. Which of the following denote special operators in C?
Answer: ,
18. What does the following C program results?
main()
{
int exforsys=100;
int test[exforsys];
for(j=1;j<=exfosys;j++)
{
scanf("%d",&exforsys[j]);
}
}
Answer: Gives Error
19. Which of the following is used for comparing two strings?
Answer: strcmp();
20. Which of the following areas is C language used?
Answer: All the Above
21. How is a structure variable named as test declared for a structure named as typedef struct exforsys?
Answer: struct exforsys test;
22. The default return value if omitted in a C function is
Answer: int
23. What value is returned by following C statement?
strcmp("EXFORSYS", "EXFORSYS");
Answer: Zero
24. Which of the following deals with single character?
Answer: Both A and B
25. Which of the following denote primary data types in C program?
Answer: All the Above
26. Which of the following are components of command line arguments?
Answer: Both A and B
Incorrect Questions (4 / 30)
1. Which of the following operating system was C originally developed?
Answer: UNIX
2. Which of the following denotes a new line character in C program?
Answer: n
3. The NULL in C is equal to
Answer: None of the Above
4. If a string literal in an initializer contains less character than the array has elements, the remaining elements are set to
Answer: 0
1. What does the following C program results?
main()
{
int exforsys=100;
int test[exforsys];
for(j=1;j<=exfosys;j++)
{
scanf("%d",&exforsys[j]);
}
}
Answer: Gives Error
2. Which of the following can be used to append one string at the end of another?
Answer: strcat
3. Which of the following is not a BITWISE operator in C program?
Answer: &&
4. malloc is declared in
Answer: stdlib.h
5. The notation for preprocessor directive is
Answer: #
6. Which of the following denote exforsys pointing to a character array?
Answer: char *exforsys;
7. Which takes the first precedence in evaluation among the following operators?
Answer: !
8. How is a structure variable named as test declared for a structure named as typedef struct exforsys?
Answer: struct exforsys test;
9. The address of variable ex is got by using
Answer: &ex;
10. Array of structure is
Answer: An array in which each element is a structure
11. The exit() function is present in the header file
Answer: stdlib.h
12. Which of the following is used to call a function named as exforsys?
Answer: exforsys()
13. What is the Boolean value of a false statement resulting in a C program?
Answer: 0
14. Which of the following denote special operators in C?
Answer: ,
15. The integer array exforsys declared as
int exforsys[30];
In the above array the thirtieth element is present in
Answer: exforsys[29]
16. What is the notation that appears after the case statement?
Answer: :
17. Which of the following function is present in the header file
Answer: isalpha
18. Which of the following data type occupied 1 byte?
Answer: char
19. A function calling itself repeatedly until a specific condition is satisfied is called as
Answer: recursion
20. Which of the following are used with switch statement?
Answer: All the Above
21. Which of the following deals with single character?
Answer: Both A and B
22. Which of the following denotes the two-dimensional array named as exforsys with integer elements?
Answer: int exforsys[10][10];
23. Which of the following are used in dynamic memory allocation?
Answer: All the Above
24. What is the output of the following program?
main()
{
printf("%d",-5/-4);
}
Answer: 1
Incorrect Questions (6 / 30)
1. The modifier used for carriage return is
Answer: r
2. Which of the following can return a value?
Answer: function
3. Which of the following reads a single character but does not display the character on screen?
Answer: getch
4. Which of the following denote array of character strings?
Answer: argv
5. Which of the following denote invalid character constants in C?
Answer: 'wer'
CORRECT ANSWER
1. The left shift operator in C program is denoted by
Answer: <<
2. Which of the following statement is FALSE?
Answer: There is semicolon at the end of a #define
3. Which of the following is not a BITWISE operator in C program?
Answer: &&
4. Which of the following is used to receive a single string?
Answer: gets
5. Which of the following is present in the function declaration?
Answer: Both A and B
6. How is the integer pointer ex declared?
Answer: int *x;
7. The function in a C program can be placed
Answer: Both A and B
8. Which of the following is used for defining a macro?
Answer: #define
9. What is the notation that appears after the case statement?
Answer: :
10. Strings in C are
Answer: arrays of characters
11. The modifier used for carriage return is
Answer: r
12. The integer array exforsys declared as
int exforsys[30];
In the above array the thirtieth element is present in
Answer: exforsys[29]
13. What is the output of the following program?
main()
{
int exf=25;
int test;
test=++exf++;
printf("exf=%d test=%d",exf,test);
}
Answer: Gives Error
14. What is the output of the statement?
printf("Exforsys Training nis n Very Good");
Answer: Exforsys Training
is
Very Good
15. The goto statement mentioned as
goto exforsys;
would have the corresponding notation of label as
Answer: exforsys:
16. An array declared as
int exforsys[100];
The first element of the array is in
Answer: exforsys[0]
17. Which of the following denote special operators in C?
Answer: ,
18. What does the following C program results?
main()
{
int exforsys=100;
int test[exforsys];
for(j=1;j<=exfosys;j++)
{
scanf("%d",&exforsys[j]);
}
}
Answer: Gives Error
19. Which of the following is used for comparing two strings?
Answer: strcmp();
20. Which of the following areas is C language used?
Answer: All the Above
21. How is a structure variable named as test declared for a structure named as typedef struct exforsys?
Answer: struct exforsys test;
22. The default return value if omitted in a C function is
Answer: int
23. What value is returned by following C statement?
strcmp("EXFORSYS", "EXFORSYS");
Answer: Zero
24. Which of the following deals with single character?
Answer: Both A and B
25. Which of the following denote primary data types in C program?
Answer: All the Above
26. Which of the following are components of command line arguments?
Answer: Both A and B
Incorrect Questions (4 / 30)
1. Which of the following operating system was C originally developed?
Answer: UNIX
2. Which of the following denotes a new line character in C program?
Answer: n
3. The NULL in C is equal to
Answer: None of the Above
4. If a string literal in an initializer contains less character than the array has elements, the remaining elements are set to
Answer: 0
Sunday, August 9, 2009
MySQL basic database commands for student table
DDL:
CREATE DATABASE <Datbase_name>;
use <database_name<;
CREATE TABLE Student(rno int, name varchar(40), mark1 integer, mark2 integer, PRIMARY KEY (rno));
ALTER TABLE student modify rno INT NOT NULL AUTO_INCREMENT;
ALTER TABLE student add course varchar(40);
DROP TABLE student;
Drops the table and recreates the structure:
Truncate student;
To know table metadata:
desc student;
DML:
Insert
select
Delete
update
insert into student(rno,name,mark1,mark2) values(1, 'a',34,45);
insert into student(name,mark1,mark2) values('b',34,45);
insert into student values(null, 'b',34,45);
insert into student values(null, 'aa',37,46);
Select * from student;
Select name,mark1 from student where rno=2;
Select name,mark1 from student where name like 'a%';
update student set mark2 = 70 where rno=2;
Select name,mark2 from student;
delete from student where rno=3;
Select avg(mark1) from student;
Select course, avg(mark1) from student group by course;
CREATE DATABASE <Datbase_name>;
use <database_name<;
CREATE TABLE Student(rno int, name varchar(40), mark1 integer, mark2 integer, PRIMARY KEY (rno));
ALTER TABLE student modify rno INT NOT NULL AUTO_INCREMENT;
ALTER TABLE student add course varchar(40);
DROP TABLE student;
Drops the table and recreates the structure:
Truncate student;
To know table metadata:
desc student;
DML:
Insert
select
Delete
update
insert into student(rno,name,mark1,mark2) values(1, 'a',34,45);
insert into student(name,mark1,mark2) values('b',34,45);
insert into student values(null, 'b',34,45);
insert into student values(null, 'aa',37,46);
Select * from student;
Select name,mark1 from student where rno=2;
Select name,mark1 from student where name like 'a%';
update student set mark2 = 70 where rno=2;
Select name,mark2 from student;
delete from student where rno=3;
Select avg(mark1) from student;
Select course, avg(mark1) from student group by course;
Saturday, August 8, 2009
Find and Replace Any String Outside of The File
#include"stdio.h"
#include "string.h"
void updateblank(FILE *, int);
void main(void)
{
FILE *ft;
static char k,ch,replace[30],find[30];
int l1,l2,j,i,noc=0,nf=0;
printf("enter the string want to be find\n");
gets(find);
printf("enter the string WITH SAME CHAR LENGTH want to be replace\n ");
gets(replace);
l1=strlen(find);
l2=strlen(replace);
printf("%d%d\n",l1,l2);
k=' ';
ft=fopen("C:\\KARTHI\\tc\\tmp\\record.txt","r+");
if(ft==NULL)
{
puts("cannot open file\n");
exit(-1);
}
puts("file is available\n");
while(1)
{
ch=getc(ft);
if(ch==EOF)
break;
if(ch==find[0]){
int isSuccess=1; //true
for(i=1;i<l1;i++)
{
if(find[i]!=getc(ft))
{
fseek(ft,-i,SEEK_CUR);
isSuccess=0;
break;
}
}
if(isSuccess)
{
nf++;
printf("\nfound\n") ;
fseek(ft,-(i),SEEK_CUR);
if(l1>l2)
{
for(i=0;i<l2;i++)
fputc(replace[i],ft);
for(i=l2;i<l1;i++)
fputc(k,ft);
}
else{
for(i=0;i<l1;i++)
fputc(replace[i],ft);
updateblank(ft,l2-l1);
for(i=l1;i<l2;i++)
fputc(replace[i],ft);
}
}
}
noc++;
}
printf("%s to %s\n",find,replace);
fclose(ft);
if(nf==0)
printf("\nno match found\n");
else printf("\nno. of match found=%d",nf);
printf("\ntotal number of character%d\n",noc);
}
void updateblank(FILE *ft, int len)
{
char ch;
int noc=0;
while(1)
{
ch=getc(ft);
if(ch==EOF)
break;
noc++;
}
char rch[noc];
fseek(ft,-(noc),SEEK_CUR);
for(int i=0;i<noc;i++)
{
rch[i]= getc(ft);
}
fseek(ft,-(noc),SEEK_CUR);
for(int i=0;i<len;i++)
{
fputc('\0',ft);
}
for(int i=0;i<noc;i++)
{
fputc(rch[i],ft);
}
fseek(ft,-(noc+len),SEEK_CUR);
}
Thursday, August 6, 2009
find and replace particular string from outside of the file
input:
1.open a .txt file .
2. type something with "hello" word.
3.close the file.
4.copy their file path.
5.paste it in fopen line.
6.replaceable word is "hi"..note: if you change this word .you should alter the for loop condition.
7.run this program with conio.h file function like clrscr();getch(); to the appropriate place.
//find and replace string from outside of the file.
#include"stdio.h"
void main(void)
{
FILE *ft;
char k,ch,replace[3],find[6];
find="hello";
replace="hi";
k=' ';
int i=1,noc=0;
ft=fopen("C:\\KARTHI\\tc\\tmp\\record.txt","r+");
if(ft==NULL)
{
puts("cannot open file\n");
exit(-1);
}else
puts("file is available\n");
while(1)
{
ch=getc(ft);
if(ch==EOF)
break;
else if(ch==find[0])
{
for(i=1;i<=4;i++)
{
if(find[i]!=getc(ft))
{
fseek(ft,-i,SEEK_CUR); goto flag;
}
}
fseek(ft,-(i),SEEK_CUR);
for(i=0;i<=1;i++)
fputc(replace[i],ft);
for(i=2;i<=4;i++) fputc(k,ft);
}
flag:noc++;
}
printf("%s",find);
fclose(ft);
printf("\ntotal number of character%d\n",noc);
}
output: 1.after run this program;
2.open that .txt file. if file exit any "hello" string, then that will replaced as "hi ".
3.Otherwise no change in the contents.
1.open a .txt file .
2. type something with "hello" word.
3.close the file.
4.copy their file path.
5.paste it in fopen line.
6.replaceable word is "hi"..note: if you change this word .you should alter the for loop condition.
7.run this program with conio.h file function like clrscr();getch(); to the appropriate place.
//find and replace string from outside of the file.
#include"stdio.h"
void main(void)
{
FILE *ft;
char k,ch,replace[3],find[6];
find="hello";
replace="hi";
k=' ';
int i=1,noc=0;
ft=fopen("C:\\KARTHI\\tc\\tmp\\record.txt","r+");
if(ft==NULL)
{
puts("cannot open file\n");
exit(-1);
}else
puts("file is available\n");
while(1)
{
ch=getc(ft);
if(ch==EOF)
break;
else if(ch==find[0])
{
for(i=1;i<=4;i++)
{
if(find[i]!=getc(ft))
{
fseek(ft,-i,SEEK_CUR); goto flag;
}
}
fseek(ft,-(i),SEEK_CUR);
for(i=0;i<=1;i++)
fputc(replace[i],ft);
for(i=2;i<=4;i++) fputc(k,ft);
}
flag:noc++;
}
printf("%s",find);
fclose(ft);
printf("\ntotal number of character%d\n",noc);
}
output: 1.after run this program;
2.open that .txt file. if file exit any "hello" string, then that will replaced as "hi ".
3.Otherwise no change in the contents.
Tuesday, August 4, 2009
swapping without third variable and single line
main()
{
int a=15,b=5;
clrscr();
a=(a+b)-(b=(a+b)-b);
printf("a=%d b= %d",a,b);
getch();
}
output: a=5 b=10
{
int a=15,b=5;
clrscr();
a=(a+b)-(b=(a+b)-b);
printf("a=%d b= %d",a,b);
getch();
}
output: a=5 b=10
Monday, August 3, 2009
pointers variable types
#include
main()
{
int j=10,*ptr1;
void *ptr2;
ptr1=&j;ptr2=&j;
printf("%d %d ",*ptr1,ptr2);
getch();
}
output:
10 and some memory address..
note:we can not print the value of "ptr2"....it is not a allowed function type.
main()
{
int j=10,*ptr1;
void *ptr2;
ptr1=&j;ptr2=&j;
printf("%d %d ",*ptr1,ptr2);
getch();
}
output:
10 and some memory address..
note:we can not print the value of "ptr2"....it is not a allowed function type.
Find and replace program
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char nam[50][50],sea[50];
int i,k=0,j,n;
int f=1;
char nam1[50];
clrscr();
printf("ENTER THE NO. OF NAMES\n");
scanf("%d",&n);
printf("ENTER THE NAME\n");
for(i=1;i<=n;i++)
{
scanf("%s",nam[i]);
}
/*internal*/
printf("memory\n");
for(i=1;i<=n;i++)
puts(nam[i]);
printf("\nENTER NAME TO BE replace\n\t\t");
scanf("%s",sea);
printf("........searching .....\n\t");
j=1;
while(j<=n)
{
if(strcmp(nam[j],sea)==0)
{
printf("\n\n\n===========found==============\n\n\n\n\n");
/*replacing */
printf("ENTER THE NAME WANT TO BE insert\n\t\n");
scanf("%s",nam1);
strcpy(nam[j],nam1);
f=0;
j=j+n;
}
else
j++;
}
if(!f)
{
printf("-----------------------------\n\n\n");
printf("displaying names\n\n\n\n");
for(k=1;k<=n;k++)
{ printf("no %d \t is ",k); puts(nam[k]);
}
}
else
{
printf("not found") ;
}
getch();
}
#include<conio.h>
#include<string.h>
void main()
{
char nam[50][50],sea[50];
int i,k=0,j,n;
int f=1;
char nam1[50];
clrscr();
printf("ENTER THE NO. OF NAMES\n");
scanf("%d",&n);
printf("ENTER THE NAME\n");
for(i=1;i<=n;i++)
{
scanf("%s",nam[i]);
}
/*internal*/
printf("memory\n");
for(i=1;i<=n;i++)
puts(nam[i]);
printf("\nENTER NAME TO BE replace\n\t\t");
scanf("%s",sea);
printf("........searching .....\n\t");
j=1;
while(j<=n)
{
if(strcmp(nam[j],sea)==0)
{
printf("\n\n\n===========found==============\n\n\n\n\n");
/*replacing */
printf("ENTER THE NAME WANT TO BE insert\n\t\n");
scanf("%s",nam1);
strcpy(nam[j],nam1);
f=0;
j=j+n;
}
else
j++;
}
if(!f)
{
printf("-----------------------------\n\n\n");
printf("displaying names\n\n\n\n");
for(k=1;k<=n;k++)
{ printf("no %d \t is ",k); puts(nam[k]);
}
}
else
{
printf("not found") ;
}
getch();
}
output:
ENTER THE NO. OF NAME
2
ENTER THE NAME
KARTHI
KARTHIKEYAN
memory
KARTHI
KARTHIKEYAN
ENTER THE NAME WANT TO BE replace
KARTHI
...............searching...............
==========found=========
ENTER THE NAME WANT TO BE insert
..........................................
displaying names
NO 1 IS KARTHIKEN07@GMAIL.COM
NO 2 IS KARTHIKEYAN
Subscribe to:
Posts (Atom)