Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Accept any two numbers from the user.
Perform the following operations on it using functions:
1. Addition
2. Subtraction
3. Multiplication
4. Swap the values
5. Print both the numbers in reverse order for example (if
a given number is 234, it should
be printed as 432)



Accept any two numbers from the user. Perform the following operations on it using functions: 1. A..

Answer / neeru bansal

/*Question 2 . Accept any two numbers from the user.
Perform the following operations on it using functions:
1. Addition
2. Subtraction
3. Multiplication
4. Swap the values
5. Print both the numbers in reverse order for example (if a
given number is 234, it should
be printed as 432)
CONCEPT : Using SWITCH statement and functions
SYNTAX : switch
{
case 1: statements;
Break;
case 2: statements;
Break;

default: statements;
}
*/

// Declaration for the preprocessor::
#include
#include
// Main function begins::
void main()
{
// Declaration of variables::
int a,b,c,t,n,num;
long int i;
int l;
char ch;
// Declaration of functions::
char num_status(int);
void sum(int,int);
void sub(int,int);
void mul(int,int);
void swap(int,int);
int reverse(int);
// To clear the screen before printing ::
clrscr();
// Printing SCDL student details for code-authentication::
printf(“\n***************************************\n NAME :
PRIYANKA”);
printf(“\n COURSE: PGDIT [1st Sem.]“);
printf(“\n REGISTRATION NUMBER: 200705826&#8243;);
printf(“\n SUBJECT: Assignment for C Programming
\n***************************************”);
// printing the directions for user to select::
printf(“\n\nPerform the following operations:\n”);
printf(“\n1.Addition:\n”);
printf(“\n2.Subtration:\n”);
printf(“\n3.Multiplication:\n”);
printf(“\n4.Swap the values:\n”);
printf(“\n5.Print the numbers in reverse order:”);
printf(“\n\nSlect your operation:\n”);
scanf(“%d”,&l);// accepts the operation choice
ch=num_status(l);// calling function for selectiong choice

//switch statement for the calculation
switch(ch)
{
case ’1&#8242;:
printf(“Enter the first number:\t”);
scanf(“%d”,&a);
printf(“Enter the second number:\t”);
scanf(“%d”,&b);
sum(a,b);
break;

case ’2&#8242;:
printf(“Enter the first number:\t”);
scanf(“%d”,&a);
printf(“Enter the second number:\t”);
scanf(“%d”,&b);
sub(a,b);
break;

case ’3&#8242;:
printf(“Enter the first number:\t”);
scanf(“%d”,&a);
printf(“Enter the second number:\t”);
scanf(“%d”,&b);
mul(a,b);
break;

case ’4&#8242;:
printf(“Enter the first number:\t”);
scanf(“%d”,&a);
printf(“Enter the second number:\t”);
scanf(“%d”,&b);
swap(a,b);
break;

case ’5&#8242;:
printf(“Enter the first number:\t”);
scanf(“%d”,&a);
printf(“The reverse of %d is %d”,a,reverse(a));
printf(“\nEnter the second number:\t”);
scanf(“%d”,&b);
printf(“The reverse of %d is %d”,b,reverse(b));
break;
}
getch();
}
// Function definition for selecting choice::
char num_status(int l)
{
if(l==1)
return ’1&#8242;;
else if(l==2)
return ’2&#8242;;
else if(l==3)
return ’3&#8242;;
else if(l==4)
return ’4&#8242;;

else
return ’5&#8242;;
}
// Function definition for addition of 2 numbers::
void sum(int a,int b)
{
int c;
c=a+b;
printf(“Addition of 2 numbers:\n a=%d\t b=%d\n c=%d\n”,a,b,c);
}
// Function definition for subtraction of 2 numbers::
void sub(int a,int b)
{
int c;
c=a-b;
printf(“Subtraction of 2 numbers:\n a=%d\t b=%d\n
c=%d\n”,a,b,c);
}
// Function definition for multiplication of 2 numbers::
void mul(int a,int b)
{
int c;
c=a*b;
printf(“Multiplication of 2 numbers:\n a=%d\n b=%d\n
c=%d\n\t\t “,a,b,c);
}
// Function definition for swapping of 2 numbers::
void swap(int a,int b)
{
int t;
t=a;
a=b;
b=t;
printf(“After swapping 2numbers:\n a=%d\n b=%d\n”,a,b,t);
}
// Function definition for reversing 2 numbers::
int reverse(int n)
{
int r,rev;
rev=0;
while(n!=0)
{
r=n%10;
n=n/10;
rev=rev*10+r;
}
return rev;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More General Aptitude Interview Questions

WHO WAS GIVEN BEST ACTOR AWAR 2010 IN FILM FARE?

0 Answers  


can you send me the SBI Clerical post model question papers

0 Answers   State Bank Of India SBI,


I need Matrix and Series questions with solutions.

0 Answers   IBM,


three numbers are in the ratio 2:3:5 and the sum of their squares is 152, what will be their sum ?

5 Answers   Banking,


From 7:00 AM to 11:00 AM it rained 2.25 inches. At 11:00 AM the rain increased to fall at a rate of 1.25 in. every two hours. How many inches of rain landed on the ground by 5:00 PM?

7 Answers   TCS,


One person start from his home towards college which is 53 km far away. Another person started from college towards home after an hour. the speed of first one is 4kmph and the second one is 3 kmph. Then, what is the distance from home to their meeting point?

1 Answers   HCL,


1,4,13,31,112,?

9 Answers   Cambridge, Subex,


Area if square increase by 69% find sides % increased by?

3 Answers   3D PLM,


who translated the novel NIL Darpan in English? a) Rabindranath Tagore b) Madhusudan Dutta C) Dinabandhu Mitra d) Bankim Chandra Chatterjee.

10 Answers   Sodexo, SSC,


If you take a marker & start from a corner on a cube, what is the maximum number of edges you can trace across if you never trace across the same edge twice, never remove the marker from the cube, & never trace anywhere on the cube, except for the corners & edges?

2 Answers  


A question for all cricket lovers and friends. .!!How many runs a single player can score in One day match (50 overs/ 300 balls)...No 'no balls', no wides, no extras, no over throws...So how much runs he can score max???this quetion came in CSAT and 99% people answered it wrong..Clue: the answer is not 1800.

7 Answers   Apex,


. For 1 month, 500 elementary students kept a daily record of the no. of hours of watching television. The average no. of hours per week spent watching television was 28hours. Researchers conducting the study also obtained report cards for each of the students. It was found that the students, who did well in school spent less time watching television and those who spent more time, did poorly. Listed below several possible statements concerning the research. Place a check on the statement that is definitely not true.

2 Answers   CTS, Godrej, Mu Sigma,


Categories