0% found this document useful (0 votes)
61 views

Programming Fundamentals Lab 5-4

This document contains 5 programming assignments: 1. A program to print a sequence of numbers for n rows where each row contains a number multiplied by 10, 100, and 1000. 2. A program to print Pascal's triangle using the formula n! / k! (n – k)! 3. A program that takes a number as input and counts the number of times each digit appears in the number. 4. A program to print the letters of the alphabet in a pyramid pattern for a given number of rows. 5. Blank programming code for question 5.

Uploaded by

Adnan Aadi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Programming Fundamentals Lab 5-4

This document contains 5 programming assignments: 1. A program to print a sequence of numbers for n rows where each row contains a number multiplied by 10, 100, and 1000. 2. A program to print Pascal's triangle using the formula n! / k! (n – k)! 3. A program that takes a number as input and counts the number of times each digit appears in the number. 4. A program to print the letters of the alphabet in a pyramid pattern for a given number of rows. 5. Blank programming code for question 5.

Uploaded by

Adnan Aadi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PROGRAMMING FUNDAMENTALS LAB

ADNAN HAIDER
REG NO: SP20-BSE-037
ASSIGNMENT # 5-4
SECTION: BSE 2B
DATE: 17-11-2020
1. Print following sequence for n row

#include<stdio.h>
int main()
{
int i,row;
printf("enter te number of row:");
scanf("%d",&row);
while(i<=row)
{
i++;
printf("%d\t%d\t%d\t%d\n",i,i*10,i*100,i*1000);
}
}
2. Wrtie a program to print pascal’s trangle using formula
n! / k! (n – k )!

#include <stdio.h>
main()
{
int rows, coef = 1, space, i, j;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = 0; i < rows; i++)
{
for (space = 1; space <= rows - i; space++)
printf(" ");
for (j = 0; j <= i; j++)
{
if (j == 0 || i == 0)
coef = 1;
else
coef = coef * (i - j + 1) / j;
printf("%4d", coef);
}
printf("\n");
}
}
3.Write a program to enter a number and show how many times a digit
appeared in number
e.g., n = 23531
1 =1 times
2 = 1 times
3= 2 times
5 = 1 times
#include<stdio.h>
main()
{
int a[10];
int number,num,i,temp=0;
printf("Enter the number");
scanf("%d",&number);
for(i=0;i<10;i++)
{
a[i]=0;
}
num=number;
while (num>0)
{temp=num%10;
num=num/10;
a[temp]++;
}
for(i=0;i<10;i++)
{
if (a[i]>0)
printf("%d present %d times\n",i,a[i]);
}

Q.5
#include <stdio.h>

void main()
{
int i, j;
char alph = 'A';
int n,blk;
int ctr = 1;

printf("Input the number of Letters (less than 26) in the Pyramid : ");
scanf("%d", &n);

for (i = 1; i <= n; i++)


{
for(blk=1;blk<=n-i;blk++)
printf(" ");
for (j = 0; j <= (ctr / 2); j++) {
printf("%c ", alph++);
}

alph = alph - 2;

for (j = 0; j < (ctr / 2); j++) {


printf("%c ", alph--);
}
ctr = ctr + 2;
alph = 'A';
printf("\n");
}
}

You might also like