Professional Documents
Culture Documents
Comp Program Loop
Comp Program Loop
y++;
For Loop }
getch();
#include<stdio.h> }
main()
{ Do – While Loop
int x,y,square,cube;
clrscr(); #include<stdio.h>
printf(“\nEnter A Number:”); main()
scanf(“%d”,&x); {
for (y=1;y<=x;y++) int x,y,square,cube;
{ clrscr();
square=y*y; printf(“\nEnter A Number:”);
cube=y*y*y; scanf(“%d”,&x);
printf(“\n %d %d %d”,y,square,cube); y=1;
} do
getch(); {
} square=y*y;
cube=y*y*y;
While Loop printf(“\n %d %d %d”,y,square,cube);
y++;
#include<stdio.h> }
main() while (y<=x);
{ getch();
int x,y,square,cube; }
clrscr();
printf(“\nEnter A Number:”);
scanf(“%d”,&x);
y=1; Program Number 2:
while (y<=x)
{ For Loop
square=y*y;
cube=y*y*y; #include<stdio.h>
main() y=1;
{ while (y<x)
int x,y,next,first=1,second=1; {
clrscr(); if (y<=1)
printf(“Enter A Number:”); next=y;
scanf(“%d”,&x); else
printf(“\nThe first %d terms of Fibonacci sequence {
are:\n”,x); next=first+second;
for (y=1;y<x;y++) first=second;
{ second=next;
if (y<=1) }
next=y; printf(“%d”,next);
else y++;
{ }
next=first+second; gecth();
first=second; }
second=next;
}
printf(“%d”,next); Do – While Loop
}
getch(); #include<stdio.h>
} main()
{
While Loop int x,y,next,first=1,second=1;
clrscr();
#include<stdio.h> printf(“Enter A Number:”);
main() scanf(“%d”,&x);
{ printf(“\nThe first %d terms of Fibonacci sequence
int x,y,next,first=1,second=1; are:\n”,x);
clrscr(); y=1;
printf(“Enter A Number:”); do
scanf(“%d”,&x); {
printf(“\nThe first %d terms of Fibonacci sequence if (y<=1)
are:\n”,x); next=y;
else #include<stdio.h>
{ main()
next=first+second; {
first=second; int x,y,z,sum=0;
second=next; clrscr();
} printf(“Enter A Number To Be Summed:”);
printf(“%d”,next); scanf(“%d”,&x);
y++; y=1;
} while (y<=x)
while (y<x); {
getch(); z=pow(y,y);
} sum=sum+z;
}
Progam Number 3: printf(“The Sum Is = %d”,sum);
y++;
For Loop getch();
}
#include<stdio.h>
main()
{
int x,y,z,sum=0; Do – While Loop
clrscr();
printf(“Enter A Number To Be Summed:”); #include<stdio.h>
scanf(“%d”,&x); main()
for (y=1;y<=x;y++) {
{ int x,y,z,sum=0;
z=pow(y,y); clrscr();
sum=sum+z; printf(“Enter A Number To Be Summed
} Considering Its Power:”);
printf(“The Sum Is = %d”,sum) scanf(“%d”,&x);
getch(); y=1;
} do
{
While Loop z=pow(y,y);
sum=sum+z; printf(“Enter A Number To Be Summed:”);
y++; scanf(“%d”,&x);
} y=1;
while (y<=x); while (y<=x)
printf(“Sum is = %d”,sum); {
getch(); sum += y;
} ++y;
}
Program Number 4: printf(“Sum is = %d”,sum);
getch():
For Loop }