1. Koristite while petlju za ispis integer vrijednosti od 1 do 10 na ekranu
12345678910
#include <stdio.h>
main()
{
int loop;
loop = 1;
while( loop <= 10 ) {
printf("%d", loop);
loop++;
}
printf("\n");
}
2. Koristite ugniježđenu while petlju da ponovite
slijedeći ispis
1 22 333 4444 55555
#include <stdio.h>
main()
{
int loop;
int count;
loop = 1;
while( loop <= 5 ) {
count = 1;
while( count <= loop ) {
printf("%d", count);
count++;
}
loop++;
}
printf("\n");
}
3. Koristite if naredbu za usporedbu vrijednosti
integer varijable sum i vrijednosti 65, i ako je sum manja, ispišite
string "Sorry, try again".
if( sum < 65 )
printf("Sorry, try again.\n");
4. Ako je total jednak varijabli good_guess,
ispišite vrijednost varijable total, inače ispišite vrijednost good_guess.
if( total == good_guess )
printf("%d\n", total );
else
printf("%d\n", good_guess );