write a program to swap two variables a=5 , b= 10 without
using third variable
Answers were Sorted based on User's Feedback
Answer / nagendra kumar
#include<stdio.h>
main(){
int a,b;
printf("Enter A value: ");
scanf("%d",&a);
printf("\nEnter B value: ");
scanf("%d",&b);
printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);
a=a+b;
b=a-b;
a=a-b;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
Is This Answer Correct ? | 20 Yes | 4 No |
Answer / dhanalakshmi
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("enter the a value"));
scanf("%d",&a);//a=10
printf("enter the b value");
scanf("%d",&b);//b=5
b=b+a;
a=b-a;
b=b-a;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / samruthi
#include<stdio.h>
void main()
{
int a=5,b=10;
printf("The value of A is:%d",a);
printf("\n The value of B is:%d",b);
b=a;
a=b;
a=b+a;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
getch();
}
Is This Answer Correct ? | 10 Yes | 7 No |
Answer / nagendra kumar
#include<stdio.h>
main(){
int a,b;
printf("Enter A value: ");
scanf("%d",&a);
printf("\nEnter B value: ");
scanf("%d",&b);
printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);
a=(a+b)-(b=a);
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / shafi.shaik
main()
{
int a,b;
clrscr();
printf("enter a, b Value");
scanf("%d%d",&a,&b);
printf("\n%d",a);
printf("\n%d",b);
b=b-a;
a=a+b;
b=a-b;
printf("\n%d",a);
printf("\n%d",b);
getch();
}
Is This Answer Correct ? | 1 Yes | 3 No |
What is FIFO?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
c program to subtract between two numbers without using '-' sign and subtract function.
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
write a c program to check weather a particluar bit is set or not?
Dear Sir, we are required the bubble sorting programs Regs Prem
what is the difference between auto and static keywords
1 Answers cDot, College School Exams Tests, TCS,
Can a void pointer point to a function?
write a program without using main function?
18)struct base {int a,b; base(); int virtual function1(); } struct derv1:base{ int b,c,d; derv1() int virtual function1(); } struct derv2 : base {int a,e; } base::base() { a=2;b=3; } derv1::derv1(){ b=5; c=10;d=11;} base::function1() {return(100); } derv1::function1() { return(200); } main() base ba; derv1 d1,d2; printf("%d %d",d1.a,d1.b) o/p is a)a=2;b=3; b)a=3; b=2; c)a=5; b=10; d)none 19) for the above program answer the following q's main() base da; derv1 d1; derv2 d2; printf("%d %d %d",da.function1(),d1.function1(),d2.function1 ()); o/p is a)100,200,200; b)200,100,200; c)200,200,100; d)none 20)struct { int x; int y; }abc; you can not access x by the following 1)abc-->x; 2)abc[0]-->x; abc.x; (abc)-->x; a)1,2,3 b)2&3 c)1&2 d)1,3,4
Explain modulus operator.
Please list all the unary and binary operators in C.