#include <stdio.h> int main( void ) { int wa, i; wa = 0; i = 1; while ( i <= 100 ) { wa = wa + i; i++; } printf( "総和 = %d\n", wa ); return 0; }
#include <stdio.h> int main( void ) { int wa, data; wa = 0; printf( "整数値入力 > " ); scanf( "%d", &data ); while ( data != 0 ) { wa = wa + data; printf( "wa = %d\n", wa ); printf( "整数値入力 > " ); scanf( "%d", &data ); } return 0; }
#include <stdio.h> int main( void ) { char str1[128], str2[128]; int flg = 0; int i = 0; printf( "同じ長さの文字列を2つ入力しなさい\n" ); scanf( "%s", str1 ); scanf( "%s", str2 ); while ( str1[i] != '\0' ) { if ( str1[i] != str2[i] ) { flg++; /* 異なる場合チェック */ } i++; } if ( flg == 0 ) { printf( "等しい文字列を入力\n" ); } else { printf( "異なる文字列を入力\n" ); } return 0; }
#include <stdio.h> int main( void ) { int n, i; n = 0; while ( n < 10 ) { i = 0; while ( i <= n ) { printf( "%d", i ); i++; } printf( "\n" ); n++; } return 0; }
▼戻る▼
「初心者のためのポイント学習C言語」 Copyright(c) 2000-2004 TOMOJI All Rights Reserved