C
This commit is contained in:
parent
04d946e28c
commit
7522af1dc2
@ -6,20 +6,20 @@ int count = 0;
|
|||||||
|
|
||||||
while (a < number) {
|
while (a < number) {
|
||||||
if(number%a == 0) {
|
if(number%a == 0) {
|
||||||
count += 1;
|
printf("%s\n", "No it isn't a Prime");
|
||||||
a++;
|
return;
|
||||||
} else {
|
|
||||||
a++;
|
|
||||||
}
|
}
|
||||||
|
a++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count == 1) {
|
if(count == 1) {
|
||||||
printf("%s\n", "Yes it's a Prime");
|
printf("%s\n", "Yes it's a Prime");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s\n", "No it isn't a Prime");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int number;
|
int number;
|
||||||
printf("%s\n", "Enter a integer!");
|
printf("%s\n", "Enter a integer!");
|
||||||
|
Binary file not shown.
22
DeitelC/Chapter4/1to20.c
Normal file
22
DeitelC/Chapter4/1to20.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
int counter = 1;
|
||||||
|
while(counter<= 20) {
|
||||||
|
if(counter%5==0) {
|
||||||
|
printf("%d\t",counter);
|
||||||
|
counter++;
|
||||||
|
} else {
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int x = 1; x<=20 ;++x) {
|
||||||
|
if (x%5==0) {
|
||||||
|
printf("%d\t", x);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
15
DeitelC/Chapter4/CelciusToFahrenheit.c
Normal file
15
DeitelC/Chapter4/CelciusToFahrenheit.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int CelciusConvert(int c) {
|
||||||
|
int f;
|
||||||
|
f = ((c*9)/5)+32;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int c;
|
||||||
|
int f;
|
||||||
|
printf("%s\n", "Enter Celcius degree!");
|
||||||
|
scanf("%d", &c);
|
||||||
|
printf("%d %s %d",c, " Celcius equals to Fahrenheit: ", CelciusConvert(c));
|
||||||
|
}
|
Binary file not shown.
9
DeitelC/Chapter4/check.c
Normal file
9
DeitelC/Chapter4/check.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i = 5, j = 7, k = 4, m = -2;
|
||||||
|
//printf("%d", i >= 5 && j > 4);
|
||||||
|
/*printf("%d", !m && k > m);
|
||||||
|
printf("%d", !k || m); */
|
||||||
|
printf("%d", !2);
|
||||||
|
}
|
17
DeitelC/Chapter4/test1.c
Normal file
17
DeitelC/Chapter4/test1.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x, i, j;
|
||||||
|
// prompt user for input
|
||||||
|
printf("%s", "Enter an integer in the range 1-20:");
|
||||||
|
scanf("%d", &x); // read values for x
|
||||||
|
for (i = 1; i <= x; i++) { // count from 1 to x
|
||||||
|
for (j = 1; j <= x; j++) { // count from 1 to x
|
||||||
|
if (j==i)
|
||||||
|
printf("%c",'@'); // output @
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
} // end inner for
|
||||||
|
printf("\n");
|
||||||
|
} // end outer for
|
||||||
|
} // end of main
|
24
test1.c
Normal file
24
test1.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
|
||||||
|
int num;
|
||||||
|
int e = 1;
|
||||||
|
int decimal = 0;
|
||||||
|
|
||||||
|
printf("%s\n", "Enter UNSIGNED BINARY! to convert decimal");
|
||||||
|
scanf("%d", &num);
|
||||||
|
int temp = num;
|
||||||
|
|
||||||
|
while (temp) {
|
||||||
|
int last = temp % 10;
|
||||||
|
temp = temp / 10;
|
||||||
|
|
||||||
|
decimal += last * e;
|
||||||
|
e = e * 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
printf("%s %d\n", "Decimal: ", decimal);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user