Skip to content

Instantly share code, notes, and snippets.

@JHeld07
Created March 11, 2015 22:33
Show Gist options
  • Save JHeld07/5477b98bfa8922bc9f51 to your computer and use it in GitHub Desktop.
Save JHeld07/5477b98bfa8922bc9f51 to your computer and use it in GitHub Desktop.
//Homework #3
//Joshua held
//Problems 3, 4, 10, 12, 13, 14, 15, 16
#include <stdio.h>
#include <conio.h>
#include <math.h>
//Problem 3
/*
main(){
int a, b=0;
printf(" Enter an integer: ");
scanf(" %d", &a);
while(b<=10){
printf(" %d", a);
a+=1;
b++;
}
while(!kbhit()){}
}
//Problem 4
main(){
int a=0, sum;
printf(" Enter an integer: ");
scanf(" %d", &sum);
for(a; a<=10; a++){
printf(" The sum of the next 10 numbers is %d \n", sum);
sum=sum+a;
}
printf("The sum of the next 10 numbers is %d", sum-10);
while(!kbhit()){}
}
//Problem 10
main(){
int a;
printf(" Enter a number:");
scanf(" %d", &a);
while(a!=1){
if(a%2==0){
a/=2;
printf(" %d", a);
}
else{
a=(a*3+1);
printf(" %d", a);
}
}
while(!kbhit()){}
}
//problem 12
main(){
int a, b;
printf(" Enter a number to factor: ");
scanf(" %d", &a);
b=a;
//for(b; b>=0; b--){
while(b>=2){
// printf("%d %d\n", a, b);
b--;
a=a*b;
// printf(" Your factor is %d\n", a);
}
printf(" Your factor is %d\n", a);
while(!kbhit()){}
}
*/
/*
//Problem 15
main(){
int x=100;
while(x>=1){
printf(" The value of x is %d\n", x);
x=x-2;
}
while(!kbhit()){}
}
//*recreate this code using a for() Loop
main(){
int x;
for(x=100; x>=1; x=x-2){
printf(" The value of x is %d\n", x);
}
while(!kbhit()){}
}
*/
//Problem 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment