Skip to main content

Write a program to do the following operations:


6.
Write a program to do the following operations:
--Read any two positive integer operands (say op1 & op2) and one character               type operator (say opr). Note that opr is any mathematical operator.
--Depending upon the operator, do the appropriate operation. e.g. if opr is '+'                then the display the value obtained by evaluating the expression (op1 + op2)


#include<stdio.h>
#include<conio.h>
void main()
{
        int a,b;
        char n;
        clrscr();
printf(“enter the value of a and b=”);
        scanf(“%d%d”,&a,&b);
        printf(“enter the operation to perform=”);
        scanf(“%c”,&n);
            if(n==”+”)
        c=a+b;
        else if(n==”-“)
        c=a-b;
        else if(n==”*”)
        c=a*b;
            else if(n==”/”)
        c=a/b;
else if(n==”%”)
c=a%b;
printf(“the A %c B=%d”,n,c);
getch();
}

Comments

Popular posts from this blog

Learn C Programming

Learn C Programming      The Definitive Guide C is a powerful general-purpose programming language. It is fast, portable and available in all platforms. If you are new to programming, C is a good choice to start your programming journey. This is a comprehensive guide on how to get started in C programming language, why you should learn it and how you can learn it. What is C (Programming Language)? - The Basics Before getting started with C programming, lets get familiarized with the language first. C is a general-purpose programming language used for wide range of applications from Operating systems like Windows and iOS to software that is used for creating 3D movies. C programming is highly efficient. That’s the main reason why it’s very popular despite being more than 40 years old. Standard C programs are portable. The source code written in one system works in another operating system without any change. ...

To find minimum and maximum number from given three numbers.

3. To find minimum and maximum number from given three numbers. #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("Enter The Value Of A,B,C="); scanf("%d%d%d",&a,&b,&c);         if((a>b)&&(a>c))                 printf("The Greater Number Is A=%d",a);         else if((b>c)&&(b>a))                 printf("The Greater Number Is B=%d",b);         else                 printf("The Greater Number Is C=%d",c);         getch(); }