// Program2.c // CSE 130 Fall 2009. Homework 1, Oct 8, 2009. // Reza Basseda, Id-No: xxx-yy-zzzz #include int main(void){ //Part 1 //declaration of variables. Please notice that i and j are two variables used as loop iterator. int m, n, k, small, large, sum=0, count=0, i, j; //The message which would be shown to the user and the statement to get the variables from standard consule. printf("Please enter m and n, both > than 0.\n"); scanf("%d %d", &m, &n); // Determination of small and large if(m>n){ small = n; large = m; } else { small = m; large = n; } // Print small and large. printf("small = %d, and large = %d\n", small, large); //Calculation of k k=m*n; //The loop which examines each number between large and k. The number is added to sum if it is not divisible by 3. for(i = large; i <= k; ++i){ if( i%3 != 0){ count++; sum = sum + i; } } //The result of calculation printf("Sum = %d and Count = %d\n", sum, count); //Part 2 //The loop which would be excecuted small times for(i = 1; i <= small; ++i ){ //The loop for printing spaces before numbers on each line for(j = 0; j < small-i ; ++j ) printf(" "); //The loop for printing the numbers in the body of parallelogram for(j = 0; j < small; ++j ) printf("%1d ", i ); //Go to next line and be ready for next line of parallelogram printf("\n"); } return 0; }