Write a short code using C++ to print out all odd number from 1 to 100 using a for  loop

1 Answer

Answer :

for( unsigned int i = 1; i < = 100; i++ )
if( i & 0x00000001 )
cout << i << \",\";

Related questions

Description : 1. Write a program to take a number and print whether it is an odd number or even number. -Artificial Intelligence

Last Answer : num = int(input("Enter a number: ")) mod = num % 2 if mod > 0: print("This is an odd number.") else: print("This is an even number.")

Description : Write a program to create two threads one thread will print even no. between 1 to 50 and other will print odd number between 1 to 50.

Last Answer : import java.lang.*; class Even extends Thread { public void run() { try { for(int i=2;i<=50;i=i+2) { System.out.println("\t Even thread :"+i); sleep(500); } } ... public static void main(String args[]) { new Even().start(); new Odd().start(); } }

Description : Write the code given below using ‘for’ loop instead of ‘while’ loop : -Technology

Last Answer : The given code using ‘for’ loop instead of ‘while’ loop :int ifor (i = 1 ; i < = 5 ; i + +){if (1 * i = = 4)jTextFieldl. setText ( “ “ + i) ;}

Description : With respect to a loop in the transportation table, which one of the following is not correct? (1) Every loop has an odd no. of cells and at least 5. (2) Closed loops may or may not b square in ... starting cell, must be occupied cells. (4) Every loop has an even no. of cells and at least four.

Last Answer : Every loop has an odd no. of cells and at least 5.

Description : If you needed to execute some code repeatedly based on a certain condition, which of the following would you use: a) Compiler b) Loop c) Variable d) None of These

Last Answer : b) Loop

Description : Write some code for a while loop. 

Last Answer : int n = 1; while (n < 6) { Console.WriteLine("Current value of n is {0}", n); n++; }

Description : Write some code for a for loop 

Last Answer : for (int i = 1; i <= 5; i++) Console.WriteLine(i);

Description : Rewrite the following code using for loop: int attempt=0; -Technology

Last Answer : for(int attempt=0;attempt

Description : Rewrite the following code using WHILE loop : -Technology

Last Answer : int x = 100 , i = 2;while (i < = 22){jTextAreal . append(' '+(i + x) ) ;x = x - 2 ;i = i + 4;}

Description : By using ................... you can force immediate termination of a loop, by passing the conditional expression and any remaining code in the body of the loop. A) Break B) Continue C) Terminate D) Loop Close

Last Answer : A) Break

Description : In the Print dialog box, you can select the pages for printing. (a) Even pages (b) Odd pages (c) All pages in range (d) All of these -Technology

Last Answer : (d) You can select the even, odd and all pages in range for printing.

Description : Short Cut key for Print Preview is: a) Ctrl + F2 b) Ctrl + F3 c) Ctrl + F1 d) None of These

Last Answer : a) Ctrl + F2

Description : Write the code in python to read the contents of “number.csv” file consisting of data from a mysql table and print the data of the table -Technology

Last Answer : f = open('numbers.csv', 'r') with f:reader = csv.reader(f)for row in reader:for e in row:print(e)

Description : PCL stands for _________ A. Print Code Language B. Printer Code Language C. Printer Character Language D. Printer Command Language

Last Answer : D. Printer Command Language

Description : Write a shell script to accept a number from user check whether number is even or odd.

Last Answer : 2 8

Description : Write a ‘C++’ program to find factorial of given number using loop.

Last Answer : #include<iostream.h> #include<conio.h> void main() { int no,fact=1,i; clrscr(); cout<<"Enter number:"; cin>>no; for(i=1;i<=no;i++) { fact=fact*i; } cout<<"Factorial ="<<fact; getch(); }

Description : Write an HTML code to print the following table: -Technology

Last Answer :

Description : Loop unrolling is a code optimization technique: (A) that avoids tests at every iteration of the loop (B) that improves performance by decreasing the number of instructions in a basic block. ... loops with outer loops (D) that reorders operations to allow multiple computations to happen in parallel.

Last Answer : (A) that avoids tests at every iteration of the loop

Description : Write algorithm and draw flow-chart to print even numbers from 1 to 100.

Last Answer : Here's one possible algorithm to print even numbers from 1 to 100: Start with a variable i equal to 1. Check if i is less than or equal to 100. If i is less than or equal to 100 ... and increments `i` by 1. The loop continues until `i` is greater than 100, and the program ends.

Description : A simpleparity-check code can detect__________ errors. A) an even-number of B) two C) no errors D) an odd-number of

Last Answer : an odd-number of

Description : _______ can detect burst error of length less than or equal to degree of the polynomial and detects burst errors that affect odd number of bits. a. Hamming Code b. CRC c. VRC d. None of the above

Last Answer : b. CRC

Description : A simple parity-check code can detect __________ errors A. an even-number of B. two C. no errors D. an odd-number of

Last Answer : D. an odd-number of

Description : Assertion `:-` In cortical nephrone, the loop of Henle is too short and extends only very little into medulla. Reason `:-` Vasa recta is absent or hig

Last Answer : Assertion `:-` In cortical nephrone, the loop of Henle is too short and extends only very little into ... . D. If both Assertion & Reason are false.

Description : _________ printers print the characters without using ribbon and it can print a complete page at a time. A. Impact B. Non Impact C. Both (A) and (B) D. None of the Above

