Skip to content

Instantly share code, notes, and snippets.

@not7cd
Last active March 14, 2018 15:23
Show Gist options
  • Save not7cd/79bf847c769485783d411f1281f716da to your computer and use it in GitHub Desktop.
Save not7cd/79bf847c769485783d411f1281f716da to your computer and use it in GitHub Desktop.
Laboratorium 3
#include <stdio.h>
int main()
{
float cel, fah;
float low_b = 0., up_b = 300., step = 20.;
printf("Provide lower bound:");
scanf("%f", &low_b);
printf("Provide upper bound:");
scanf("%f", &up_b);
printf("Provide step size:");
scanf("%f", &step);
fah = low_b;
while (fah < up_b) {
cel = 5 * (fah - 32) / 9;
printf("%8.2f\t%8.2f\n", fah, cel);
fah = fah + step;
}
return 0;
}
#include <stdio.h>
int main()
{
float cel, fah;
float low_b = 0., up_b = 300., step = 20.;
printf("Provide lower bound:");
scanf("%f", &low_b);
printf("Provide upper bound:");
scanf("%f", &up_b);
printf("Provide step size:");
scanf("%f", &step);
fah = low_b;
for(fah = low_b; fah < up_b; fah += step) {
cel = 5 * (fah - 32) / 9;
printf("%8.2f\t%8.2f\n", fah, cel);
}
return 0;
}
#include <stdio.h>
int main()
{
float cel, fah;
float low_b = 0., up_b = 300., step = 20.;
printf("Provide lower bound:\t");
scanf("%f", &low_b);
printf("Provide upper bound:\t");
scanf("%f", &up_b);
if (up_b <= low_b) {
printf("ERROR: upper bound can't be lower than upper bound\n");
return 1;
}
printf("Provide step size:\t");
scanf("%f", &step);
if (step < 0) {
printf("ERROR: step can't be negative\n");
return 1;
}
fah = low_b;
for(fah = low_b; fah < up_b; fah += step) {
cel = 5 * (fah - 32) / 9;
printf("%8.2f\t%8.2f\n", fah, cel);
}
return 0;
}
int main()
{
int s=0;
for(int i=1; i<=100; i++)
s+=i;
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment