0% found this document useful (0 votes)
34 views2 pages

Void Void Int Int Int Int While

The document contains code for a menu driven C program that performs operations on arrays such as reading elements, checking for palindromes, and sorting elements. The program contains functions for displaying the menu, sorting elements, and the main function with a switch case to call different functions based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Void Void Int Int Int Int While

The document contains code for a menu driven C program that performs operations on arrays such as reading elements, checking for palindromes, and sorting elements. The program contains functions for displaying the menu, sorting elements, and the main function with a switch case to call different functions based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void afisareMeniu();
void ordonare(int arr[], int n);
int main() {
int i=0,aux, n, x, A[30], lngA,k,r,m=0,opt;
while (1) {
afisareMeniu();
printf("Alegeti o optiune");
scanf("%d", &opt);
switch (opt) {
case 0:
exit(0);
break;
case 1:
printf("Cate numere doriti sa introduceti? ");
scanf("%d", &n);
lngA = n;
printf("Introduceti numerele: ");
while (n > 0) {
scanf("%d", &x);
A[i++] = x;
n--;
}
break;
case 2:
for (k = 0; k < lngA; k++) {
aux = A[k];
while (A[k] > 0) {
r = A[k] % 10;
m = (m * 10) + r;
A[k] = A[k] / 10;
}
if (aux == m)
printf("Nr %d este palindrom\n", A[k]);
else
printf("Nr %d nu este palindrom\n", A[k]);
}
break;
case 3:
ordonare(A, n);
printf("Elementele in ordine sunt: ", A[k]);
}
}

}
void ordonare(int arr[], int n)
{
int i, j,aux;
for (i = 0; i < n - 1; i++)
for (j = 0; j < n - i - 1; j++)
if (arr[j] > arr[j + 1])
aux = arr[j];
arr[j] = arr[j+1];
arr[j + 1] = aux;

void afisareMeniu() {
printf("Alegeti o optiune :\n");
printf("1. Cititi elementele multimii A de la tastatura\n");
printf("2. Afisarea elementelor palindroame din multime\n");
printf("3. Afisarea elementelor in ordine crescatoare\n");
printf("0. Iesire");
}

printf("dati dimensiunea matricelor");


scanf("%d", &n);
printf("Prima matrice: ");
for (i=0; i<n; i++)
for (j = 0; j < n; j++)
{
printf("Dati a[%d][%d]", i, j);
scanf("%d", &a[i][j]);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy