1( b) Write a C program to ask the user to enter two integers and apply all arithmetic operations on those print the corresponding values?(hint : +,-,*,/,%)
Algorithm
Step-1 : Start
Step-2 : Declare variables a,b,c,choice
Step-3 : If choice is true
Step-4 : Read Input values a and b
Step-5 : Read choice
Step-6 : perform arithmetic operations
6.1 : if choice = ‘+’
perform addition and display result
6.2 : if choice= ‘-‘
perform Subtraction and display result
6.3 : if choice= ‘*’
perform multiplication and display result
6.4 : if choice= ‘/’
perform Division and display result
6.5 : if choice = ‘%’
perform Modulus and display result
6.6 : Display wrong choice
Step-7 : Go to step-3
Step-8 : Stop
Flowchart
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
printf("\nEnter Two Integers.");
scanf("%d%d",&x,&y);
printf("\nSummation of the two numbers %d,%dis:%d",x,y,(x+y));
printf("\nThe subtraction of the two numbers %d,%d is:%d",x,y,(x-y));
printf("\nThe multiplication of the two numbers %d,%d is:%d",x,y,(x*y));
printf("\nThe division of the two numbers %d,%d is:%d",x,y,(x/y));
printf("\nThe modulus of the two numbers %d,%d is:%d",x,y,(x%y));
getch();
}
Algorithm
Step-1 : Start
Step-2 : Declare variables a,b,c,choice
Step-3 : If choice is true
Step-4 : Read Input values a and b
Step-5 : Read choice
Step-6 : perform arithmetic operations
6.1 : if choice = ‘+’
perform addition and display result
6.2 : if choice= ‘-‘
perform Subtraction and display result
6.3 : if choice= ‘*’
perform multiplication and display result
6.4 : if choice= ‘/’
perform Division and display result
6.5 : if choice = ‘%’
perform Modulus and display result
6.6 : Display wrong choice
Step-7 : Go to step-3
Step-8 : Stop
Flowchart
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
printf("\nEnter Two Integers.");
scanf("%d%d",&x,&y);
printf("\nSummation of the two numbers %d,%dis:%d",x,y,(x+y));
printf("\nThe subtraction of the two numbers %d,%d is:%d",x,y,(x-y));
printf("\nThe multiplication of the two numbers %d,%d is:%d",x,y,(x*y));
printf("\nThe division of the two numbers %d,%d is:%d",x,y,(x/y));
printf("\nThe modulus of the two numbers %d,%d is:%d",x,y,(x%y));
getch();
}

Comments
Post a Comment