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