0% found this document useful (0 votes)
64 views10 pages

C++ Priprema Za Ispit

This document provides 9 programming problems/exercises for a partial exam in Programming I. Each problem provides sample code to test or modify, and asks the student to write the output, modify the code, or write a new program to calculate a specified value (like the circumference of a square given the diagonal length). The problems cover topics like loops, conditional statements, functions, and basic math calculations.

Uploaded by

salihpatkovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views10 pages

C++ Priprema Za Ispit

This document provides 9 programming problems/exercises for a partial exam in Programming I. Each problem provides sample code to test or modify, and asks the student to write the output, modify the code, or write a new program to calculate a specified value (like the circumference of a square given the diagonal length). The problems cover topics like loops, conditional statements, functions, and basic math calculations.

Uploaded by

salihpatkovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

PRIPREMA ZA PARCIJALNI ISPIT

Programiranje I

Sarajevo, novembar 2011.


1
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 1
Napiite rezultat izvravanja sljedeeg programa
#include <iostream>
void main()
{
int X = 2; int i=1;
while (X>=i)
{
X+=1;
i*=2;
cout << X << " ";
}
cout << i;
}

2
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 2
Napiite rezultate izvravanja sljedeih programa
void main()
{
int x = 1, y = 3;
x+=y;
if(y<=x) y-=2*x;
x-=2*y;
cout << x << " " << y << " " <<x % y;
}

3
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 3
#include<iostream>
void main ()
{
int X1 = 1, X2 = 3, i=2;
while (i>=0 & i<=2 )
{
switch (i)
{
case 1:
X1+=X2*i;
break;
case 2:
X2+=X1;
break;
default:
X1-=X2*(i-1);
}
i-=1;
}
cout << i << " " << X1 << " " << X2;
}

4
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 4
#include <iostream.h>
void main()
{
int a=3;
for (int a = 1; a < 3; a++);
cout << a++ << ",";
while (a>=1)
{
cout << a-- << " ";
}
}

5
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 5
#include <iostream>
void main()
{
int X1 = 0;
float X2 = 0;
for (int i = 0; i >= -2; --i)
{
for (int j = 0; j <= 2; j+=2 )
{
X1 += ((i+2) * (j+1));
X2+=X1/(i-1);
}
}
cout << X1 << " " << X2 << endl;
}
1

6
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 6
#include <iostream>
using namespace std;
int a = 10;
int main() {
{
int a=29;
cout << a / 8;
}
cout << a % 7;
system("PAUSE");
}

7
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 7
#include<iostream>
void main ()
{
int X1 = 1, X2 = 4, i;
for (i = 0; i <3; i++)
{
switch (i)
{
case 1:
X1+=X2/i; break;
case 2:
X2*=(X1-i);break;
default:
X1-=X2*i;
3
}
}
cout << i << " " << X1 << " " << X2;
}

8
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 8
Napisati program koji na osnovu unesene dijagonale kvadrata
rauna
njegov obim.
Raunanje obima izvesti pomou funkcije Obim koja kao parametar
prima duinu dijagonale, a vraa obim kvadrata.

9
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

Zadatak 9
Napiite program koji rauna povrinu jednakokrakog trougla, ako su
zadati duina osnovice i duina kraka trougla.
Raunanje povrine izvesti pomou funkcije koja kao parametre
prima duinu osnovice i kraka, a vraa povrinu trougla.

10
UNIVERSITY OF SARAJEVO MECHANICAL ENGINEERING FACULTY DEFENSE TECHNOLOGIES DEPARTMENT www.dtd.ba

You might also like