Archive for July 30, 2010


#include <stdio.h>
int main(void)
{
int score;
int grade;
clrscr();
printf(“This program converts your grade to college grade.\n”);
printf(“Please enter grade(0-100):\n”);
scanf(“%i”,&score);
if (score<0)
{
printf(“The value %i is less than zero.”,score);
}
if (score>100)
{
printf(“The value %i is greater than one hundred.”,score);
}
else
{
if (score>=97)
{
if (score<=100)
{
printf(“Your grade is 1.00\n”);
}
}
if (score>=93)
{
if (score<=96)
{
printf(“Your grade is 1.25\n”);
}
}
if (score>=89)
{
if (score<=92)
{
printf(“Your grade is 1.50\n”);
}
}
if (score>=85)
{
if (score<=88)
{
printf(“Your grade is 1.75\n”);
}
}
if (score>=80)
{
if (score<=84)
{
printf(“Your grade is 2.00\n”);
}
}
if (score>=75)
{
if (score<=79)
{
printf(“Your grade is 2.25\n”);
}
}
if (score>=70)
{
if (score<=74)
{
printf(“Your grade is 2.50\n”);
}
}
if (score>=65)
{
if (score<=69)
{
printf(“Your grade is 2.75\n”);
}
}
if (score>=60)
{
if (score<=64)
{
printf(“Your grade is 3.00\n”);
}
}
if (score<60)
{
if (score>=0)
{
printf(“Your grade is 5.00\n”);
}
}
}
getch();
return 0;
}

#include <stdio.h>int main(void){int score;int grade;
clrscr();
printf(“This program converts your grade to college grade.\n”);printf(“Please enter grade(0-100):\n”);scanf(“%i”,&score);
if (score<0)     {     printf(“The value %i is less than zero.”,score);     }
if (score>100)     {     printf(“The value %i is greater than one hundred.”,score);     }
else     {     if (score>=97)      {      if (score<=100)           {           printf(“Your grade is 1.00\n”);           }      }
if (score>=93)      {      if (score<=96)           {           printf(“Your grade is 1.25\n”);           }      }     if (score>=89)      {      if (score<=92)           {           printf(“Your grade is 1.50\n”);           }      }     if (score>=85)      {      if (score<=88)           {           printf(“Your grade is 1.75\n”);           }      }     if (score>=80)      {      if (score<=84)           {           printf(“Your grade is 2.00\n”);           }      }     if (score>=75)      {      if (score<=79)           {           printf(“Your grade is 2.25\n”);           }      }     if (score>=70)      {      if (score<=74)           {           printf(“Your grade is 2.50\n”);           }      }     if (score>=65)      {      if (score<=69)           {           printf(“Your grade is 2.75\n”);           }      }     if (score>=60)      {      if (score<=64)           {           printf(“Your grade is 3.00\n”);           }
}     if (score<60)  {  if (score>=0)    {     printf(“Your grade is 5.00\n”);    }  }     }
getch();
return 0;
}

#include <stdio.h>
int main(void)
{
int num1,num2,num3;
clrscr();
printf(“This program gets three numbers and displays the least among the three numbers.\n”);
printf(“\n”);
printf(“\tEnter first number : “);
scanf(“%i”,&num1);
printf(“\tEnter second number: “);
scanf(“%i”,&num2);
printf(“\tEnter third number : “);
scanf(“%i”,&num3);
printf(“\n”);
printf(“\n”);
printf(”     The three numbers are %i, %i and %i.”,num1,num2,num3);
printf(“\n”);
printf(“\n”);
if ((num1<num2) && (num1<num3))
{
printf(“\n\t 1The least number is %i.”,num1);
}
if ((num2<num1) && (num2<num3))
{
printf(“\n\t 2The least number is %i.”,num2);
}
if ((num3<num1) && (num3<num2))
{
printf(“\n\t 3The least number is %i.”,num3);
}
if ((num1==num2) && (num1<num3))
{
printf(“\n\t 4The least number is %i.”,num2);
}
if ((num3==num1) && (num3<num2))
{
printf(“\n\t 6The least number is %i.”,num1);
}
if ((num2==num3) && (num2<num1))
{
printf(“\n\t 8The least number is %i.”,num3);
}
if ((num1==num2) && (num2==num3))
{
printf(“\n\t The least number is %i.”,num1);
}
getch();
return 0;
}

