Friday, March 28, 2014

Write single C statements that
a) Input integer variable x with scanf.
b) Input integer variable y with scanf.
c) Initialize integer variable i to 1.
d) Initialize integer variable power to 1.
e) Multiply variable power by x and assign the result to power.
f) Increment variable i by 1.
g) Test i to see if it’s less than or equal to y in the condition of a while statement.
h) Output integer variable power with printf.


#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();


int x,y,i=1,power=1;
printf("\nEnter First Integer = ");
scanf("%d",&x);
printf("Enter 2nd Integer = ");
scanf("%d",&y);
while(i<=y)



{
    power=power*x;
    printf("\n%d",power);
    i++;
}

return 0;
}

No comments:

Post a Comment