bathacid
February 17th, 2012, 10:13 PM
I am trying to create a program that will help me make random numbers between 1-255 in the first if statement and one i finish i will have are a part in the else if statement that will randomly create ip address's and cider subnetmask to practice subnetting i only have the first if statement done so far just want to make sure i did it right. ooo btw im really new to programming so be easy on me lol a better copy of this is at http://pastebin.com/dmbt5yBv
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int scanfunc; //This int is ment to choose the binary or subnetting asked in first question
int x; //This int is here to continue looping the binary part as long as this value is set to 1 by the user
printf( "What kind of Subnetting do you wish to do?\n1.)binary conversions\n2.)subnetting\n" );
scanf( "%d", &scanfunc );
if ( scanfunc ==1 ) {
do {
srand(time(NULL));
int rc;
rc = (rand() % (255 + 1) + 1);
printf( "Your number is: %d", rc );
printf( "\nto create a new number press 1 and enter. To exit press 2 then enter\n" );
scanf( "%d", &x );
} while ( x == 1 );
}
else if ( scanfunc == 2 ) {
printf( "function not created yet 2" );
}
else {
printf( "You did not type a 1 or a 2" );
}
getchar();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int scanfunc; //This int is ment to choose the binary or subnetting asked in first question
int x; //This int is here to continue looping the binary part as long as this value is set to 1 by the user
printf( "What kind of Subnetting do you wish to do?\n1.)binary conversions\n2.)subnetting\n" );
scanf( "%d", &scanfunc );
if ( scanfunc ==1 ) {
do {
srand(time(NULL));
int rc;
rc = (rand() % (255 + 1) + 1);
printf( "Your number is: %d", rc );
printf( "\nto create a new number press 1 and enter. To exit press 2 then enter\n" );
scanf( "%d", &x );
} while ( x == 1 );
}
else if ( scanfunc == 2 ) {
printf( "function not created yet 2" );
}
else {
printf( "You did not type a 1 or a 2" );
}
getchar();
return 0;
}