
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Dr. Hanif Durad
2
Dr. Hanif Durad
D:\C\CSCI-1190\ lecture-3.ppt, P-
Dr. Hanif Durad
Dr. Hanif Durad
int i;for( i = 1; i <= 100; i++ ) {printf("%d", i);if ( isPrime(i) )
printf("*");if ( i % 10 == 0 )printf("\n");elseprintf("\t"); }^
Dr. Hanif Durad
8
D:\C\Numerical Methods and Programming\lecture3.ppt
int
i;
if ( num < 3 ) return 1;for (i=2; i<=(int) sqrt(num);i++ )if ( num % i == 0 ) break;
if ( num % i ) return 1;return 0; }
Dr. Hanif Durad
9
#include <stdio.h>
2.^
#include <stdlib.h>
/* srand() and rand() */
3.^
#include <time.h>
/* time() */
4.^
int main()
5.^
6.^
float r;
7.^
srand(time(NULL));
8.^
r=1.0*rand()/RAND_MAX;
9.^
printf("Random number: %f\n",r);
return 0;
D:\C\Hanif Search\C.tn.pdf
#include <stdio.h>newI (int I) {
I = 5;printf(“%d\n”, I); } main() {
int
I;
I = 4;printf(“%d\n”, I);newI(I);printf(“%d\n”, I); }
Dr. Hanif Durad
17
2.^
3.^
4.^
5.^
6.^
7.^
8.^
9.^