0% found this document useful (0 votes)
26 views6 pages

Probleme Partial Informatica

The document contains 5 programming problems and their solutions: 1) The first problem defines functions to manipulate strings and arrays. 2) The second problem contains examples of pre-increment, post-increment, and accessing array elements. 3) The third problem asks the reader to correct errors in a function that counts characters in a string. 4) Additional problems include examples of enum types, nested code blocks overwriting variables, and fixing errors in string manipulation code. 5) The final problem asks the reader to write a function to find the transpose of a matrix.

Uploaded by

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

Probleme Partial Informatica

The document contains 5 programming problems and their solutions: 1) The first problem defines functions to manipulate strings and arrays. 2) The second problem contains examples of pre-increment, post-increment, and accessing array elements. 3) The third problem asks the reader to correct errors in a function that counts characters in a string. 4) Additional problems include examples of enum types, nested code blocks overwriting variables, and fixing errors in string manipulation code. 5) The final problem asks the reader to write a function to find the transpose of a matrix.

Uploaded by

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

Partial 1:

P1:
int main()
{
char str[20] = "hello";
char* const p = str;
*p='M';
printf("%s\n",str);
return 0;
}
Result: Mello
P2:
int main()
{
int a[5] = {5,1,15,20,25};
int i,j,m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d %d %d",i,j,m);
return 0;
}
Result: 3 2 15
P3: Ce prelucrare efectueaza functia urmatoare? Corectati greselile a.i. sa functioneze
corect:
int f1( char* s,char s){
int count;
for(i=0,s[i]<'\0',);{
if(s[i]=='c')
count++;
}
return count;
}
Rescrieti functia utilizand pointeri.

P4:
#include <stdio.h>

int main()
{
enum status { pass, fail=2, absent};
enum status stud1, stud2, stud3;

stud1 = pass;
stud2 = absent;
stud3 = fail;

printf("%d %d %d %d\n", stud1, stud2, stud3,stud1++);


return 0;
}
Result: 1 3 2 0

P5:
Scrieti o functie care sa gaseasca intr-o matrice mxn de intregi data ca parametru
puncte care sa indeplineasca cumulativ urmatoarele conditii:
*sunt >= decat toate elementele de pe randul lor
*sunt <= decat toate elem de pe coloana lor
Punctele se intorc prin intermediul a 2 vectori( unul constituie indicii randurilor si
celalalt indicii coloanelor)

Partial 1:
P1:
void main(void)
{
int i=0;
for (i=0;i<20;i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
printf("%d,",i);
}
}
Result: 16,21,
P2:
int main(void)
{
int i=1;
for (i=0;i=-1;i=1)
{
printf("%d ",i);
if (i != 1) break;
}
return 0;
}
Result: -1
P3:
#include<stdio.h>
extern int a;

void main(void)
{
int a=5;
{
int a=10;
printf("%d",a++);
}
printf(" %d",a);
}
int a=20;
Result: 10 5
P4: Corectati
#include <stdio.h>
int main()
{
char str[] = "nu sir de caractere";
char *str2;
int j=0;
while (str[++i] != '\0');
while (i >= 0)
str2[j++] = str[--i];
printf("%s\n",str2);
return 0;
}
P5:
Scrieti o functie care primeste ca parametru o matrice si intoarce matricea transpusa.

Partial 2:
P1
int main()
{
int a[5] = {2,3};
printf("%d %d %d\n",a[2],a[3],a[4]);
return 0;
}
Result 0 0 0
P2
#include<stdio.h>
int main(void)
{
char str1[] = "Hello";
char str2[] = "Hello";
if (str1 == str2)
printf("egal\n");
else printf("diferit\n");
return 0;
}
Result: diferit
P3
int main(void)
{
int i=4;
switch(i)
{
default:
printf("this is default\n");
case 1:
printf("this is case 1\n");
break;
case 2:
printf("this is case 2\n");
break;
case 3:

printf("this is case 3\n");


}
return 0;
}
Result:
this is default
this is case 1
P4: Corectati
int main()
{
char str[] = "un sir de caractere";
char *str2;
int j=0;
while (str[++1] != '\0');
while (i >= 0)
str2[j++] = str[--1];
printf("%s\n",str2);
return 0;
}
P5:
Scrieti o functie care primeste ca parametru o matrice A si intoarce o matrice B cu
aceleasi dimensiuni. Matricea B se obtine prin urmatoarea transformare a matricii A:
se cauta valoarea 0 in A; coloana si linia ce contin aceasta valoare se inlocuiesc cu 0.

You might also like