Q. Write c program to print star * pattern .
*
**
***
****
*****
#include<stdio.h>
#include<conio.h>
void main()
{
int n i ,j;
printf("enter ho many rows you want");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Q. Write c program to print one two pattern .
1
12
123
1234
#include<stdio.h>
#include<conio.h>
void main()
{
int n i ,j;
printf("enter ho many rows you want");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
Q. Write c program for sum of digit of given number .
#include<stdio.h>#include<conio.h>void main(){int n,rem,sum=0;printf("Enter number : ");scanf("%d",&n);while(n>0){rem=n%10;sum=sum+rem;n=n/10;}printf("Sum of digit is %d",sum);getch();}