Preview

Freedom of Speech and Expression in Malaysia

Satisfactory Essays
Open Document
Open Document
295 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Freedom of Speech and Expression in Malaysia
Practical test (set A)

Write a program to add of number in c programming. The output of the program should be like the figure below:
Enter an integer
98
Sum of digits of entered number = 17

Enter an integer
98
Sum of digits of entered number = 17

#include<stdio.h> Int main ( ) { Int a,b; /*variable declaration*/ Printf(“insert your integer number \n”); /*insert the integer number that is 98*/ Scanf(“%d”,&a); /* the input percent d,mpersand sign and variablename */ Int y=17; /*assigning the variable value that is yis equal to 17*/

While(y<=17); /*y is is less then or equal to 17*/
{
Printf(“the sum is %d\n”,y); /*display the output of sum y*/
}

Return 0; /*returning*/
}

introduction loop structure

loop is know as a group of instruction be executed repeatedly, until a logical condition has been satisfied. looping statements are used to control program flow. There are three major loop statements in the C programming language.

3 major loop : * for loop * while loop * do…while loop

For loop.

For loop is the fundamental looping statement in C. It is often used for situations in which you want to execute a specific task number of times.

While loop

In the while loop, the body of the loop is executed as long as the expression is true. And when the expression become false, program control passes to the line that follows the loop.

Do.. while loop

This loop structure is similar to the while loop. The do while loop checks its condition at the end of the loop. This means that the do while loop will always excute atleast once.

SPG0412

NAME:NURUL EKA SHAHFIKA BINTI RAZI
ID:PIC127060
MISS:MISS NURUL RADFIZA BINTI MUHAMAD RASHID

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Nt1330 Unit 2 Assignment 1

    • 3740 Words
    • 15 Pages

    1. A while loop will not execute the body of the code if you have your test condition incorrect.…

    • 3740 Words
    • 15 Pages
    Satisfactory Essays
  • Satisfactory Essays

    3. When a module is executing, what happens when the end of the module is reached?…

    • 765 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    SD1230 Lab 1

    • 239 Words
    • 2 Pages

    1. What is an instruction? – A sequence of bits understood by the processor to signal a certain action…

    • 239 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    1. Statements are execute in order according to the program code. Complex programs can need the help of a decision structure. Statements have to be true to be executed.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Unit 59 Assignment 3

    • 645 Words
    • 3 Pages

    The process of how the subroutine works within an operating environment is as follows. While the main part of the program is running, there will be a call command sent to the CPU to tell it to stop wherever the program is at, store the W, Z and status along with where in the main program the CPU is at in the stack. Then the main program is cleared from memory and the subroutine is loaded for the CPU to start processing the code. Once the subroutine has finished, the subroutine code is deleted from memory and the CPU will load up the main program back on and will retrieve from stack the stored information (W, Z and status) which will allow the CPU know exactly where it needs to start from.…

    • 645 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    unit 7 assignment 1

    • 431 Words
    • 2 Pages

    5. What three actions do count-controlled loops typically perform using the counter variable? Initialization: Before the loop begins, the counter variable is initialized to a starting value. Test : The loop tests the counter variable by comparing it to a maximum value. If the counter variable is less than or equal to the maximum, the loop iterates. If the counter is greater than the maximum value, the program exits the loop. Increment : To increment a variable means to increase its value. During each iteration, the loop increments the counter variable by adding a predetermined amount to it…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Unit 3 network discovery

    • 1031 Words
    • 5 Pages

    The shell tries to find an executable program with the same name as the command. When it does, the shell executes the program. When finishing the command put an & ampersand symbol at the end of the command and the command will run in the background. Then a cursor will be displayed immediately to allow the next command to be entered.…

    • 1031 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Unit 7 Assignment 1

    • 261 Words
    • 2 Pages

    2. A pretest loop is a loop tests the conditions before performing the iteration. A posttest loop performs the iteration then test the condition.…

    • 261 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Nt1310 Unit 1

    • 4209 Words
    • 17 Pages

    If two steps are indented at the same level, the uppermost statement is executed first. ans)All of the above…

    • 4209 Words
    • 17 Pages
    Powerful Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    23. Write a program for finding product of two positive integers A and B by addition and bit…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 4 Homework

    • 401 Words
    • 2 Pages

    When the module is executing, what happens when the end of the module is reached? Computer jumps back to the part of the program that called the module…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    science 23 answers

    • 12424 Words
    • 61 Pages

     In C, "&&" and "||" are short-circuit boolean operators just like in Java, while the "&" and "|" operators in C…

    • 12424 Words
    • 61 Pages
    Satisfactory Essays
  • Powerful Essays

    The figure shows a circuit that illustrates the concept of loops, which are colored red and labeled loop 1 and loop 2. Loop 1 is the loop around the entire…

    • 9654 Words
    • 80 Pages
    Powerful Essays