Saturday, February 14, 2009

CS121 Exercises 3

Output:
Exer3



#include
#include
float num1,num2,sum=0,diff=0,pro=0,quo=0;
void main(){
clrscr();
gotoxy(25,4);textcolor(YELLOW);cprintf("Basic Operations\n\n");
gotoxy(12,7);textcolor(GREEN);cprintf("Enter 1st number:");
scanf("%f", &num1);
gotoxy(12,8);textcolor(GREEN);cprintf("Enter 2nd number:");
scanf("%f", &num2);
sum=num1+num2;
gotoxy(15,11);textcolor(MAGENTA);cprintf("Sum of %.2f and %.2f is %.2f",num1,num2,sum);
diff=num1-num2;
gotoxy(15,13);textcolor(MAGENTA);cprintf("Difference of %.2f and %.2f is %.2f",num1,num2,diff);
pro=num1*num2;
gotoxy(15,15);textcolor(MAGENTA);cprintf("Product of %.2f and %.2f is %.2f",num1,num2,pro);
quo=num1/num2;
gotoxy(15,17);textcolor(MAGENTA);cprintf("Quotient of %.2f and %.2f is %.2f",num1,num2,quo);
getch();
}

No comments:

Post a Comment