Posts

Showing posts from August 30, 2012

program to find the type of triangle as inputted by the user

Image
#include<stdio.h>
#include<conio.h>
void main()
{
long int a,b,c;
clrscr();
printf("enter sides of triangle\n");
scanf("%ld%ld%ld",&a,&b,&c);
if(a+b>c||b+c>a||c+a>b)
{
  if(a==b&&b==c)
  printf("equilateral triangle\n");
  if(a==b||b==c||c==a)
  printf("isoceles triangle\n");
  else
  printf("scalene triangle\n");
  }
  else
  printf(" wrong input");
 printf("thank you for using the program\n");
getch();
}

SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLETEMPERATURE CONVERSIONCOMMISSION OF A SALESMANPRINT NUMBERS IN DESCENDING ORDERBIGGEST NUMBER AMONG THREE NUMBERSCALCULATE DIVISIONA YEAR IS LEAP OR NOTA NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTEREDDATA STRUCTURES ENTER DETAILS OF A STUDENTENTER DETAILS OF A STUDENT USING STRUCTURE WITHIN A…

program to convert temperature (menu-driven)

Image
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int temp=0,choice=1,i=1;
float result=0;
clrscr();
do
{

switch(i)
{
case 1:
{
printf("enter 1 for converting fahrenheit to celsius \n");
printf("enter 2 for converting celsius to fahrenheit \n");

printf("enter choice\n");
scanf("%d",&choice);
printf("enter temperature\n");
scanf("%d",&temp);
switch(choice)
{
case 1:result=(temp-32)*5/9;
break;
case 2:result=1.8*temp+32;
break;

default:printf("wrong input\n");
break;
}
if(choice>0&&choice<3)
printf("%f\n",result);
break;
}
}
printf(" enter 1 for re using temperature convertor\n");
printf(" enter other number for exit\n");
scanf("%ld",&i);
}while(i==1);
 printf("thank you\n");
getch();
}

SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLETEMPERATURE CONVERSIONCOMMISSION OF A SALESMANPRINT NUMBERS IN DESCENDING ORDER

program to input ano. and print the weekday matching with the number(menu-driven)

Image
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int i=1,a,b,c=0,choice=1;
clrscr();
do
{

switch(i)
{
case 1:
{
printf("enter 1 for sunday\n");
printf("enter 2 for monday\n");
printf("enter 3 for tueday\n");
printf("enter 4 for wednesday\n");
printf("enter 5 for thursday\n");
printf("enter 6 for friday\n");
printf("enter 7 for saturday\n");
printf("enter choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:printf(" sunday\n");
break;
case 2:printf(" monday\n");
break;
case 3:printf(" tuesday\n");
break;
case 4:printf(" wednesday\n");
break;
case 5:printf(" thursday\n");
break;
case 6:printf(" friday\n");
break;
case 7:printf(" saturday\n");
break;
default:printf("wrong input\n");
break;
}
if(choice>0&&choice<6)
printf("%ld",c);
break;
}
}
printf…

DIFFERENCE BETWEEN BREAK AND CONTINUE

Image
/*program to see the use of continue statement*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
  clrscr();
printf("DIFFERENCE BETWEEN BREAK AND CONTINUE\n");
printf("PRINTING IN CASE OF CONTINUE\n");
for(i=1;i<=3;i++)
 {
for( j=1;j<=3;j++)
 {
 if(i!=j)
  continue;
  printf("%d %d   ",i,j);
 }
 }
printf(" \n");
printf("PRINTING IN CASE OF BREAK \n");
for(i=1;i<=3;i++)
 {
for( j=1;j<=3;j++)
 {
 if(i!=j)
  break;
printf("%d %d",i,j);
 }
 }


  getch();
}
/* click the below picture to maximize it /*


SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLETEMPERATURE CONVERSIONCOMMISSION OF A SALESMANPRINT NUMBERS IN DESCENDING ORDERBIGGEST NUMBER AMONG THREE NUMBERSCALCULATE DIVISIONA YEAR IS LEAP OR NOTA NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTEREDDATA STRUCTURES EN…