Wednesday, December 31, 2014

Math(5)

1:
 #include<stdio.h>
///***subtraction without using(-)
int main(){
  
    int a,b;
    int sum;
    printf("Enter any two integers: ");
    scanf("%d%d",&a,&b);
    sum = a + ~b + 1;
    printf("Difference of two integers: %d",sum);

    return 0;
}

output: depend on your value


///***(a+(-b-1)+1=ans

2:
 #include<stdio.h>
///***addition without using(+)
int main(){

    int a,b;
    int sum;

    printf("Enter any two integers: ");
    scanf("%d%d",&a,&b);
    sum = a - ~b -1;
    printf("Sum of two integers: %d",sum);

    return 0;
}

output: depend on your value

///***(a-(-b+1)+1

3:
#include <stdio.h>
///***find largest number
int main(){
      int a, b, c;
      printf("Enter three numbers: ");
      scanf("%d %d %d", &a, &b, &c);
      if(a>=b && a>=c)
         printf("Largest number = %d", a);
      if(b>=a && b>=c)
         printf("Largest number = %d", b);
      if(c>=a && c>=b)
         printf("Largest number = %d", c);
      return 0;
}



output: depend on your value

No comments:

Post a Comment