你好,输出1到100之间的偶数,用C语言怎么写啊?

kuaidi.ping-jia.net  作者:佚名   更新日期:2024-07-10
用C语言输出1到100之间的所有偶数(要求输出10换一行)


#include "stdio.h"
#include "conio.h"

main()
{
int i=2,j=0;
while(i<=100)
{

printf("%d ",i);
if(i%20==0)
{
printf("
");
}
i=i+2;
}
getch();
}
采纳。。

#include<stdio.h>
int main()
{
int i;
for(i = 1; i < 100; ++i)
{
if(i % 2 == 0)
printf("%d\n", i);
}
return 0;
}

#include<stdio.h>
int main()
{
int i;
for(i = 1; i < 100; ++i)
{
if(i % 2 == 0)//看是不是偶数
printf("%d\n", i);
}
return 0;

}

#include <stdio.h>
int main()
{
int i;
for(i=1;i<=100;i++)
if(i%2==0)
printf("%d",i);
}

  • Java 输出1-100间的偶数
    答:92 94 96 98 100 也可以这样 public class Test { public static void main(String[] args) { for (int i = 1; i <= 100; i++) { if (i%2 == 0) { System.out.print(i+" ");} } } } 结果:2 4 6 8 10 12 14 16 18 20 22 24 26 28 ...
  • 编写程序,计算并输出1到100中的所有偶数
    答:include<iostream.h> int main(){ int i=1,sum=0;cout<<"1到100的所有偶数:"<<endl;do { if(i%2==0){ cout<<i<<endl;sum+=i;} i++;}while(i<=100);cout<<"1到100所有偶数和是:"<<sum;return 0;} 没有VC++,没办法调试运行,你运行试下看看有没有小错误。
  • 用VB编写:在窗体上输出1到100之间的偶数,要求每10个数显示一行。_百度...
    答:Dim i As Integer, j As Integer j = 0 Label1.Caption = ""For i = 1 To 100 If i Mod 2 = 0 Then j = j + 1 Label1.Caption = Label1.Caption & i & " "If j Mod 10 = 0 Then Label1.Caption = Label1.Caption & Chr(13)End If Next ...
  • ...题目是:输出1到100之间的所有偶数 请依次解释每条代码!!谢谢_百度知...
    答:For I = 1 To 100 进入FOR循环,从1到100 If I Mod 2 = 0 Then 判断是否为偶数 一个偶数除以2余数为0知道的吧,用的就是这个原理 k = k + 1 每判断一个让K加1,做累加操作 Print (I) 打印出I,也就是判断出的偶数 End If 结束一个上面那个判断偶数的IF语句 If k = ...
  • //求1-100之间的所有偶数,10个数一行,用do,while语句
    答:include <stdio.h> int main() { int i = 1;int count = 0; // 统计当前行已输出的数目 do { if (i % 2 == 0) { // 如果是偶数 printf("%d ", i);++count;if (count == 10) { // 每行输出10个数 printf("\n");count = 0;} } ++i;} while (i <= 100);return...
  • c语言高手进!!设计C语言程序,输出[1,100]以内所有的偶数。
    答:while循环:include <stdio.h> void main( ){ int i=1;while (i<=100){ if(i%2==0) printf("%5d",i);if(i%10==0) printf("\n");i++; } } for循环:include <stdio.h> void main( ){ int i=1;for(i=1;i<=100;i++){ if(i%2==0) printf("%5d",i);if...
  • 求1-100之间的偶数,使用while语句实现
    答:java中 public class p39 { public static void main(String[] args) { int s=0;int i=2;while(i<=100) { s=s+i;i=i+2;} System.out.println("s="+s);} } C语言中 include<stdio.h> main(){ int i=2,s=0;while(i<=100){ s=s+i;i=i+2;} printf("%d\n",s);}...
  • C++ 用do while找出1-100偶数
    答:2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 Press any key to continue include<iostream> using namespace std;main(){ int i=1;do { if (i%...
  • python 输出 1-100 内的所有偶数 有运行结果截图,谢谢
    答:for i in range(1, 101):if i % 2 == 0:print(i)
  • C语言编写程序求1到100所有的奇数和偶数
    答:include <stdio.h>int main(void){int i;printf(" 从 1 到 100 所有的奇数如下:\n");for(i=1;i<100;i+=2){printf(" %d",i);if(!((i+1)%20))printf("\n");}printf("\n 从 1 到 100 所有的偶数如下:\n");for(i=2;i<101;i+=2){printf(" %d",i);if(!(...