Question about Operating Systems

Sample output

enter 1st no:3

enter 2nd no:

sum of even nos:10

sum of odd nos:12

#include <stdio.h>

int main()

{

int n1, n2, i;

int sum = 0;

n1 = 3;

n2 = 11;

for (i = n1; i <= n2; i++) {

if (i % 2 == 0) {

printf("Adding %d\n", i);

sum = sum + i;

}

}

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

return 0;

}

Posted on Feb 21, 2008

To display an even number when an odd number is entered you can add 1.

n= val(text1.text) 'Take the value of n from the textbox.

If n mod 2 =1 then 'If n is an odd number n=n+1 'You make it an even number end if

text2.text = n 'Display it in another textbox.

Please give a good rating to this answer so that I will be encouraged to support people like you having problems with VB6.

n= val(text1.text) 'Take the value of n from the textbox.

If n mod 2 =1 then 'If n is an odd number n=n+1 'You make it an even number end if

text2.text = n 'Display it in another textbox.

Please give a good rating to this answer so that I will be encouraged to support people like you having problems with VB6.

Sep 22, 2011 | Operating Systems

this would be explained on the basis of two FACTS below.......

sum of two odd numbers are always even and

sum of to even numbers are also always even

then how 6 odd numbers (consider 3 pairs, 9 5 3 1 being odd numbers) can make an odd number 21..!!

SO SIMPLE

Make your basics strong...

sum of two odd numbers are always even and

sum of to even numbers are also always even

then how 6 odd numbers (consider 3 pairs, 9 5 3 1 being odd numbers) can make an odd number 21..!!

SO SIMPLE

Make your basics strong...

Aug 14, 2010 | Operating Systems

In FORTRAN:

PROGRAM MATMULT

PARAMETER (N=3)

DIMENSION X(N,N), Y(N,N), Z(N,N)

DOUBLE PRECISION SUM

READ, X

READ, Y

DO 200 J=1, N

DO 100 K=1, N

SUM = 0.0

DO 50 L=1, N

SUM = SUM + X(J,L) * Y(L,K)

50 CONTINUE

Z(J,K) = SUM

100 CONTINUE

200 CONTINUE

WRITE, Z

END

PROGRAM MATMULT

PARAMETER (N=3)

DIMENSION X(N,N), Y(N,N), Z(N,N)

DOUBLE PRECISION SUM

READ, X

READ, Y

DO 200 J=1, N

DO 100 K=1, N

SUM = 0.0

DO 50 L=1, N

SUM = SUM + X(J,L) * Y(L,K)

50 CONTINUE

Z(J,K) = SUM

100 CONTINUE

200 CONTINUE

WRITE, Z

END

Aug 04, 2010 | Operating Systems

May 18, 2010 | Microsoft Windows XP Professional

Hi Friend,

This is a python command solution.you can download the python IDE from this link and get down to buisiness.

www.python.org/download

And here is my example.....

>* >>> L=[]*

>* >>> L.append('10')*

>* >>> L.append('15')*

>* >>> L.append('20')*

>* >>> len(L)*

>* 3*

>* >>> print L*

>* ['10', '15', '20']*

>* *

>* is there a way to sum up all the numbers in a list? the number of *

>* objects in the list is vary, around 50 to 60. all objects are 1 to 3 *

>* digit positive numbers.*

>* *

>* all i can think of is check the length of the list (in the above *

>* example, 3), then L[0]+L[1]+L[2] .....*

Good Luck!!!

This is a python command solution.you can download the python IDE from this link and get down to buisiness.

www.python.org/download

And here is my example.....

>

Good Luck!!!

Jun 23, 2009 | Apple Mac OS X 10.4

