Created
March 12, 2015 02:40
-
-
Save JHeld07/6be5f8a94d531e090f6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lab 5 | |
//Joshua Held | |
//Wed pm embedded programing spring | |
#include<stdio.h> | |
#include<conio.h> | |
#include<math.h> | |
#define null '\0' | |
/* | |
int stringlength(char *arrayaddress); | |
main(){ | |
char myarray[100]; | |
printf("Enter phrase:"); | |
gets(myarray); | |
printf("The phrase is %d chars long", stringlength(myarray)); | |
while(!kbhit()){} | |
} | |
int stringlength(char *arrayaddress){ | |
int x=0; | |
while(arrayaddress[x++]!=null){} | |
return(x-1); | |
} | |
*/ | |
/* | |
int stringlength(char *arrayaddress); | |
main(){ | |
char myarray[100]; | |
printf("Please enter a phrase:"); | |
gets(myarray); | |
printf("The phrase is %d chars long", stringlength(myarray)); | |
while(!kbhit()){} | |
} | |
int stringlength(char*arrayaddress){ | |
int x=0; | |
while(arrayaddress[x++]!=null){} | |
return(x-1); | |
} | |
void printvertical(char *myarray); | |
main(){ | |
char myarray[100]; | |
printf("Enter a phrase"); | |
gets(myarray); | |
printvertical(myarray); | |
while(!kbhit()){} | |
} | |
void printvertical(char *myarray){ | |
int x=0; | |
while(myarray[x]!=null){ | |
printf(" %c\n", myarray[x]); | |
x++; | |
} | |
} | |
*/ | |
/* | |
//#2 | |
void printbackwards(char *myarray); | |
main(){ | |
char myarray[100]; | |
printf("Enter a phrase \n"); | |
gets(myarray); | |
printbackwards(myarray); | |
while(!kbhit()){} | |
} | |
void printbackwards(char *myarray){ | |
int x=0; | |
while(myarray[x]!=null){ | |
x++; | |
} | |
for(x;x>=0;x--){ | |
printf(" %c", myarray[x]); | |
} | |
} | |
*/ | |
/* | |
// #3 | |
void printbackwards(char *myarray); | |
int stringlength(char *arrayaddress); | |
void printvertical(char *myarray); | |
main(){ | |
char myarray[100]; | |
printf("Enter a phrase "); | |
gets(myarray); | |
printf("String length is %d \n", stringlength(myarray)); | |
printvertical(myarray); | |
printbackwards(myarray); | |
while(!kbhit()){} | |
} | |
void printvertical(char *myarray){ | |
int x=0; | |
while(myarray[x]!=null){ | |
printf(" %c\n", myarray[x]); | |
x++; | |
} | |
} | |
void printbackwards(char *myarray){ | |
int x=0; | |
while(myarray[x]!=null){ | |
x++; | |
} | |
for(x;x>=0;x--){ | |
printf(" %c", myarray[x]); | |
} | |
} | |
int stringlength(char*arrayaddress){ | |
int x=0; | |
while(arrayaddress[x++]!=null){} | |
return(x-1); | |
} | |
*/ | |
/* | |
main(){ | |
int x, y=1, z; | |
printf("How many number of prime numbers would you like to see?"); | |
scanf(" %d", &y); | |
while(z!=y){ | |
if(x(prime) ){ | |
z++; | |
printf (prime) | |
//for(x=1; x==y; x++){ | |
// if(x%x==1){ | |
*/ | |
//#4 | |
int prime(int x); | |
main(){ | |
int y,x,z; | |
printf("Enter the number of Prime numbers you would like to see "); | |
scanf(" %d", &x); | |
for( y=1; y<=x; y++){ | |
while(!prime(z)){ | |
z++; | |
} | |
printf(" %d", z++); | |
} | |
while(!kbhit()){} | |
} | |
int prime(int x){ | |
int cnt=2; | |
while(cnt<x-1){ | |
if(!(x%cnt)){ | |
return(0); | |
} | |
cnt++; | |
} | |
return(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment