int main()
{
int a=10,b=20;
while(a--)
b++;
printf("%d",b);
}
or: a -= -b;
Not possible. Let's not forget than in C the followings are all operators:+, -+=, -=++, --=&, *, []function-call
You cannot compare 2 numbers without using relational operators. Certainly, you could subtract them, but you still need to test the result, and that is a relational operator in itself.
Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.
#include<stdio.h> #include<conio.h> void main() { int a,b,multi; clrscr(); printf("enter a value for a and b"); scanf("%d%d",&a,&b); multi=a*b; printf("the result is %d", multi); getch() }
It is very easy. The program begins here..... /*Program to sum and print numbers without creating variables*/ #include<stdio.h> main() { clrscr(); printf("%d+%d=%d",5,2,5+2); getch(); } /*Program ends here*/ Now just by changing the numbers in the "printf" statement we can add, subtract, multiply and divide the numbers without using variables. Hence the problem is solved..........
Not possible. Let's not forget than in C the followings are all operators:+, -+=, -=++, --=&, *, []function-call
int divide1(int a,int b) { int t=1; while(b*t<=a) { t++; } return t-1; }
You cannot compare 2 numbers without using relational operators. Certainly, you could subtract them, but you still need to test the result, and that is a relational operator in itself.
max = a > b ? a : b; max = max > c ? max : c;
By using repeated addition. Consider two numbers a and b. If you want to find a*b then you can add the numbers repeatedly in a loop to get the product. Eg:product = a;for( i=1; i
Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.
int max (int a, int b) { return a>b?a:b; }
using pow() function.. ..
write a c program to fine largest/smallest of 3no (using ?:ternary operator/conditional operator)
#include<stdio.h> #include<conio.h> void main() { int a,b,multi; clrscr(); printf("enter a value for a and b"); scanf("%d%d",&a,&b); multi=a*b; printf("the result is %d", multi); getch() }
program to find maximum of two numbers using pointers
The question is malformed and incomprehensible.