Lab 5 Programming
Lab 5 Programming
1|Page
Lab Task -02
1. Write a program that calls print line function 5 times using a loop.
2. Write a function void evenOdd(int), the function should print even or odd according to the
number passed. Call this function in main and show the output.
3. Write a program that prints the status of 10 numbers as even or odd using your evenOdd()
function, the numbers can be as simple as 1-10 or can be between two numbers A and B
provided by the user.
1) Code:
#include <stdio.h>
void printline(void);
int main()
int i;
for (i=0;i<5;i++)
printline();
getchar();getchar();
return 0;
void printline(void)
printf("\n**************************************************\n");
2|Page
Here is shown the screenshot of the above program and its executable file.
3|Page
2) Code:
#include <stdio.h>
void evenOdd(int);
int main()
{
int number;
printf ("Enter a number : ");
scanf("%d",&number);
evenOdd(number);
getchar();getchar();
return 0;
}
void evenOdd(int x)
{
if (x%2==0)
printf ("\nNumber is even.");
else
printf ("\nNumber is odd.");
}
Here is shown the screenshot of the above program and its executable file.
4|Page
Here is shown the executable file of the above program.
5|Page
3) Code:
#include <stdio.h>
void evenOdd(int);
int main()
{
int a,b;
printf ("Please enter the lower limit: ");
scanf ("%d",&a);
printf ("Please enter the upper limit: ");
scanf ("%d",&b);
getchar();getchar();
return 0;
}
void evenOdd(int x)
{
if (x%2==0)
printf ("%d is even.\n\n",x);
else
printf ("%d is odd.\n\n",x);
}
6|Page
Here is shown the screenshot of the above program and its executable file.
7|Page
Here is shown the executable file of the above program.
8|Page