Skip to content

Instantly share code, notes, and snippets.

@not7cd
Last active March 7, 2018 15:34
Show Gist options
  • Save not7cd/af9cb749b9e6e2f0e5af2b5d3abeed05 to your computer and use it in GitHub Desktop.
Save not7cd/af9cb749b9e6e2f0e5af2b5d3abeed05 to your computer and use it in GitHub Desktop.
Laboratorium 2 Proceduralne Języki Programowania I
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char my_uni[80];
char pg[] = "politechnika";
char ug[] = "uniwersytet";
printf("At which university do you study? ");
scanf("%79s", my_uni);
if( strcmp(pg, my_uni) == 0) {
printf("Good choice mate!\n");
} else if ( strcmp(ug, my_uni) == 0) {
printf("Oh no!!!! Boooo!\n");
} else if ( strcmp("AWFiS", my_uni) == 0) {
printf("Not so bad! Better be runnin'\n");
} else if ( strcmp("GUMED", my_uni) == 0) {
printf("Nice, good luck!\n");
} else {
printf("I don't know this place.\n");
}
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char my_uni[80];
char my_field[80];
char pg[] = "politechnika";
char physics[] = "physics";
printf("At which university do you study? ");
scanf("%79s", my_uni);
if( strcmp(pg, my_uni) == 0) {
printf("Good choice mate!\n");
} else {
printf("I don't know this place.\n");
}
printf("What do you study? ");
scanf("%79s", my_field);
if( strcmp(physics, my_field) == 0) {
printf("Very good! I like physics!\n");
} else {
printf("I guess it's fine to, but I don't know.\n");
}
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char my_uni[80];
char my_field[80];
printf("At which university do you study? ");
scanf("%79s", my_uni);
if( strcmp("politechnika", my_uni) == 0 || strcmp("PG", my_uni) == 0) {
printf("Good choice mate!\n");
printf("What do you study? ");
scanf("%79s", my_field);
if( strcmp("physics", my_field) == 0 || strcmp("UG", my_uni) == 0) {
printf("Very good! I like physics!\n");
} else {
printf("I guess it's fine to, but I don't know.\n");
}
} else if ( strcmp("uniwersytet", my_uni) == 0) {
printf("WRONG CHOICE MATE!\n");
} else if ( strcmp("AWFiS", my_uni) == 0) {
printf("Not so bad! Better be runnin'\n");
} else if ( strcmp("GUMED", my_uni) == 0) {
printf("Nice, good luck!\n");
} else {
printf("I don't know this place.\n");
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x;
printf("At which uni do you study\nwrite 1 - PG, 2 - UG, 3 - AWFiS\n");
scanf("%i", &x);
if ( x == 1 ) {
printf("You are at PG\n");
} else if ( x == 2 ) {
printf("You are at UG\n");
} else if ( x == 3 ) {
printf("You are at AWFiS\n");
} else {
printf("I don't recognize it!\n");
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x;
printf("At which uni do you study\nwrite 1 - PG, 2 - UG, 3 - AWFiS\n");
scanf("%i", &x);
switch(x) {
case 1: printf("You are at PG\n"); break;
case 2: printf("You are at UG\n"); break;
case 3: printf("You are at AWFiS\n"); break;
default: printf("I don't recognize it!\n"); break;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment