Quote from: the walking fedorekd™ on October 14, 2015, 11:37:40 AMQuote from: SoporificSlash on October 14, 2015, 11:36:00 AMjust wrote my midterm for data structures famCode: [Select]#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}Seeing this makes me realise how fucked I am for my own course because I can't code for shit.bruh do not lose hope because i've been there. Both this semester and last I hit a wall where i was seriously considering chaning majors. Its all built around those basic building blocks. This program is nothing fancy just if, else, printf, etc. Its taken me two years to be to this point too you're only just now starting, you'll get there. ANYONE can code, trust me. Your biggest enemy in programming is overcomplicating things
Quote from: SoporificSlash on October 14, 2015, 11:36:00 AMjust wrote my midterm for data structures famCode: [Select]#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}Seeing this makes me realise how fucked I am for my own course because I can't code for shit.
just wrote my midterm for data structures famCode: [Select]#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}
Quote from: Epsira on October 14, 2015, 12:05:37 PMQuote from: SoporificSlash on October 14, 2015, 11:40:10 AMQuote from: the walking fedorekd™ on October 14, 2015, 11:37:40 AMQuote from: SoporificSlash on October 14, 2015, 11:36:00 AMjust wrote my midterm for data structures famCode: [Select]#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}Seeing this makes me realise how fucked I am for my own course because I can't code for shit.bruh do not lose hope because i've been there. Both this semester and last I hit a wall where i was seriously considering chaning majors. Its all built around those basic building blocks. This program is nothing fancy just if, else, printf, etc. Its taken me two years to be to this point too you're only just now starting, you'll get there. ANYONE can code, trust me. Your biggest enemy in programming is overcomplicating thingsI'm also interested in coding, but I want to specifically learn about AI and I don't really know where to start with that.Even something as complex as AI theory is still built upon the basic foundations of programming I.e. if else statements, while and for loops, stacks, queues, etc.
Quote from: SoporificSlash on October 14, 2015, 11:40:10 AMQuote from: the walking fedorekd™ on October 14, 2015, 11:37:40 AMQuote from: SoporificSlash on October 14, 2015, 11:36:00 AMjust wrote my midterm for data structures famCode: [Select]#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>int main(int argc, char * argv[]) {char op, my_string[5];float num, num1, num2, fans;int len, i = 0;if (argc == 4) { sscanf(argv[1], "%f", &num1); sscanf(argv[2], "%c", &op); sscanf(argv[3], "%f", &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("num1 ^ num2 can't be represented\n"); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } else { fans = pow(num1, num2); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (argc == 3) { sscanf(argv[1], "%c", &op); sscanf(argv[2], "%f", &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } }else { printf("Proper input: \n\tnumber operator number\n\t operator number\nEnter your expression: "); gets(my_string); len = strlen(my_string); if (len == 5) { sscanf(my_string, "%f %c %f", &num1, &op, &num2); switch (op) { case '+': fans = num1 + num2; printf("%4.2f + %4.2f = %4.2f\n", num1, num2, fans); break; case '-': fans = num1 - num2; printf("%4.2f - %4.2f = %4.2f\n", num1, num2, fans); break; case 'x': case 'X': fans = num1 * num2; printf("%4.2f x %4.2f = %4.2f\n", num1, num2, fans); break; case '/': if (num2 == 0) { printf("Error: Cannot divide by zero.\n"); } else { fans = num1/num2; printf("%4.2f / %4.2f = %4.2f\n", num1, num2, fans); } break; case '^': if (num1 == 0 && num2 <= 0) { printf("%f ^ %f can't be represented\n", num1, num2); } else { fans = pow(num1, num2); printf("%4.2f ^ %4.2f = %4.2f\n", num1, num2, fans); } break; default: printf("%c is not a valid selection\n", op); break; }} else if (len == 3) { sscanf(my_string, "%c %f", &op, &num); switch (op) { case 'n': case 'N': fans = num * -1; printf("-(%4.2f) = %4.2f\n", num, fans); break; case 'a': case 'A': fans = fabs(num); printf("|%4.2f| = %4.2f\n", num, fans); break; case 's': case 'S': if (num < 0) { printf("Error: Can't find square root of negative number.\n"); } else { fans = sqrt(num); printf("Sqrt(%4.2f) = %4.2f\n", num, fans); } break; default: printf("%c is not a valid selection\n", op); break; } } }}Seeing this makes me realise how fucked I am for my own course because I can't code for shit.bruh do not lose hope because i've been there. Both this semester and last I hit a wall where i was seriously considering chaning majors. Its all built around those basic building blocks. This program is nothing fancy just if, else, printf, etc. Its taken me two years to be to this point too you're only just now starting, you'll get there. ANYONE can code, trust me. Your biggest enemy in programming is overcomplicating thingsI'm also interested in coding, but I want to specifically learn about AI and I don't really know where to start with that.
All I have is academic stuff.