above int main () you will want "using namespace std;" without quotes. Under that, "int main ()" without quotes, then a [ bracket to start the main function.

Please rate, thanks!

Please rate, thanks!

Mar 16, 2009 | Operating Systems

This code doesn't include any overflow error checking mechanism. It is not much difficult to implement one however.

#include <stdio.h>

int main(){

unsigned num1,num2,result=0,i=0,temp=0;

printf("Enter the two numbers:\n");

scanf("%d",&num1);

scanf("%d",&num2);

for (i= ~0; i; i>>= 1){ //ensure that the body of the loop is executed 8*sizeof(unsigned) times where 8 is the number of bits in a byte. The number of bits in a byte can be more than 8 on some machines.

temp<<= 1;

temp|= (num1^num2^result)&1;

result= ((num1|num2)&result|num1&num2)&1;//to understand this line and the one above take a look at the full adder circuit above

//here temp is the equivalent of S1 in the full adder circuit above and result is the equivalent of C1

num1>>= 1;

num2>>= 1;

}

//the bit order in temp would be in the reverse order. the following code snippet reverses the order

for (i= ~0, result= ~i; i; i>>= 1){

result<<= 1;

result|= temp&1;

temp>>= 1;

}

printf("Sum: %d",result);

return 0;

}

Here is another elegant solution that uses recursion

#include <stdio.h>

int add(int a, int b){

if (!a) return b;

else

return add((a & b) << 1, a ^ b);

}

int main(){

printf("Enter the two numbers: \n");

int a,b;

scanf("%d",&a);

scanf("%d",&b);

printf("Sum is: %d",add(a,b));

}

#include <stdio.h>

int main(){

unsigned num1,num2,result=0,i=0,temp=0;

printf("Enter the two numbers:\n");

scanf("%d",&num1);

scanf("%d",&num2);

for (i= ~0; i; i>>= 1){ //ensure that the body of the loop is executed 8*sizeof(unsigned) times where 8 is the number of bits in a byte. The number of bits in a byte can be more than 8 on some machines.

temp<<= 1;

temp|= (num1^num2^result)&1;

result= ((num1|num2)&result|num1&num2)&1;//to understand this line and the one above take a look at the full adder circuit above

//here temp is the equivalent of S1 in the full adder circuit above and result is the equivalent of C1

num1>>= 1;

num2>>= 1;

}

//the bit order in temp would be in the reverse order. the following code snippet reverses the order

for (i= ~0, result= ~i; i; i>>= 1){

result<<= 1;

result|= temp&1;

temp>>= 1;

}

printf("Sum: %d",result);

return 0;

}

Here is another elegant solution that uses recursion

#include <stdio.h>

int add(int a, int b){

if (!a) return b;

else

return add((a & b) << 1, a ^ b);

}

int main(){

printf("Enter the two numbers: \n");

int a,b;

scanf("%d",&a);

scanf("%d",&b);

printf("Sum is: %d",add(a,b));

}

Mar 05, 2009 | Microsoft Windows XP Professional

Hi,

Not to worry. As long as you have genuine windows you can get it activated. You call Microsoft Windows activation for US at: 1 888 571 2048 . The IVR will prompt you to enter read out the number on the activation screen. Punch in the numbers using the Phone dial rather than reading it out. This would be simpler. It would also ask you if this is the only computer windows is installed, and if this is the first time you are activating. Press 1 for Yes on both.

Hope this helps. Please rate your feedback!

Thanks,

VJ

Not to worry. As long as you have genuine windows you can get it activated. You call Microsoft Windows activation for US at: 1 888 571 2048 . The IVR will prompt you to enter read out the number on the activation screen. Punch in the numbers using the Phone dial rather than reading it out. This would be simpler. It would also ask you if this is the only computer windows is installed, and if this is the first time you are activating. Press 1 for Yes on both.

Hope this helps. Please rate your feedback!

Thanks,

VJ

Mar 04, 2009 | Microsoft Operating Systems

hmm here is a psuedo to consider

input number n

while

n = n / 2

if n = 0 then print n = even , break loop

if n < 0 then print n is odd

loop

input number n

while

n = n / 2

if n = 0 then print n = even , break loop

if n < 0 then print n is odd

loop

Jul 12, 2008 | Operating Systems

int number = 10 //Insert the number here

if ((number % 2) == 0) { System.out.println(number+" is a even number); } else { System.out.println(number+" is a odd number);

{

Let me know if you need a complete java class for this

if ((number % 2) == 0) { System.out.println(number+" is a even number); } else { System.out.println(number+" is a odd number);

{

Let me know if you need a complete java class for this

Apr 15, 2008 | Operating Systems

128 people viewed this question

Usually answered in minutes!

×