Reformatted some example programs for consistency (#35139)

This commit is contained in:
cindydhy
2019-03-11 11:56:22 -04:00
committed by Randell Dawson
parent 384cd7e548
commit 708f951f8e

View File

@ -69,8 +69,8 @@ Generally the part which is inside the curly braces is considered as the body of
```C
#include<stdio.h>
int main() {
int a=5,i;
for(i=1;i<=5;i++)
int a = 5, i;
for (i = 1; i <= 5; i++)
printf("%d ",i);
return 0;
}
@ -83,10 +83,10 @@ Output:
```C
#include<stdio.h>
int main() {
int a=5,i;
for(i=1;i<=5;i++)
if(i%2==0)
printf("%d ",i);
int a = 5, i;
for (i = 1;i <= 5; i++)
if (i % 2 == 0)
printf("%d ", i);
return 0;
}
```
@ -98,10 +98,10 @@ Output:
```C
#include<stdio.h>
int main() {
int a=5,i;
for(i=1;i<=5;i++)
for(j=1;j<=2;j++)
printf("%d ",i);
int a = 5, i;
for (i = 1; i <= 5; i++)
for (j = 1; j <=2 ; j++)
printf("%d ", i);
return 0;
}
```
@ -146,7 +146,7 @@ int main()
{
int i, k, levels, space;
printf("Enter the number of levels in pyramid:");
scanf("%d",&levels);
scanf("%d", &levels);
space = levels;
@ -231,8 +231,8 @@ When "break" statement is executed, the loop stops executing all other statement
#include <stdio.h>
int main(void) {
int n = 5,i;
for(i=0;i<n;i++)
int n = 5, i;
for(i = 0; i < n; i++)
{
printf("%d\n",i);
if(n == 3)
@ -253,10 +253,10 @@ When "continue" statement is executed, the loop execution is skipped for that ti
#include <stdio.h>
int main(void) {
int n = 5,i;
for(i=0;i<n;i++)
int n = 5, i;
for (i = 0; i < n; i++)
{
printf("%d\n",i);
printf("%d\n", i);
if(n == 3)
continue;
}