Advertisement
Th3001nv3nto-200Hab1

c startimes

Jul 26th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. -فقرة تصحيح النص البرمجي :
  2.  
  3. #include <stdio.h>
  4. int main(){
  5.     int tab[] = {548,7,29,31,154,14,98,246,10,489};
  6.     srand(time(NULL));
  7.     int random = rand()%10;
  8.     printf("Random number: %d\n",random);
  9.     for (int i=0; i <= random;i++){
  10.       printf("%d\n",tab(i));
  11.     }
  12.  
  13.  
  14. -فقرة معرفة مخرجات النص البرمجي :
  15.  
  16.  
  17. a b c d e f g h i j k l m n o p q r s t u v w x y z
  18.  
  19.  
  20.  
  21. -فقرة الألغاز البرمجية :
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #define IS_PRIME 1
  26. #define NOT_PRIME 0
  27. int isprimenumber(int n){
  28.     if(n<=1)return NOT_PRIME;
  29.     int q=(int)sqrt(n);
  30.     int IS_OR_NOT_PRIME=IS_PRIME;
  31.     while(q>1){
  32.         if(n%q==0)IS_OR_NOT_PRIME=NOT_PRIME;
  33.         q--;
  34.     }
  35.     return IS_OR_NOT_PRIME;
  36. }
  37. int main()
  38. {
  39.     int c=1000;
  40.     printf("Numbers are:");
  41.     while(c>1){
  42.         if(isprimenumber(c))printf("%d,",c);
  43.         c--;
  44.     }printf("1\n");//1 also but1 is not prime
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement