Skip to content

Instantly share code, notes, and snippets.

@wbzyl
Created February 29, 2012 14:19
Show Gist options
  • Save wbzyl/1941165 to your computer and use it in GitHub Desktop.
Save wbzyl/1941165 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
double a, b, c, i;
double wynik;
char *formatka = "| %.6f | %.6f |";
//char *head = "%s|%s\n";
char bufor[100];
char wyliczona_formatka[100];
printf("Podaj wartosc poczatkowa: ");
scanf("%lf", &a);
printf("Podaj krok postepu: ");
scanf("%lf", &b);
printf("Podaj wartosc koncowa: ");
scanf("%lf", &c);
for (i = a; i <= c; i = i + b) {
wynik = sqrt(i);
sprintf(bufor, formatka, a, wynik);
//printf(bufor);
/* printf(formatka, a, wynik); */
a = a + b;
}
sprintf(wyliczona_formatka, "%20s|%16s\n", "liczba", "pierwiastek");
// printf("szerokosc formatki: %d\n", strlen(formatka));
printf("--------------------\n");
printf(wyliczona_formatka);
printf("--------------------\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment