Introduction to C Tutorial 7
Short Description
Introduction to C Tutorial 7. Masha Nikolski CS Department, Technion; May 2006. #include . /* Declarations */. int plus(int a, int b); …
Website: www.cs.technion.ac.il | Filesize: 18kb
Content
Introduction to C Tutorial 7
Masha Nikolski CS Department, Technion; May 2006
#include
/* Declarations */
int plus(int a, int b);
int minus(int a, int b);
int times(int a, int b);
int power(int a, int b);
int main()
{
int k, n, i, j;
printf(”Please enter two integers: “);
if (scanf(”%d %d”, &n, &k) != 2) {
printf(”Error in input!
“);
return 1;
}
printf(”
Multiplication Table
“);
printf(”====================
“);
for (i = 1; i <= k; i++) {
for (j = 1; j <= n; j++)
printf("%d ", power(j, i));
printf("
");
}
return 0;
}
int plus(int a, int b)
{
int i;
if (b < 0)
return minus(a, -b);
for (i = 0; i < b; i++)
a++;
return a;
}
int minus(int a, int b)
{
int i;
if (b < 0)
return plus(a, -b);
for (i = 0; i < b; i++)
a--;
return a;
}
int times(int a, int b)
{
int i, res = 0, cnt = b;
if (b < 0)...
Get the file Download here
Related Books:Related Searches: multiplication table, power int, introduction to c, c tutorial, nikolski
Comments
Leave a Reply