Computer Science, asked by DarkGenius, 6 months ago

Answer it Please. I will mark as brainliest.​

Attachments:

Answers

Answered by caline
1

1. #include<stdio.h>

#include<conio.h>

int add(int, int);

main() {

int a,b,sum;

printf("enter two numbers:");

scanf("%d %d",&a,&b);

sum=add(a,b);

printf("%d\n",sum);

}

int add(int a,int b)

{

int sum,carry;

if (b == 0)

return a;

else

sum = a^b; // add without carrying

carry = (a&b) << 1; // carry, but don’t add

return add(sum,carry); // recursion

}

this is the program for adding two numbers without even using operators( in C).

This above program is executed through HALF_ADDER logic that can be used to add 2 single bits.

Here, bitwise XOR (^) of x and y gives the sum of x and y.

Bitwise AND of x and y gives all carry bits.

(x & y) << 1 is calculated and added it to x ^ y to get the required result.

sry I have no time!!!

just could answer 1st no.

sry for the rest

follow me!!

Answered by Ꚃhαtαkshi
9

Explanation:

Few Tricky Programs in Java

Comments that execute :

Till now, we were always taught “Comments do not Execute”. Let us see today “The comments that execute”

Following is the code snippet:

public class Testing {

public static void main(String[] args)

{

// the line below this gives an output

// \u000d System.out.println("comment executed");

}

}

Output:

comment executed

The reason for this is that the Java compiler parses the unicode character \u000d as a new line and gets transformed into:

public class Testing {

public static void main(String[] args)

{

// the line below this gives an output

// \u000d

System.out.println("comment executed");

}

}

Named loops :

// A Java program to demonstrate working of named loops.

public class Testing

{

public static void main(String[] args)

{

loop1:

for (int i = 0; i < 5; i++)

{

for (int j = 0; j < 5; j++)

{

if (i == 3)

break loop1;

System.out.println("i = " + i + " j = " + j);

}

}

}

}

Output:i = 0 j = 0

i = 0 j = 1

i = 0 j = 2

i = 0 j = 3

i = 0 j = 4

i = 1 j = 0

i = 1 j = 1

i = 1 j = 2

i = 1 j = 3

i = 1 j = 4

i = 2 j = 0

i = 2 j = 1

i = 2 j = 2

i = 2 j = 3

i = 2 j = 4

You can also use continue to jump to start of the named loop.

We can also use break (or continue) in a nested if-else with for loops in order to break several loops with if-else, so one can avoid setting lot of flags and testing them in the if-else in order to continue or not in this nested level.

Similar questions