Sunteți pe pagina 1din 3

Program: Multiplication table of a given number

#include <stdio.h>

int main() {

int num, i = 1

printf("\n Enter any Number:");

scanf("%d", &num);

printf("Multiplication table of %d: \n", num);

while (i <= 10) {

printf("\n %d x %d = %d", num, i, num * i);

i++;

return 0;

1.

Write C program to print the following pattern:


1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

Program:
#include<stdio.h>

int main() {

int i, j, k, c = 5;

for (i = 1; i <= 5; i++) {

/* k is taken for spaces */

for (k = 1; k <= c; k++) {

/* blank space */

printf(" ");

for (j = 1; j <= i; j++) {

/* %2d ensures that the number is printed in

two spaces for alignment and the numbers are printed in the order. */

printf("%2d", i);

printf("\n");

/*c is decremented by 1 */

c--;

return 0;

S-ar putea să vă placă și