A program to convert from celcius
to ferenheit
main()
{
float farenheit;
float
celcius;
printf("Enter Celcious value........... ");
scanf("%f",&celcius);
farenheit =
32 + celcius * 9 / 5 ;
printf("\n\n %.2f Degree Celcius in
Farenheit is.........%.2f
farenheit",celcius,farenheit);
getch();
}
Try to do ferenheit to celcius by your own
A program to find the prime
numbers between 1 to 100
main()
{
int i,j;
int s;
for(i
=1;i<=100;i++)
{
s=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
s=s+1;
}
if(s==2)
{
printf("%d\n",i);
}
}
getch();
}
A program to check a given number
is prime or not
main()
{
int i,num;
printf("Enter a number \n");
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i == 0)
{
printf(" This Is Not A Primt Number ");
break;
}
}
if(i==num)
{
printf(" This Is a Prime
Number ");
}
getch();
}
A program to display odd and even
number between 1 to 100
main()
{
int i;
for(i=1;i<=100;i++)
{
if(i%2 == 0)
{
printf("Even Number %d\n",i);
}
else
{
printf("Odd Number %d\n",i);
}
}
getch();
}
A program to find a given number
is even or odd
main()
{
int num;
printf("Enter a number \n");
scanf("%d",&num);
if(num % 2 == 0)
{
printf("Even Number");
}
else
printf("Odd Number");
getch();
}
A program to print febonacci
series upto 20
main()
{
int a = 0;
int b = 1;
int i,sum;
for(i =
0;i<20;i++)
{
sum =
a+b;
printf("%d\n",sum);
a=b;
b=sum;
}
getch();
}
A program to find the biggest number from three numbers
#include<stdio.h>
main()
{
//enter three different values
int a,b,c;
printf("Enter 1st Number\n");
scanf("%d",&a);
printf("Enter 2nd Number\n");
scanf("%d",&b);
printf("Enter 3rd Number\n");
scanf("%d",&c);
if(a > b && a > c )
printf("The Largest Number is %d",a);
if(b > a && b > c )
printf("The Largest Number is %d",b);
if(c > a && c > b)
printf("The Largest Number is %d",c);
getch();
}
A program to find the smallest number from three numbers
#include<stdio.h>
main()
{
//enter three different values
int a,b,c;
printf("Enter 1st Number\n");
scanf("%d",&a);
printf("Enter 2nd Number\n");
scanf("%d",&b);
printf("Enter 3rd Number\n");
scanf("%d",&c);
if(a < b && a < c )
printf("The Lowest Number is %d",a);
if(b < a && b < c )
printf("The Lowest Number is %d",b);
if(c < a && c < b)
printf("The Lowest Number is %d",c);
getch();
}
A program to create random numbers
#include<stdio.h>
#include<stdlib.h>
main()
{
int i;
srand(time(NULL));
for(i=0;i<10;i++)
printf("Random Number %6d \n",rand());
fflush(stdin);
getch();
}
A program to create dice rolling effect
#include<stdio.h>
main()
{
int rolls,number,i;
printf("Enter The Number Of Times You Want To Roll The Dice ");
scanf("%d",&rolls);
srand(time(NULL));
for(i=0;i<rolls;i++)
{
number = rand();
number = number % 6;
number++;
printf("\n Dice Rolled %d Number Is : %d \n",i+1,number);
}
getch();
}
A program to tell the nature of image placed before a lens
A program to tell Horoscope
#include<stdio.h>
#include<conio.h>
main()
{
int select,option;
int c,p,a,ar,t,g,ca,l,v,li,s,sa;
char y;
printf("\n Select your Zoic Sign \n");
printf("\n 1 CAPRICORN");
printf("\n 2 AQUARIUS");
printf("\n 3 PISCES");
printf("\n 4 ARIES");
printf("\n 5 TARUS");
printf("\n 6 GEMINI");
printf("\n 7 CANCER");
printf("\n 8 LEO");
printf("\n 9 VIRGO");
printf("\n 10 LIBRA");
printf("\n 11 SCORPIO ");
printf("\n 12 SAGGITTARIUS \n\n ");
scanf("%d",&select);
switch(select)
{
case 1:
printf("\n\n You Have Selected CAPRICORN \n\n ");
printf("\n Your Date of Birth Lies between 1st December to 20th January \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Money Forms an important partof your life and reaching your full potential is something you worry about\n You have the ability to earn good money throygh life but are sometimes hindered for the lack of opportunity you have\n\n Working in a structured environment is oftenthe best and the most successful way you work\n although partnerships may also bring about success.\n You are prone to suffring from stress related illness like headaches and back pain so don't over do it");
break;
case 2:
printf("\n\n.................................Friends and Companions..........................\n\n");
printf(" You have a amicable personality and therefore a large circle of friends very few you are intimate with\n You are very loyal to choose friends and people ofen see you as a soldier to cry on because of your good nature\n Intimate companions will normally be born under pisces , virgo , scorpio and cancer");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are a very talented , courageous , truthful , individual.\n You have a clear views on things and are at times painfully frank.\n You have a quick temper and because of this often say things you latter regert ");
break;
}
break;
case 2:
printf("\n\n You Have Selected AQUARIUS \n\n ");
printf("\n Your Date of Birth Lies between 21st January to 19th February \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&a);
switch(a)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your impressionable nature means you are often taken advantage of financial situations.\n People often see you soft touch and you must overcome this if you asr to reach the hights of your desire.\n You are quit unlucky in speculative ventures and should avoid gambling\n\n Your love of natural beauty and high degree of energy means that professions in the performing arts , teaching , artistry , medicine and other science would suite you well ");
break;
case 2:
printf("\n\n.................................Friends and Companions.........................\n\n");
printf(" Your appreciation of intellectual beauty through your love of poetry and art means that you enjoy being in the company of intelligent people.\n Although you have many friends who admire you very few are close to you.\n You get on best with people born under libra , gemini and aries ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are energetic , loving and inspirational and are often seen as an attention speaker\n You have a love of natural beauty , ars and mugic.\n You often have a sence of mystic and a fascination with physic abilities ");
break;
}
break;
case 3:
printf("\n\n You Have Selected PIECES \n\n ");
printf("\n Your Date of Birth Lies between 20th Febuary to 20th Mars \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&p);
switch(p)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your financial situation vill vary greatly during your worling career.\n At other time it will be more difficult.\n Your turbulent relationship with money means that it is important for you to put money away for harden times ahed.\n You are hard working although your pessimstic nature means you tend to worry too much ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Your ability to communicate well with people means you will always have a large group of friends\n However people find you rather hard to understand because of your dual personalities. ");
break;
case 3:
printf("\n\n....................................Personality..................................\n\n");
printf(" You are generous and loyal to friends and kind hearted.\n At times you appear to have dual personality as you can be two totally different individuals.\n Overall you tend to have a pessimistic attitude towards things which you need to fight.\n You posse's good communication skills and have good foresight. ");
break;
}
break;
case 4:
printf("\n\n You Have Selected ARIES \n\n ");
printf("\n Your Date of Birth Lies between 21st Mars to 20th April \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&ar);
switch(ar)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Inclined to be impulsive which you need to come to terms with to succeed.\n You have the ability to attain fincial independence if you do not spread your efforts too much.\n If you can learn to coordinate your mind and body success will be assured.\n You are practical and always tyr to improve the ways you do things ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will have large group of friends and admirers and will go to extremes to defend friends you fell are unjustly threatened.\n You have an ability to make friends very easy and are excellent social mixer because of your entertainning personality ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" Determined , industrious and practical minded.\n You tend to be blunt and plain spoken with a high degree of eloquence.\n You are inclined to be impatient and regard your opinions and judgement to be as good as others ");
break;
}
break;
case 5:
printf("\n\n You Have Selected TARUS \n\n ");
printf("\n Your Date of Birth Lies between 21st April to 21st May \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&t);
switch(t)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Although mney will never be a problem for you throughout life , it does tend to burn a hole in your pocket.\n You need to control your spending if you want to complete fincial stability in later life.\n Your determination and ambitious nature means you are a hard working and diligent employee .\n You will have successful career and are capable of achieving greats hights ");
break;
case 2:
printf("\n\n....................................Friends and Companions.......................\n\n");
printf(" Through your personality traits you will have many friends who admire your loving and honest nature.\n You enjoy sharing your life with others and have lot of devoted friends. ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have an ambitious and determined nature and are cautions , lovind and honest.\n At time you can be stubborn and people find it hard to change your opinion of things.\n You are often guided by your deep emotions and have a friendly and optimistic character ");
break;
}
break;
case 6:
printf("\n\n You Have Selected GEMINI \n\n ");
printf("\n Your Date of Birth Lies between 22nd May to 21th June \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&g);
switch(g)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your fincial position will alter greatly throughout life.\n At times money will come easy , at other times less so.\n Putting money away for the future is the best strategy for you.\n You open mindeness will serve you well at work where you will adapt well to changing environment and new tasks.\n Your slight nervousness may hinder you so try overcome this ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will be regarded as a soulder to cry on by both close friends and more distance ones.\n Your sensitive nature attracts people to share their worries with you .\n You will have few very close friends who you can turn to ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You often have a nervous temperament but are sensitive , Cautious and versatile.\n You have an innovative nature and an inquisitive mind and enjoy scoring out information on subjects that interest you.\n This means you develop an depth understanding of such topics ");
break;
}
break;
case 7:
printf("\n\n You Have Selected CANCER \n\n ");
printf("\n Your Date of Birth Lies between 22nd June to 23rd July \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&ca);
switch(ca)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your sign displays clear signs of wanting to save money.\n You like to gamble once in a while and are generally a lucky person as long as you follow your instincts and are not influenced by others.\n In your working career you are thorough and methodical-A lateral thinker.\n You like being motivated and can easily become down if you are not encouraged ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Surrounded by a large group of friends you are generally very popular.\n You will feel happy confiding in close friends who always have your best interests at heart. ");
break;
case 3:
printf("\n\n....................................Personality................................\n\n");
printf(" You are extremeley sensitive character with a friendly and loving nature but often be irritable and moody.\n Living in a world of your own you are a bit of daydreamer.\n In your community you are a popular person. ");
break;
}
break;
case 8:
printf("\n\n You Have Selected LEO \n\n ");
printf("\n Your Date of Birth Lies between 24th July to 23rd August \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&l);
switch(l)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your financial affairs will have many ups and downs. It is therefore important that you invest early on life to provide for your future.\n External fincial support will come from close friends and relative at time when you most need it.\n In your working career you have the ability to achieve great successes.\n Your ambitious nature coupled with good problem solving skills make you a valuable addition to any business ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will have a large circle of friends who like your generous and enthusiastic personality.\n People find you slightly hot headed and impatient ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have a ambitious , generous and determined nature .\n You easily looses your temper and become restless.\n Akey strength that you posses is your ability to adapt to almost any situation you are put in ");
break;
}
break;
case 9:
printf("\n\n You Have Selected VIRGO \n\n ");
printf("\n Your Date of Birth Lies between 24th August to 23rd September \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&v);
switch(v)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Fincial success will be achieved through exploiting your artistic abilities .\n Your methodical and intellectual nature means that when you find a profession in life that is well suited to you ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Your strong desire to succeed means that you appreciate the finer things in life , This in turn influnce the social circle you move in.\n You choose your friends very carefully and generally they are of a similar nature to you ");
break;
case 3:
printf("\n\n....................................Personality..................................\n\n");
printf(" You often have a nervous temperament, but are sensitive , cautious and versatile.\n You have an innovative nature and an inquisitive mind and sourcing out information on subjects that interest you ");
break;
}
break;
case 10:
printf("\n\n You Have Selected LIBRA \n\n ");
printf("\n Your Date of Birth Lies between 24th September to 23rd Octobor \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&li);
switch(li)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" If you can fulfil your full potential you have the ability of achieve a high level of wealth.\n Money does tend to burn a hole in your pocket through.\n Wise investments early in your life will assure you of a secure future.\n You will have a successful carrer through your way of work. ");
break;
case 2:
printf("\n\n...................................Friends and Companions.......................\n\n");
printf(" You choose your closest friends carefully although they are often of a totally different nature to you.\n You enjoy spending time alone . ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are a well balanced individual.\n You are loving , selfish and idealistic .\n You have a forgiving and sympathetic nature, although you can be slightly hot tempered at times ");
break;
}
break;
case 11:
printf("\n\n You Have Selected SCORPIO \n\n ");
printf("\n Your Date of Birth Lies between 24th Octobor to 22nd November \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&s);
switch(s)
{
case 1:
printf("\n\n...................................Work and Finance.............................\n\n");
printf(" Although you will not fulfil your full capabilities until later life, you will set a steady growth in fincial status as your career progresses.\n Your good sence of humour and laid back approch to life will mean that you are able to take on anything that falls in your path ");
break;
case 2:
printf("\n\n...................................Friends and Companions.......................\n\n");
printf(" People enjoy your company but dislike the way you try to dominate all situations.\n You enjoy spending time with those who have a similar sense of humour to you and share your laid back approach on life ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have a generous , sympathetic and determined nature.\n You are well liked by friends and colleagues because of your sence of humour ");
break;
}
break;
case 12:
printf("\n\n You Have Selected SAGITTARIUS \n\n ");
printf("\n Your Date of Birth Lies between 23rd November to 21th December \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&sa);
switch(sa)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" You are extreamely resourceful. You like to work on your own ideas.\n Your fincial status will grow with your experience . You are a bit impulsive in your work ");
break;
case 2:
printf("\n\n....................................Friends and Companions.......................\n\n");
printf(" You do not have a large circle of friends.\n People often regards you as a workaholic and become jealous of your success in later life ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" Your overall outlook on life is very positive and you have a high degree of intelligence.\n You are happy to share all that you own with those around you.\n You are slightly hot tempered and are easily upset ");
break;
}
break;
default:
printf("................................Invalid Parametre............................... ");
}
getch();
}
A program to find the biggest number from three numbers
#include<stdio.h>
main()
{
//enter three different values
int a,b,c;
printf("Enter 1st Number\n");
scanf("%d",&a);
printf("Enter 2nd Number\n");
scanf("%d",&b);
printf("Enter 3rd Number\n");
scanf("%d",&c);
if(a > b && a > c )
printf("The Largest Number is %d",a);
if(b > a && b > c )
printf("The Largest Number is %d",b);
if(c > a && c > b)
printf("The Largest Number is %d",c);
getch();
}
A program to find the smallest number from three numbers
#include<stdio.h>
main()
{
//enter three different values
int a,b,c;
printf("Enter 1st Number\n");
scanf("%d",&a);
printf("Enter 2nd Number\n");
scanf("%d",&b);
printf("Enter 3rd Number\n");
scanf("%d",&c);
if(a < b && a < c )
printf("The Lowest Number is %d",a);
if(b < a && b < c )
printf("The Lowest Number is %d",b);
if(c < a && c < b)
printf("The Lowest Number is %d",c);
getch();
}
A program to create random numbers
#include<stdio.h>
#include<stdlib.h>
main()
{
int i;
srand(time(NULL));
for(i=0;i<10;i++)
printf("Random Number %6d \n",rand());
fflush(stdin);
getch();
}
A program to create dice rolling effect
#include<stdio.h>
main()
{
int rolls,number,i;
printf("Enter The Number Of Times You Want To Roll The Dice ");
scanf("%d",&rolls);
srand(time(NULL));
for(i=0;i<rolls;i++)
{
number = rand();
number = number % 6;
number++;
printf("\n Dice Rolled %d Number Is : %d \n",i+1,number);
}
getch();
}
A program to find rate of interest
#include<stdio.h>
main()
{
int year,period;
float amount,interest_rate,value;
printf("Enter Amount \n");
scanf("%f",&amount);
printf("Enter Interest Rate \n");
scanf("%f",&interest_rate);
printf("Enter Period \n");
scanf("%d",&period);
year = 1;
printf("\n\n");
while(year <= period)
{
value = amount + interest_rate * amount;
printf("%2d Price %8.2f\n",year,value);
amount = value;
year = year + 1;
}
getch();
}
main()
{
int year,period;
float amount,interest_rate,value;
printf("Enter Amount \n");
scanf("%f",&amount);
printf("Enter Interest Rate \n");
scanf("%f",&interest_rate);
printf("Enter Period \n");
scanf("%d",&period);
year = 1;
printf("\n\n");
while(year <= period)
{
value = amount + interest_rate * amount;
printf("%2d Price %8.2f\n",year,value);
amount = value;
year = year + 1;
}
getch();
}
A program to print multiplication table from 1 to 10
main()
{
int i,j;
int array[10][10];
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
array[i][j] = (i+1)*(j+1);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
printf("%3d ",array[i][j]);
}
printf("\n");
}
getch();
}
{
int i,j;
int array[10][10];
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
array[i][j] = (i+1)*(j+1);
}
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
printf("%3d ",array[i][j]);
}
printf("\n");
}
getch();
}
A program to find average of 5 subjects
#include<stdio.h>
main()
{
int sub1,sub2,sub3,sub4,sub5;
int sum;
float avg;
printf("Enter Subject 1 Marks\n");
scanf("%d",&sub1);
printf("Enter Subject 2 Marks\n");
scanf("%d",&sub2);
printf("Enter Subject 3 Marks\n");
scanf("%d",&sub3);
printf("Enter Subject 4 Marks\n");
scanf("%d",&sub4);
printf("Enter Subject 5 Marks\n");
scanf("%d",&sub5);
sum = sub1+sub2+sub3+sub4+sub5;
avg = (float)sum/5;
printf("Average of The Subjects is %.2f ",avg);
getch();
}
main()
{
int sub1,sub2,sub3,sub4,sub5;
int sum;
float avg;
printf("Enter Subject 1 Marks\n");
scanf("%d",&sub1);
printf("Enter Subject 2 Marks\n");
scanf("%d",&sub2);
printf("Enter Subject 3 Marks\n");
scanf("%d",&sub3);
printf("Enter Subject 4 Marks\n");
scanf("%d",&sub4);
printf("Enter Subject 5 Marks\n");
scanf("%d",&sub5);
sum = sub1+sub2+sub3+sub4+sub5;
avg = (float)sum/5;
printf("Average of The Subjects is %.2f ",avg);
getch();
}
A program to find maximum
#include<stdio.h>
main()
{
int n,i,max;
printf("Enter Total Numbers Of Numbers In The Array\n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d Number \n",i+1);
scanf("%d",&array[i]);
}
max = array[0];
for(i=0;i<n;i++)
{
if(array[i] > max)
max = array[i];
}
printf("The Largest Number in the array is %d ",max);
getch();
}
main()
{
int n,i,max;
printf("Enter Total Numbers Of Numbers In The Array\n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d Number \n",i+1);
scanf("%d",&array[i]);
}
max = array[0];
for(i=0;i<n;i++)
{
if(array[i] > max)
max = array[i];
}
printf("The Largest Number in the array is %d ",max);
getch();
}
A program To find minimum
#include<stdio.h>
main()
{
int n,i,min;
printf("Enter Total Numbers Of Numbers In The Array\n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d Number \n",i+1);
scanf("%d",&array[i]);
}
min = array[0];
for(i=0;i<n;i++)
{
if(array[i] < min)
min = array[i];
}
printf("The Smallest Number in the array is %d ",min
);
getch();
}
main()
{
int n,i,min;
printf("Enter Total Numbers Of Numbers In The Array\n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d Number \n",i+1);
scanf("%d",&array[i]);
}
min = array[0];
for(i=0;i<n;i++)
{
if(array[i] < min)
min = array[i];
}
printf("The Smallest Number in the array is %d ",min
);
getch();
}
A program to find average of n numbers
#include<stdio.h>
main()
{
int n,i;
int sum;
float avg;
printf("Enter Total Number of the array \n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d number \n",i+1);
scanf("%d",&array[i]);
sum = sum + array[i];
}
avg = (float)sum/n;
printf("Average Of The Numbers Are %.2f ",avg);
getch();
}
main()
{
int n,i;
int sum;
float avg;
printf("Enter Total Number of the array \n");
scanf("%d",&n);
int array[n];
for(i=0;i<n;i++)
{
printf("Enter %d number \n",i+1);
scanf("%d",&array[i]);
sum = sum + array[i];
}
avg = (float)sum/n;
printf("Average Of The Numbers Are %.2f ",avg);
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
float radius,focus,o_distance,i_distance,infinity,beyond_curvature,magni;
char conti,y,n;
printf(" PROGRAM TO FIND THE NATURE OF IMAGE OF A CONCAVE MIRROR ");
printf(" \n\n\n\n # . ");
printf(" \n # Concave Mirror . . . ");
printf(" \n # . ");
printf(" \n # . Positive ");
printf(" \n # ");
printf(" \n Focus # ");
printf(" \n ..C.........F.......... O......................... ");
printf(" \n # pole . ");
printf(" \n Radius of Curvature # . Negitive ");
printf(" \n # . . . ");
printf(" \n Negative # Positive . ");
printf(" \n . # . ");
printf(" \n ........... # ........... ");
printf(" \n . . ");
printf("\n\n\n\n Enter radius of Curvature(in CM) ------- ");
scanf("%f",&radius);
focus=radius/2;
printf("\n\n Focal Length will be at(in CM) -----( -ve ) %f",focus);
printf("\n Centre of Curvature will be at(in CM)-----( -ve )%f",radius);
infinity=3*radius;
beyond_curvature=2*radius;
do
{
printf("\n Enter the Distance of the object fron the Mirror(in CM) ------");
scanf("%f",&o_distance);
i_distance=(1/-focus+1/o_distance)*100;
if(o_distance>=infinity)
{
printf("\n\n Position of the object....................infinity ");
printf("\n\n Image will be formed at Focus (in CM)-----");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Diminished");
}
else if(o_distance>beyond_curvature)
{
printf("\n\n Position of the object....................Beyond Centre of Curvature ");
printf("\n\n Image will be formed between center of curvature and focus(in CM)------");
printf("\n\n Nature--------\n\n Real\n\n Inverted \n\n Diminished");
}
else if(o_distance==radius)
{
printf("\n\n Position of the object....................at centre of curvature ");
printf("\n\n Image will be formed at centre of curvature(in CM).........");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Same size");
}
else if(o_distance>focus)
{
printf("\n\n Position of the object....................Between centre of curvature and focus ");
printf("\n\n Image will be formed at Beyond center of curvature ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Magnified ");
}
else if(o_distance==focus)
{
printf("\n\n Position of the object....................at focus ");
printf("\n\n Image will be formed at infinity ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Hypermagnified");
}
else if(o_distance<focus)
{
printf("\n\n Position of the object....................Betweew pole and focus ");
printf("\n\n Image will be formed behind the mirror ");
printf("\n\n Nature--------\n\n Virtual\n\n Erect\n\n Magnified");
}
else
{
}
printf("\n\n\n image distance = %f",i_distance);
if(i_distance<0)
{
printf(" To the LeftHand side of pole ");
}
else
{
printf(" To the RightHand side of pole ");
}
magni=i_distance/o_distance;
printf("\n Magnification is = %f",magni);
printf("\n\n Do you want to change the object position (y/n) ");
scanf("%s",&conti);
}
while(conti=='y');
getch();
}
#include<conio.h>
main()
{
float radius,focus,o_distance,i_distance,infinity,beyond_curvature,magni;
char conti,y,n;
printf(" PROGRAM TO FIND THE NATURE OF IMAGE OF A CONCAVE MIRROR ");
printf(" \n\n\n\n # . ");
printf(" \n # Concave Mirror . . . ");
printf(" \n # . ");
printf(" \n # . Positive ");
printf(" \n # ");
printf(" \n Focus # ");
printf(" \n ..C.........F.......... O......................... ");
printf(" \n # pole . ");
printf(" \n Radius of Curvature # . Negitive ");
printf(" \n # . . . ");
printf(" \n Negative # Positive . ");
printf(" \n . # . ");
printf(" \n ........... # ........... ");
printf(" \n . . ");
printf("\n\n\n\n Enter radius of Curvature(in CM) ------- ");
scanf("%f",&radius);
focus=radius/2;
printf("\n\n Focal Length will be at(in CM) -----( -ve ) %f",focus);
printf("\n Centre of Curvature will be at(in CM)-----( -ve )%f",radius);
infinity=3*radius;
beyond_curvature=2*radius;
do
{
printf("\n Enter the Distance of the object fron the Mirror(in CM) ------");
scanf("%f",&o_distance);
i_distance=(1/-focus+1/o_distance)*100;
if(o_distance>=infinity)
{
printf("\n\n Position of the object....................infinity ");
printf("\n\n Image will be formed at Focus (in CM)-----");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Diminished");
}
else if(o_distance>beyond_curvature)
{
printf("\n\n Position of the object....................Beyond Centre of Curvature ");
printf("\n\n Image will be formed between center of curvature and focus(in CM)------");
printf("\n\n Nature--------\n\n Real\n\n Inverted \n\n Diminished");
}
else if(o_distance==radius)
{
printf("\n\n Position of the object....................at centre of curvature ");
printf("\n\n Image will be formed at centre of curvature(in CM).........");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Same size");
}
else if(o_distance>focus)
{
printf("\n\n Position of the object....................Between centre of curvature and focus ");
printf("\n\n Image will be formed at Beyond center of curvature ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Magnified ");
}
else if(o_distance==focus)
{
printf("\n\n Position of the object....................at focus ");
printf("\n\n Image will be formed at infinity ");
printf("\n\n Nature--------\n\n Real\n\n Inverted\n\n Hypermagnified");
}
else if(o_distance<focus)
{
printf("\n\n Position of the object....................Betweew pole and focus ");
printf("\n\n Image will be formed behind the mirror ");
printf("\n\n Nature--------\n\n Virtual\n\n Erect\n\n Magnified");
}
else
{
}
printf("\n\n\n image distance = %f",i_distance);
if(i_distance<0)
{
printf(" To the LeftHand side of pole ");
}
else
{
printf(" To the RightHand side of pole ");
}
magni=i_distance/o_distance;
printf("\n Magnification is = %f",magni);
printf("\n\n Do you want to change the object position (y/n) ");
scanf("%s",&conti);
}
while(conti=='y');
getch();
}
//feel free to modify the logic according to your need if neede
A program to display the place value of a number (upto Billion Only)
#include<stdio.h>
main()
{
long int digit[10];
char place[30][30] = {"Ones","Tens","Hundreds","Thousands","Ten Thousand","Hundred Thousand","Million","Ten Million","Hundred Million","Billion"};
long int data[10];
/* count number of digits */
int c = 0; /* digit position */
int n ;
int i;
int number;
printf("enter a number\n");
scanf("%d",&n);
number = n;
while (n != 0)
{
n /= 10;
c++;
}
printf("the number of digits int the number is %d\n\n\n",c);
int numberArray[c];
for (i = 0; i < 10; i++) {
numberArray[i] = number%10;
number = number / 10;
}
int j = 10;
digit[0] = 0;
for(i = 1;i<10;i++)
{
digit[i] = j;
j = j * 10;
}
for(i = 0;i<10;i++)
{
printf("%d__________%5s____________%d\n\n",digit[i],place[i],numberArray[i]);
}
getch();
}
A program to display the place value of a number (upto Billion Only)
#include<stdio.h>
main()
{
long int digit[10];
char place[30][30] = {"Ones","Tens","Hundreds","Thousands","Ten Thousand","Hundred Thousand","Million","Ten Million","Hundred Million","Billion"};
long int data[10];
/* count number of digits */
int c = 0; /* digit position */
int n ;
int i;
int number;
printf("enter a number\n");
scanf("%d",&n);
number = n;
while (n != 0)
{
n /= 10;
c++;
}
printf("the number of digits int the number is %d\n\n\n",c);
int numberArray[c];
for (i = 0; i < 10; i++) {
numberArray[i] = number%10;
number = number / 10;
}
int j = 10;
digit[0] = 0;
for(i = 1;i<10;i++)
{
digit[i] = j;
j = j * 10;
}
for(i = 0;i<10;i++)
{
printf("%d__________%5s____________%d\n\n",digit[i],place[i],numberArray[i]);
}
getch();
}
A program to tell Horoscope
#include<stdio.h>
#include<conio.h>
main()
{
int select,option;
int c,p,a,ar,t,g,ca,l,v,li,s,sa;
char y;
printf("\n Select your Zoic Sign \n");
printf("\n 1 CAPRICORN");
printf("\n 2 AQUARIUS");
printf("\n 3 PISCES");
printf("\n 4 ARIES");
printf("\n 5 TARUS");
printf("\n 6 GEMINI");
printf("\n 7 CANCER");
printf("\n 8 LEO");
printf("\n 9 VIRGO");
printf("\n 10 LIBRA");
printf("\n 11 SCORPIO ");
printf("\n 12 SAGGITTARIUS \n\n ");
scanf("%d",&select);
switch(select)
{
case 1:
printf("\n\n You Have Selected CAPRICORN \n\n ");
printf("\n Your Date of Birth Lies between 1st December to 20th January \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Money Forms an important partof your life and reaching your full potential is something you worry about\n You have the ability to earn good money throygh life but are sometimes hindered for the lack of opportunity you have\n\n Working in a structured environment is oftenthe best and the most successful way you work\n although partnerships may also bring about success.\n You are prone to suffring from stress related illness like headaches and back pain so don't over do it");
break;
case 2:
printf("\n\n.................................Friends and Companions..........................\n\n");
printf(" You have a amicable personality and therefore a large circle of friends very few you are intimate with\n You are very loyal to choose friends and people ofen see you as a soldier to cry on because of your good nature\n Intimate companions will normally be born under pisces , virgo , scorpio and cancer");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are a very talented , courageous , truthful , individual.\n You have a clear views on things and are at times painfully frank.\n You have a quick temper and because of this often say things you latter regert ");
break;
}
break;
case 2:
printf("\n\n You Have Selected AQUARIUS \n\n ");
printf("\n Your Date of Birth Lies between 21st January to 19th February \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&a);
switch(a)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your impressionable nature means you are often taken advantage of financial situations.\n People often see you soft touch and you must overcome this if you asr to reach the hights of your desire.\n You are quit unlucky in speculative ventures and should avoid gambling\n\n Your love of natural beauty and high degree of energy means that professions in the performing arts , teaching , artistry , medicine and other science would suite you well ");
break;
case 2:
printf("\n\n.................................Friends and Companions.........................\n\n");
printf(" Your appreciation of intellectual beauty through your love of poetry and art means that you enjoy being in the company of intelligent people.\n Although you have many friends who admire you very few are close to you.\n You get on best with people born under libra , gemini and aries ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are energetic , loving and inspirational and are often seen as an attention speaker\n You have a love of natural beauty , ars and mugic.\n You often have a sence of mystic and a fascination with physic abilities ");
break;
}
break;
case 3:
printf("\n\n You Have Selected PIECES \n\n ");
printf("\n Your Date of Birth Lies between 20th Febuary to 20th Mars \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&p);
switch(p)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your financial situation vill vary greatly during your worling career.\n At other time it will be more difficult.\n Your turbulent relationship with money means that it is important for you to put money away for harden times ahed.\n You are hard working although your pessimstic nature means you tend to worry too much ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Your ability to communicate well with people means you will always have a large group of friends\n However people find you rather hard to understand because of your dual personalities. ");
break;
case 3:
printf("\n\n....................................Personality..................................\n\n");
printf(" You are generous and loyal to friends and kind hearted.\n At times you appear to have dual personality as you can be two totally different individuals.\n Overall you tend to have a pessimistic attitude towards things which you need to fight.\n You posse's good communication skills and have good foresight. ");
break;
}
break;
case 4:
printf("\n\n You Have Selected ARIES \n\n ");
printf("\n Your Date of Birth Lies between 21st Mars to 20th April \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&ar);
switch(ar)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Inclined to be impulsive which you need to come to terms with to succeed.\n You have the ability to attain fincial independence if you do not spread your efforts too much.\n If you can learn to coordinate your mind and body success will be assured.\n You are practical and always tyr to improve the ways you do things ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will have large group of friends and admirers and will go to extremes to defend friends you fell are unjustly threatened.\n You have an ability to make friends very easy and are excellent social mixer because of your entertainning personality ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" Determined , industrious and practical minded.\n You tend to be blunt and plain spoken with a high degree of eloquence.\n You are inclined to be impatient and regard your opinions and judgement to be as good as others ");
break;
}
break;
case 5:
printf("\n\n You Have Selected TARUS \n\n ");
printf("\n Your Date of Birth Lies between 21st April to 21st May \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&t);
switch(t)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Although mney will never be a problem for you throughout life , it does tend to burn a hole in your pocket.\n You need to control your spending if you want to complete fincial stability in later life.\n Your determination and ambitious nature means you are a hard working and diligent employee .\n You will have successful career and are capable of achieving greats hights ");
break;
case 2:
printf("\n\n....................................Friends and Companions.......................\n\n");
printf(" Through your personality traits you will have many friends who admire your loving and honest nature.\n You enjoy sharing your life with others and have lot of devoted friends. ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have an ambitious and determined nature and are cautions , lovind and honest.\n At time you can be stubborn and people find it hard to change your opinion of things.\n You are often guided by your deep emotions and have a friendly and optimistic character ");
break;
}
break;
case 6:
printf("\n\n You Have Selected GEMINI \n\n ");
printf("\n Your Date of Birth Lies between 22nd May to 21th June \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&g);
switch(g)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your fincial position will alter greatly throughout life.\n At times money will come easy , at other times less so.\n Putting money away for the future is the best strategy for you.\n You open mindeness will serve you well at work where you will adapt well to changing environment and new tasks.\n Your slight nervousness may hinder you so try overcome this ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will be regarded as a soulder to cry on by both close friends and more distance ones.\n Your sensitive nature attracts people to share their worries with you .\n You will have few very close friends who you can turn to ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You often have a nervous temperament but are sensitive , Cautious and versatile.\n You have an innovative nature and an inquisitive mind and enjoy scoring out information on subjects that interest you.\n This means you develop an depth understanding of such topics ");
break;
}
break;
case 7:
printf("\n\n You Have Selected CANCER \n\n ");
printf("\n Your Date of Birth Lies between 22nd June to 23rd July \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&ca);
switch(ca)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your sign displays clear signs of wanting to save money.\n You like to gamble once in a while and are generally a lucky person as long as you follow your instincts and are not influenced by others.\n In your working career you are thorough and methodical-A lateral thinker.\n You like being motivated and can easily become down if you are not encouraged ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Surrounded by a large group of friends you are generally very popular.\n You will feel happy confiding in close friends who always have your best interests at heart. ");
break;
case 3:
printf("\n\n....................................Personality................................\n\n");
printf(" You are extremeley sensitive character with a friendly and loving nature but often be irritable and moody.\n Living in a world of your own you are a bit of daydreamer.\n In your community you are a popular person. ");
break;
}
break;
case 8:
printf("\n\n You Have Selected LEO \n\n ");
printf("\n Your Date of Birth Lies between 24th July to 23rd August \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&l);
switch(l)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Your financial affairs will have many ups and downs. It is therefore important that you invest early on life to provide for your future.\n External fincial support will come from close friends and relative at time when you most need it.\n In your working career you have the ability to achieve great successes.\n Your ambitious nature coupled with good problem solving skills make you a valuable addition to any business ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" You will have a large circle of friends who like your generous and enthusiastic personality.\n People find you slightly hot headed and impatient ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have a ambitious , generous and determined nature .\n You easily looses your temper and become restless.\n Akey strength that you posses is your ability to adapt to almost any situation you are put in ");
break;
}
break;
case 9:
printf("\n\n You Have Selected VIRGO \n\n ");
printf("\n Your Date of Birth Lies between 24th August to 23rd September \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&v);
switch(v)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" Fincial success will be achieved through exploiting your artistic abilities .\n Your methodical and intellectual nature means that when you find a profession in life that is well suited to you ");
break;
case 2:
printf("\n\n..................................Friends and Companions........................\n\n");
printf(" Your strong desire to succeed means that you appreciate the finer things in life , This in turn influnce the social circle you move in.\n You choose your friends very carefully and generally they are of a similar nature to you ");
break;
case 3:
printf("\n\n....................................Personality..................................\n\n");
printf(" You often have a nervous temperament, but are sensitive , cautious and versatile.\n You have an innovative nature and an inquisitive mind and sourcing out information on subjects that interest you ");
break;
}
break;
case 10:
printf("\n\n You Have Selected LIBRA \n\n ");
printf("\n Your Date of Birth Lies between 24th September to 23rd Octobor \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&li);
switch(li)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" If you can fulfil your full potential you have the ability of achieve a high level of wealth.\n Money does tend to burn a hole in your pocket through.\n Wise investments early in your life will assure you of a secure future.\n You will have a successful carrer through your way of work. ");
break;
case 2:
printf("\n\n...................................Friends and Companions.......................\n\n");
printf(" You choose your closest friends carefully although they are often of a totally different nature to you.\n You enjoy spending time alone . ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You are a well balanced individual.\n You are loving , selfish and idealistic .\n You have a forgiving and sympathetic nature, although you can be slightly hot tempered at times ");
break;
}
break;
case 11:
printf("\n\n You Have Selected SCORPIO \n\n ");
printf("\n Your Date of Birth Lies between 24th Octobor to 22nd November \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&s);
switch(s)
{
case 1:
printf("\n\n...................................Work and Finance.............................\n\n");
printf(" Although you will not fulfil your full capabilities until later life, you will set a steady growth in fincial status as your career progresses.\n Your good sence of humour and laid back approch to life will mean that you are able to take on anything that falls in your path ");
break;
case 2:
printf("\n\n...................................Friends and Companions.......................\n\n");
printf(" People enjoy your company but dislike the way you try to dominate all situations.\n You enjoy spending time with those who have a similar sense of humour to you and share your laid back approach on life ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" You have a generous , sympathetic and determined nature.\n You are well liked by friends and colleagues because of your sence of humour ");
break;
}
break;
case 12:
printf("\n\n You Have Selected SAGITTARIUS \n\n ");
printf("\n Your Date of Birth Lies between 23rd November to 21th December \n ");
printf("\n Choose a Catagory\n");
printf("\n 1 Work and Finance \n");
printf("\n 2 Friends and Companions \n");
printf("\n 3 Personality \n ");
scanf("%d",&sa);
switch(sa)
{
case 1:
printf("\n\n....................................Work and Finance............................\n\n");
printf(" You are extreamely resourceful. You like to work on your own ideas.\n Your fincial status will grow with your experience . You are a bit impulsive in your work ");
break;
case 2:
printf("\n\n....................................Friends and Companions.......................\n\n");
printf(" You do not have a large circle of friends.\n People often regards you as a workaholic and become jealous of your success in later life ");
break;
case 3:
printf("\n\n....................................Personality.................................\n\n");
printf(" Your overall outlook on life is very positive and you have a high degree of intelligence.\n You are happy to share all that you own with those around you.\n You are slightly hot tempered and are easily upset ");
break;
}
break;
default:
printf("................................Invalid Parametre............................... ");
}
getch();
}
Very informative and well written post! Quite interesting and nice topic chosen for the post.
ReplyDeleteHP - EliteBook Folio Ultrabook 14" Laptop - 4GB Memory - 500GB Hard Drive - Platinum