Thursday, January 1, 2015

loop(6)

1:
#include <stdio.h>
///***loop continue:
int main()
{
int i;
for(i=0;i<=5;i++){
    printf(" %d",i);
        if(i==2)
        continue;
    printf("%d",i);
}
return 0;
}
output:  00 11 2 33 44 55

2:
#include <stdio.h>
///***print all integer in accending order:

int main()
{
int i,start,end;
scanf("%d %d",&start,&end);
for(i=start;i<=end;i++){
    printf("% d ",i);
}
return 0;
}

input:3 9
output:3 4 5 6 7 8 9

3:
#include <stdio.h>
///print all integer in accending order:

int main()
{
int temp,i,start,end;
scanf("%d %d",&start,&end);
if(start>end){
    temp=start;
    start=end;
    end=temp;
}
for(i=start;i<=end;i++){
    printf("% d ",i);
}
return 0;
}

input:3 9
output:3 4 5 6 7 8 9

No comments:

Post a Comment