Preview

Odd-Even Program C++

Satisfactory Essays
Open Document
Open Document
311 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Odd-Even Program C++
LYCEUM OF THE PHILIPPINES UNIVERSITY
CAVITE CAMPUS

COLLEGE OF ENGINEERING AND COMPUTER STUDIES
DEPARTMENT OF COMPUTER STUDIES

LABORATORY ACTIVITY 3
ODD-EVEN NUMBER IN TURBO C

RATINGS

LIA G. BANDAHALA 2011 - 11502

MR. IVAN JAMES FERMANEJO
INSTRUCTOR

I. Aim : * Write a Program to determine whether input number is ODD or EVEN. * Proper demonstration the use of Conditional Statements and Control Statements. II. Tools/Apparatus : Turbo C

III. Procedure :

A. Common Procedure * Enter the number. Make the coding that if the entered number is ODD then display the message the “Number is odd”, else display that “Number is even”. B. Standard Procedure * Analysing the problem * Designing the solution * Flowchart START

int num;

if(num %2 ==0)

TRUE FALSE

printf(“%d is an EVEN number”, num);

printf(“%d is an ODD number”, num);

END

C. Implementing the Solution * Writing the code * * #include<stdio.h> * #include<process.h> * #include<conio.h> * * main(){ * * int num; * int letter; * * clrscr(); * * start: * printf("\nEnter a number: "); * scanf("%d", &num); * * if(num%2 == 0){ * printf("%d", num); * printf(" is an EVEN number!"); * } * else{ * printf("%d", num); * printf(" is an ODD number!"); * } * * printf("\n*************\n"); * printf("Enter again? [y][n]\t"); * scanf("%s", &letter); * * if(letter == 'y'){ * goto start; * } * else if(letter == 'n'){ * exit(0); * } * else{ * printf("\nInvalid Input!"); * printf("\nThank you! Bye!"); * } * * getch(); * return 0; * * }

* Compiling/Debugging the code

IV. Conclusion

In creating a program that would accept a number and determines if the number is an ODD or

You May Also Find These Documents Helpful

  • Satisfactory Essays

    = z) return true; else return false; } Problem 5 a. Output: 720 b. Output: 0 c. Output: 71 d. Output: 362880 Problem 6 a. Output: “Take Programming I.” b. Output:…

    • 188 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    1) Numbers can be represented in binary (using 2 symbols 0 and 1) and hexadecimal ( 16 symbols…

    • 480 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    it238 r6 appendix c

    • 243 Words
    • 2 Pages

    1. Write JavaScript® code that anticipates and handles an error for an expected numeric field. This code is executed on keypress, and the entered value is saved for you in a variable called enteredChar. Include the try block of JavaScript® statements needed to check if the character is not a number or a nonalphanumeric character, or if you throw an error message.…

    • 243 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Program Lovecs.Java

    • 422 Words
    • 2 Pages

    import java.util. Scanner; public class LoveCS { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; limit= scan.nextInt(); int sum=0; int count=1; while (count <=limit) { System.out.println(count+" I love Computer Science!!"); sum+=count; count++; } System.out.println("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); } } import java.util. Scanner; public class PowersOf2 { public static void main(String[]args) { int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0; Scanner scan = new Scanner(System.in); System.out.println("Enter A Number.");…

    • 422 Words
    • 2 Pages
    Better Essays
  • Satisfactory Essays

    Javascript Error Handling

    • 255 Words
    • 2 Pages

    1. Write JavaScript code that anticipates and handles an error for an expected numeric field. This code is executed on keypress and the entered value is saved for you in a variable called enteredChar. Include the try block of JavaScript statements needed to check if the character is not a number or a non-alphanumeric character or if you throw an error message.…

    • 255 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Cosc-2436-73426 Project 2

    • 306 Words
    • 2 Pages

    return -1 // if the while loop exit without retuning a value it means the value…

    • 306 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Income Tax

    • 950 Words
    • 11 Pages

    8 Subtract line 7 from line 6. If zero or less, enter -0-. However, if line 7…

    • 950 Words
    • 11 Pages
    Good Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    7. The If…Then…Else…End If code allows code to be conditionally executed depending on whether a specified logical condition has been met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Good Essays

    POW Free Think Football

    • 531 Words
    • 3 Pages

    After I did that I had to come up with four other scoring systems. So the first scoring system that I came up with was 4 and 8. I wanted to see how the results of two even numbers would come out. So I used the same method as I did before and I also created a table.…

    • 531 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Assignment 1: Logic

    • 605 Words
    • 3 Pages

    Next Belle draws the question card, “Of the five (5) odd numbers, how many different…

    • 605 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    mba 539

    • 256 Words
    • 2 Pages

    If the answer input equals to the correct answer, system shows “Correct!”. If the answer input is not equal to the correct answer, system shows “Try again!” on screen.…

    • 256 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Pseudo Code

    • 486 Words
    • 2 Pages

    The user will input a decimal number, which is a parallelogram that indicates data input for a process. The program would then check to see if the decimal number that has been inputted is between 0 and 255. If the decimal number isn’t between 0 and 255, then the program will go back to the previous process (input a decimal number.) The program will then divide the decimal number by 2. The next step would then store the remainders of all the division as binary and the answer is stored as decimal. The program then checks to see if the decimal number is equal to 0. If this isn’t the case, then the program will return to the stage where the decimal number is divided by 2. If the statement is correct, then the program can output all of the remainders…

    • 486 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Next Belle draws the question card, “Of the five odd numbers, how many different odd numbers do you see?” She answers, “All of them.” From this information, Andy is able to figure out that he has a one, a five, and a seven.…

    • 410 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Math Lesson Plan

    • 563 Words
    • 3 Pages

    2.OA.C.3- Determine whether a group of objects (up to 20) has an odd or even number of members, e.g., by pairing objects or counting them by 2s; write an equation to express an even number as a sum of two equal addends.…

    • 563 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Abbdbd

    • 355 Words
    • 2 Pages

    Write the following programs that takes the size as an integer from the user and displays the shapes (given below) with the help of asterisks.…

    • 355 Words
    • 2 Pages
    Good Essays

Related Topics