#include <stdio.h>
int main(void){
int num1,num2,num3;
clrscr();
printf(“This program gets three numbers and displays the least among the three numbers.\n”);printf(“\n”);printf(“\tEnter first number : “);scanf(“%i”,&num1);
printf(“\tEnter second number: “);scanf(“%i”,&num2);
printf(“\tEnter third number : “);scanf(“%i”,&num3);
printf(“\n”);printf(“\n”);printf(”     The three numbers are %i, %i and %i.”,num1,num2,num3);printf(“\n”);printf(“\n”);
if ((num1<num2) && (num1<num3))     {     printf(“\n\t 1The least number is %i.”,num1);     }if ((num2<num1) && (num2<num3))     {     printf(“\n\t 2The least number is %i.”,num2);     }if ((num3<num1) && (num3<num2))     {     printf(“\n\t 3The least number is %i.”,num3);     }if ((num1==num2) && (num1<num3))     {     printf(“\n\t 4The least number is %i.”,num2);     }if ((num3==num1) && (num3<num2))     {     printf(“\n\t 6The least number is %i.”,num1);     }if ((num2==num3) && (num2<num1))     {     printf(“\n\t 8The least number is %i.”,num3);     }
if ((num1==num2) && (num2==num3))     {     printf(“\n\t The least number is %i.”,num1);     }getch();
return 0;
}

#include <stdio.h>
int main(void)
{
float circle,rectangle,triangle;
float x,y,radius,b,h;
float PI=3.1416;
int choice;
clrscr();
printf(“This program asks the user to choose among the following tasks.\n”);
printf(“1.Get the area of the circle\n”);
printf(“2.Get the area of a rectangle\n”);
printf(“3.Get the area of a triangle\n”);
printf(“\nPlease enter the number of your choice:\n”);
scanf(“%i”,&choice);
if (choice==1)
{
printf(“Enter radius:\n”);
scanf(“%f”,&radius);
circle = PI*(radius*radius);
printf(“The area of the circle with the radius %.2f is %.2f.\n”,radius,circle);
}
if (choice==2)
{
printf(“Enter length:\n”);
scanf(“%f”,&y);
printf(“Enter width:\n”);
scanf(“%f”,&x);
rectangle = x*y;
printf(“The area of the rectangle which has a length of %.2f and a width of %.2f is %.2f.\n”,y,x,rectangle);
}
if (choice==3)
{
printf(“Enter base:\n”);
scanf(“%f”,&b);
printf(“Enter height:\n”);
scanf(“%f”,&h);
triangle = ((b*h)/2);
printf(“The area of the triangle which has a base of %.2f and a height of %.2f is %.2f.\n”,b,h,triangle);
}
getch();
return 0;
}

#include <stdio.h>
int main(void){float circle,rectangle,triangle;float x,y,radius,b,h;float PI=3.1416;int choice;clrscr();printf(“This program asks the user to choose among the following tasks.\n”);printf(“1.Get the area of the circle\n”);printf(“2.Get the area of a rectangle\n”);printf(“3.Get the area of a triangle\n”);printf(“\nPlease enter the number of your choice:\n”);scanf(“%i”,&choice);
if (choice==1){printf(“Enter radius:\n”);scanf(“%f”,&radius);circle = PI*(radius*radius);printf(“The area of the circle with the radius %.2f is %.2f.\n”,radius,circle);
}
if (choice==2){printf(“Enter length:\n”);scanf(“%f”,&y);printf(“Enter width:\n”);scanf(“%f”,&x);rectangle = x*y;printf(“The area of the rectangle which has a length of %.2f and a width of %.2f is %.2f.\n”,y,x,rectangle);}
if (choice==3){printf(“Enter base:\n”);scanf(“%f”,&b);printf(“Enter height:\n”);scanf(“%f”,&h);triangle = ((b*h)/2);printf(“The area of the triangle which has a base of %.2f and a height of %.2f is %.2f.\n”,b,h,triangle);
}
getch();

return 0;}

#include <stdio.h>
int main(void)
{
float num1,num2;
float sum,difference;
clrscr();
printf(“This program displays the sum and difference of the squares of two numbers.\n”);
printf(“Enter first number:\n”);
scanf(“%f”,&num1);
printf(“Enter second number:\n”);
scanf(“%f”,&num2);
printf(“Your numbers are %.2f and %.2f.\n”,num1,num2);
sum = (num1*num1)+(num2*num2);
difference = (num1*num1)-(num2*num2);
printf(“The sum is %.2f and the difference is %.2f.\n”,sum,difference);
getch();
return 0;
}

#include <stdio.h>
int main(void){float num1,num2;float sum,difference;clrscr();
printf(“This program displays the sum and difference of the squares of two numbers.\n”);printf(“Enter first number:\n”);scanf(“%f”,&num1);printf(“Enter second number:\n”);scanf(“%f”,&num2);printf(“Your numbers are %.2f and %.2f.\n”,num1,num2);
sum = (num1*num1)+(num2*num2);difference = (num1*num1)-(num2*num2);
printf(“The sum is %.2f and the difference is %.2f.\n”,sum,difference);
getch();return 0;}

Follow

Get every new post delivered to your Inbox.