Wed Feb 2
Wed Feb 2
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");
}
}
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;
}