Background

Background

Silahkan klik beberapa gambar di bawah ini

  • image1
  • image2
  • image3
  • image4
  • image2
  • image1
  • image4
  • image3

   ICP  Lab 5  

Q 1

#include<stdio.h>
#include<conio.h>
int main (){
int p;
scanf("%d",&p);
while(p<=300&&p>=1){
           if(p%2==1||p%3==1||p%5==1||p%7==1)
                printf("your num is  prime");
   else
                printf("your num is not  prime");
           break;}
if(p>=300)
   printf("your num is out of range");
getch();
return 0;}

Q 2

#include<stdio.h>
#include<conio.h>
int main()
{
printf("       \n Enter the number : 4\n");
printf("* * * *");
getch();
return 0;
}

Q 3 a

#include<stdio.h>
#include<conio.h>
int main(){
   
 for(int i=5; i>=1; i--){
        
      for(int j=1; j<=i; j++){
              printf("* ");}
 printf("\n");
 }
   getch();
return 0;
}

Q 3 b

#include<stdio.h>
#include<conio.h>
int main(){
   
 for(int i=1; i<=5; i++){
        
      for(int j=1; j<=i; j++){
              printf("* ");}
 printf("\n");
 }
   getch();
return 0;
}

Q 3 c

#include <stdio.h>
#include <conio.h>
int main(){
   int row, a, n=5;
   for ( row = 1 ; row <= 5 ; row++ ){
      for ( a = 1 ; a < n ; a++ )
     printf(" ");
      n--;
      for ( a = 1 ; a <= 2*row - 1 ; a++ )
         printf("*");
      printf("\n");}
     return 0;}

Q4

#include <stdio.h>
#include <conio.h>
int main(){
   int row, a, n;
   printf("Enter the num of star's   :");
   scanf("%d",&n);
   for ( row = 1 ; row <= n ; row++ ){
      for ( a = 1 ; a < n ; a++ )
  printf(" ");
      n--;
      for ( a = 1 ; a <= 2*row - 1 ; a++ )
         printf("*");
      printf("\n");}
   return 0;}

Q5

#include<stdio.h>
#include<conio.h>
int main ()
{
int x,y,z,x1,y1,z1,x2,y2,z2,z3,x3,y3,x4,y4,z4,x5,x6,x7,x8,x9,x10,y5,y6,y7,y8,y9,y10,z5,z6,z7,z8,z9,z10;
for(x=0,x1=24,x2=48,x3=72,x4=96,x5=120,x6=144,x7=168,x8=192,x9=216,x10=240;x<=6,x1<=30,x2<=54,x3<=78,x4<=102,x5<=126,x6<=150,x7<=174,x8<=198,x9<=222,x10<=246;x++,x1++,x2++,x3++,x4++,x5++,x6++,x7++,x8++,x9++,x10++)
{
printf("\n%d %c   %d %c   %d %c   %d %c   %d %c  %d %c   %d %c  %d %c  %d %c  %d %c  %d %c",x,x,x1,x1,x2,x2,x3,x3,x4,x4,x5,x5,x6,x6,x7,x7,x8,x8,x9,x9,x10,x10);
}
printf("\n7     31 %c   55 %c   79 %c   103 %c  127 %c   151 %c  175 %c  199 %c  223 %c  247 %c\n8     32     56 %c   80 %c   104 %c  128 %c   152 %c  176 %c  200 %c  224 %c  248 %c\n9     33 %c   57 %c   81 %c   105 %c  129 %c   153 %c  177 %c  201 %c  225 %c  249 %c\n10    34 %c   58 %c   82 %c   106 %c  130 %c   154 %c  178 %c  203 %c  226 %c  250 %c",31,55,79,103,127,151,175,199,223,247,56,80,104,128,152,176,200,224,248,33,57,81,105,129,153,177,201,225,249,34,58,82,106,130,154,178,202,226,250,250);
for(y=11,y1=35,y2=59,y3=83,y4=107,y5=131,y6=155,y7=179,y8=203,y9=227,y10=251;y<=12,y1<=36,y2<=60,y3<=84,y4<=108,y5<=132,y6<=156,y7<=180,y8<=204,y9<=228,y10<=252;y++,y1++,y2++,y3++,y4++,y5++,y6++,y7++,y8++,y9++,y10++)
{
printf("\n%d %c  %d %c   %d %c   %d %c   %d %c  %d %c   %d %c  %d %c  %d %c  %d %c  %d %c",y,y,y1,y1,y2,y2,y3,y3,y4,y4,y5,y5,y6,y6,y7,y7,y8,y8,y9,y9,y10,y10);
}
printf("\n13    37 %c   61 %c   85 %c   109 %c  133 %c   157 %c  181 %c  205 %c  229 %c  253 %c",37,61,85,109,133,157,181,205,229,253);
printf("\n14    38 %c   62 %c   86 %c   110 %c  134 %c   158 %c  182 %c  206 %c  230 %c  254 %c",14,62,86,110,134,158,182,206,230,254);
printf("\n15    39 %c   63 %c   87 %c   111 %c  135 %c   159 %c  183 %c  207 %c  231 %c  255 %c",15,63,87,111,135,159,183,208,231,255);
for(z=16,z1=40,z2=64,z3=88,z4=112,z5=136,z6=160,z7=184,z8=208,z9=232;z<=23,z1<=47,z2<=71,z3<=95,z4<=119,z5<=143,z6<=167,z7<=191,z8<=215,z9<=239;z++,z1++,z2++,z3++,z4++,z5++,z6++,z7++,z8++,z9++)
{
printf("\n%d %c  %d %c   %d %c   %d %c   %d %c  %d %c   %d %c  %d %c  %d %c  %d %c",z,z,z1,z1,z2,z2,z3,z3,z4,z4,z5,z5,z6,z6,z7,z7,z8,z8,z9,z9);
}
getch();
return(0);
}