Skip to content Skip to navigation

Connexions

You are here: Home » Content » Вежба-2

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Програмски јазик C –Вежба 2

Наредби за внес и печатење на податоци

1. Внес од тастатура со користење на функцијата scanf()

Example 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
     int a;
     scanf(“%d”, &a);
     printf(“Vrednosta na promenlivata a e %d\n”, a);
     system(“pause”);
}

Доколку се изврши горенаведената програма по внесување на вредноста 10 на екран се печати:

Vrednosta na promenlivata a e 10

2. Збир на два цели броја

Example 2
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a, b, zbir;
    printf(“Programa za zbir na dva broja\n”); 
    printf(“Vesete go prviot sobirok\n”);
    scanf(“%d”, &a);
    printf(“Vesete go vtoriot sobirok\n”);
    scanf(“%d”, &b);
    zbir = a + b;
    printf(“Zbirot na broevite %d i %d e %d\n”, a, b, zbir);
    system(“pause”);
}

Доколку се изврши горенаведената програма по внесување на вредностите 10 и 5 на екран се печати:

Zbirot na broevite 10 и 5 e 15

3. Операции на збир, разлика и множење на два цели броја

Example 3
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a, b;
    printf(“Vesete go prviot broj\n”);
    scanf(“%d”, &a);
    printf(“Vesete go vtoriot broj\n”);
    scanf(“%d”, &b);
    printf(“Zbirot na broevite %d i %d e %d\n”, a, b, a+b);
    printf(“Razlikata na broevite %d i %d e %d\n”, a, b, a-b);
    printf(“Proizvodot na broevite %d i %d e %d\n”, a, b, a*b);
    system(“pause”);
}

Доколку се изврши горенаведената програма по внесување на вредностите 10 и 5 на екран се печати:

Zbirot na broevite 10 и 5 e 15

Razlikata na broevite 10 и 5 e 5

Proizvodot na broevite 10 и 5 e 50

4. Тип на променливи float

Example 4
#include<stdio.h>
#include<stdlib.h>
int main()
{
    float a, b;
    printf(“Vesete go prviot broj\n”);
    scanf(“%f”, &a);
    printf(“Vesete go vtoriot broj. Toj treba da bide razlicen od 0\n”);
    scanf(“%f”, &b);
    printf(“Kolicnikot na broevite %f i %f e %f\n”, a, b, a/b);
    system(“pause”);
}

Доколку се изврши горенаведената програма по внесување на вредностите 10 и 8 на екран се печати:

Kolicnikot na broevite 10.0 и 8.0 e 1.25

Note:
Заблешка: Внимавајте на типот на променливите и специјалните знаци %f.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks