• Home
  • Disclaimer
  • Privacy Policy
  • Contact Us

Any Coding Here

providing coding tutorial for learning and sharing experiences

Select Menu
  • Home
  • Desktop Programming
    • C
    • Visual Basic
    • Java
    • Phyton
  • Web programming
    • HTML
    • PHP
    • Java Script
    • Perl
    • Responsive Cek
  • Sitemap
  • Static Page
  • Error Page
Home » C LANGUAGE » DESKTOP » sample program "FOR":C Language

Sunday, 15 November 2015

sample program "FOR":C Language

dimas mu
Add Comment
C LANGUAGE, DESKTOP
Sunday, 15 November 2015
sample program for:C Language
sample program for:C Language

on the discussion today I will give an example of a simple program using a command (for).

The first example
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    for(x=1;x<=10;x++){
        printf("%d\n",x);
    }
    return 0;
the role of the code above is to command increments that start variable "x = 1" and the variable is less than or equal to 10 and a code "x ++" is used to add "1 + x" in which the value of  "x is 1" and continue until the result is less than or equal to 10


for(x=1;x<=10;x++){
        printf("%d\n",x);
X=1 : Used to make the base in the statement (for).
X<=10 : Informing that the final value of the variable-value <= 10
X++ : Perform increment on control variable
printf("%d\n",x) ; displaying the results of the statement for (printf should be inside the curly braces for statement. if not then the result will be different)

the second example
the second program we will try to show the numbers from "1" to "10" but only even numbers are out.
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long int x;
    for(x=1;x<=10;x++){
            x = x + 1;
        printf("%d\n",x);
    }
    return 0;
}


x = x + 1;
For example if out "X = 1" it will be "X = X + 1". So when read "1 = 1 + 1" program becomes "1 = 2" and "2" will be out in the program. and then number "2" will be missed because it had been executed by the program. so directly proceed to number "3 = 3 + 1" and so on until "10".

The third example
made the statement program (for) to bring up an odd number
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    for(x=0;x<=9;x++){
        x=x+1;
        printf("%d\n",x);
    }
    return 0;
}
The fourth example
displaying programs from "100" down to number "1"
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    for(x=100;x>=1;x--){
        printf("%d\n",x);
    }
    return 0;
}

The fifth example
changing the control variables from "x = 7 to x <= 77" by adding "7" at each increment. example  "x = 7 and x + = 7" the same as "x = x + 7 so 7 = 7 + 7", which means that "7 = 14".
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    int y;
    for(x=7;x<=77;x+=7){
        printf("%d\n",x);
    }
    return 0;
}
The sixth example
making the results into a coherent
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    for(x = 44; x >= 0;x-=11){
        printf("%d\n",x);
    }
    return 0;
}



Like this article? Please Share: Facebook Twitter Google+
0 comments to "sample program "FOR":C Language"

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Entri Populer

  • Pengertian dan Kegunaan Bahasa Pemrograman PHP
    Pengertian dan Kegunaan Bahasa Pemrograman PHP
    Pengertian dan Kegunaan Bahasa Pemrograman PHP Pemrograman PHP ,merupakan bahasa pemrograman untuk web yang digunakan untuk membuat skri...
  • Contoh Pembuatan StringMatching Bahasa C
    Contoh Pembuatan StringMatching Bahasa C
  • Membuat Php Baru
    Membuat Php Baru
    Membuat Php Baru
  • introducing visual basic programming
    introducing visual basic programming
    What Is Visual Basic Visual Basic is one programming language developed by Microsoft since 1991 evolved form the earlier DOS version cal...
  • create a canvas in:HTML5
    create a canvas in:HTML5
    create a canvas in:HTML5 canvas on the "HTML5" is used to draw on a web page. the canvas, we can include 2D or 3D objects into...
  • Apa itu Pemrograman Java
    Apa itu Pemrograman Java
    Apa itu Pemrograman Java Java merupakan pemrograman Berorientasi objek (PBO) yang dikembangkan oleh Sun Microsystem pada tahun 90-an.Bah...
  • sample program "FOR":C Language
    sample program "FOR":C Language
    sample program for:C Language on the discussion today I will give an example of a simple program using a command (for). The first exa...
  • example problems statement for:C Language
    example problems statement for:C Language
    example problems statement for:C Language someone invested $ 100 in a deposit account with an interest rate of 5%. It is assumed that al...
  • Add Two Integer:C Language
    Add Two Integer:C Language
    Add Two Integer:C Language add two integer in c language is one of the simplest program in this language.The discussion today we will t...
  • repost
    repost
    1 2 3 4 5 6 7 8 <html> <head> <title> .::Title::. </title> </head> <body> section contents ...

Labels

  • C LANGUAGE
  • DESKTOP
  • HTML
  • JAVA
  • PHP
  • VISUAL BASIC
  • WEB PROGRAMING
Powered by Blogger.

Blog Archive

  • ►  2017 (1)
    • ►  February (1)
  • ►  2016 (5)
    • ►  December (2)
    • ►  November (3)
  • ▼  2015 (7)
    • ▼  November (7)
      • create a canvas in:HTML5
      • a first step coding HTML5:HTML 5
      • examples of plural selection switch statement:C La...
      • example problems statement for:C Language
      • sample program "FOR":C Language
      • introducing visual basic programming
      • Add Two Integer:C Language

Labels

  • C LANGUAGE
  • DESKTOP
  • HTML
  • JAVA
  • PHP
  • VISUAL BASIC
  • WEB PROGRAMING

About Me

dimas mu
View my complete profile
Copyright 2015 Any Coding Here - All Rights Reserved
Template By Jenny Psychicfio Distributed by Kaizentemplate.