Last Answer : B. Non Impact

Description : Is it odd for a personality type to change over a short period of time?

Last Answer : I don't think so because of the age you're at. It's natural to have your personality change quite a bit between your high school years and college. It's part of emotional growth. I ... if you are exhibiting some sort of damaging personal change. Such as suddenly finding harming other people fun'.

Description : I am a puzzle with a wordy facade. There's always an answer, even if it seems odd. Only the clever can understand my code. If you don't answer, then you'll never know. What am I? -Riddles

Last Answer : A riddle.

Description : A kind of scanner MICR is the short form of A) Magnetic Ink Character Reader B) Magnetic Ink Code Reader C) Magnetic Ink Cases Reader D) None

Last Answer : Answer : A

Description : What is the diameter of a copper wire to be used in a 16 km loop with a dc loop resistance of 100 ohms/km? A. 0.108 cm B. 1.082 cm C. 0.017 cm D. 0.0465 cm

Last Answer : D. 0.0465 cm

Description : To accept 100 different values into the array we require A) Loop B) If condition C) Function D) Structure

Last Answer : A) Loop

Description : The least significant bit of the binary number, which is equivalent to any odd decimal number, is: A) 0 B) 1 C) 1 or 0 D) 3

Last Answer : Answer : A

Description : What is used to identify whether a data word has an odd or even number of 1’s ? (1) Carry bit (2) Sign bit (3) Zero bit (4) Parity bit

Last Answer : Parity bit

Description : The action performed by a ___________ structure must eventually cause the loop to terminate. a) sequence b) case c) repetition d) process

Last Answer : Answer: c Explanation: The action performed by a repetition structure must eventually cause the loop to terminate. Otherwise, an infinite loop is created

Description : Which is fundamental approache of mapping A : Loop Closing B : Sensorial maps C : Perceptul maps D : Geomatric Maps

Last Answer : A : Loop Closing

Description : Which is fundamental approache of mapping A : Loop Closing B : Sensorial maps C : Perceptul maps D : Geomatric Maps

Last Answer : A : Loop Closing

Description : If a robot can alter its own trajectory in response to external conditions it is considered to be A : Intelligent B : Mobile C : Open loop D : Non-servo

Last Answer : A : Intelligent

Description : What is the name of algorithm in which a loop that continually moves in the direction of increasing value – that is uphill A : Up-Hill Search B : Hill-Climbing C : Hill algorithm D : Platue climbing valley

Last Answer : B : Hill-Climbing

Description : What is the name of algorithm in which a loop that continually moves in the direction of increasing value – that is uphill A : Up-Hill Search B : Hill-Climbing C : Hill algorithm D : Platue climbing valley

Last Answer : B : Hill-Climbing

Description : If a robot can alter its own trajectory in response to external conditions it is considered to be A : Intelligent B : Mobile C : Open loop D : Non-servo

Last Answer : A : Intelligent

Description : What is the name of algorithm in which a loop that continually moves in the direction of increasing value – that is uphill A : Up-Hill Search B : Hill-Climbing C : Hill algorithm D : Platue climbing valley

Last Answer : B : Hill-Climbing

Description : What is the name of algorithm in which a loop that continually moves in the direction of increasing value – that is uphill A : Up-Hill Search B : Hill-Climbing C : Hill algorithm D : Platue climbing valley

Last Answer : B : Hill-Climbing

Description : Computers that control processes accept data in a continuous a) data traffic pattern b) data highway c) infinite loop d) feedback loop e) None of these 44. What refers to a

Last Answer : c) infinite loop

Description : If a robot can alter its own trajectory in response to external conditions, it is considered to be: ⮚ mobile ⮚ open loop ⮚ intelligent ⮚ non-servo

Last Answer : ⮚ intelligent

Description : WLL stands for (1) Walking Land Line (2) Walking Loop Line (3) Wireless Land Line (4) Wireless in Local Loop

Last Answer : Wireless in Local Loop

Description : Do you have to print the free online coupons or does it give you a code to use instead?

Last Answer : I could answer this question myself actually. There are many kinds of free online coupons. For the online shopping websites, they usually require a code. The printable coupons are to bring in the physical location.

Description : What will this code print ? String a = new String ("TEST"); String b = new String ("TEST"); if(a == b) { System.out.println ("TRUE"); } else { System.out.println ("FALSE"); }

Last Answer : Ans. FALSE. == operator compares object references, a and b are references to two different objects, hence the FALSE. .equals method is used to compare string object content.

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} a.clear() print(a) a) None b) { None:None, None:None, None:None} c) {1:None, 2:None, 3:None} d) { }

Last Answer : d) { }

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} b={4:"D",5:"E"} a.update(b) print(a) a) {1: ‘A’, 2: ‘B’, 3: ‘C’} b) Method update() doesn’t exist for dictionaries c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’} d) {4: ‘D’, 5: ‘E’}

Last Answer : c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} a.setdefault(4,"D") print(a) a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}. b) None. c) Error.

Last Answer : a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}.

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} print(a.setdefault(3)) a) {1: ‘A’, 2: ‘B’, 3: ‘C’} b) C c) {1: 3, 2: 3, 3: 3} d) No method called setdefault() exists for dictionary

Last Answer : b) C