Wed Feb 2

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 3

Wed feb 2

#include <stdio.h>
#include <math.h>

1`, C program to find all numbers which are dividing by 7 and the remainder is equal
to 2 or 3 between two given integer numbers
int main()
{
        int frtInt, sndInt, i, temp;
        printf(" Enter the fisrt and second integer :");
        scanf("%d %d",&frtInt, &sndInt);
    
        if ( frtInt > sndInt)
    {
                temp = sndInt;
                sndInt = frtInt;
                frtInt = temp;
    }
    
        for (i = frtInt ; i <= sndInt; i++)
    {
                if ((i % 7) == 2 || (i % 7) == 3)
        {
                        printf("%d\n", i);
        }
    }
        return 0;
}

2, printf pyramid
int main()
{
        int i,j,n;
        printf("ENTER the number of the rows :");
        scanf("%d", &n);
    
        for (i = 1; i <= n ; i++)
    {
                for(j = 1; j <= 2*n - 1; j++)
        {
                        if (j >= n - (i -1) && j <= n + (i-1))
            {
                            printf("*");
                        }else
            {
                                printf(" ");
            }
                }printf("\n");
    }
}

3, a program in C to make such a pattern like a pyramid with an asterisk


#include <stdio.h>
void main()
{
    int i,j,spc,rows,k;
    printf("Input number of rows : ");
    scanf("%d",&rows);
    spc=rows+4-1;
    for(i=1;i<=rows;i++)
  {
                  for(k=spc;k>=1;k--)
            {
                            printf(" ");
            }
                      
      for(j=1;j<=i;j++)
      printf("* ");
printf("\n");
        spc--;
  }
}

int main()
{
        int i,j,n;
        printf("enter the amount of rows :");
        scanf("%d", &n);
    
        for (i = 1; i <= n*3; i++)
    {
                for (j = 3 ; j <= 3 ; j++)
        {
                    printf("%d", i);
         
        }
        } printf("\n");
}

4,C program to print 3 numbers in a line, starting from 1 and print n lines. Accept
number of lines (n, integer) from the user
#include <stdio.h>
int main() {
int a, i, j = 1, x = 0;
printf("Input number of lines: ");
scanf("%d", &a);
for(i = 1; i <= a; i++) {
while(x < 3) {
printf("%d ", j++);
x++;
}
x = 0;
printf("\n");
}

return 0;
}

You might also like