Informatică, întrebare adresată de vasilesibaev, 7 ani în urmă

Vă rog ajutați trebuie de rezolvat în C nu C++ e foarte urgent. problema e atașată.​

Anexe:

Răspunsuri la întrebare

Răspuns de barbucostel89
0

Răspuns:

#include <stdio.h>

int main(void) {

   int A[50];  // declare the array with size n <= 50

   int n;      // declare a variable to store the size of the array

   printf("Enter the size of the array: ");

   scanf("%d", &n);  // read in the size of the array from the user

   for (int i = 0; i < n; i++) {

       if (i % 2 == 0) {  // if i is even

           A[i] = 10;     // assign the value 10 to A[i]

       } else {           // if i is odd

           A[i] = i;      // assign the value of i to A[i]

       }

   }

   // print out the contents of the array

   for (int i = 0; i < n; i++) {

       printf("A[%d] = %d\n", i, A[i]);

   }

   return 0;

}

Alte întrebări interesante