Preview:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define _CRT_SECURE_NO_WARNINGS
//1.
int main() {
	int cnt = 0, sum = 0, num = 0; float aritm = 0.0;
 
	do {
		printf("Unesi broj\t");
		scanf("%d", &num);
		if (num == 0) {
			break;
		}
		cnt++;
		sum += num;
	} while (1);
	aritm = (float)sum / cnt;
	printf("Aritmeticka sredina je %f.\n", aritm);
}
//2.
int main()
{
	int br = 0, rem = 0;
	printf("Unesi broj:\t");
	scanf(" %d", &br);
	if (br < 0) {
		printf("- ");
		br *= -1;
	}
	do {
		rem = br % 10;
		printf("%d ", rem);
		br /= 10;
	} while (br != 0);
}
//3.
int main()
{
	int rnd = 0, guess = 0, cnt = 0;
 
	srand((unsigned)time(NULL));
	rnd = rand();
	do {
		printf("Unesi broj:\t");
		scanf(" %d", &guess);
		cnt++;
		if (guess < rnd) {
			printf("Random broj je veci od unesenog!\n");
		}
		else if (guess > rnd) {
			printf("Random broj je manji od unesenog!\n");
		}
 
	} while (rnd != guess);
	printf("BINGO!\n");
	printf("Potrebno je bilo %d pokusaja.\n", cnt);
}

//4.
int main()
{
	int temp;
	for (int i = 1; i <= 100; i++)
	{
		temp = 1;
		for (int j = 2; j < i; j++)
		{
			if ((i % j) == 0)
				temp = 0;
		}
		if (temp)
			printf("%d ", i);
	}
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter