Quiz 191196

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Q1

#include<iostream>

Using namespace std;

Void main()

Int arr[5];

Int temp;

For (int I = 0; I < 5; i++)

Cin >> arr[i];

For (int I = 0; I < 5; i++)

For (int j = I + 1; j < 5; j++)

If (arr[j] < arr[i])

Temp = arr[i];

Arr[i] = arr[j];

Arr[j] = temp;

For (int I = 0; I < 5; i++)

Cout << arr[i]<<endl;


}

System(“pause”);

Q2
#include <iostream>

Using namespace std;

Int getOddNum(int arr[], int arrSize)

For (int I = 0; I < arrSize; i++) {

Int count = 0;

For (int j = 0; j < arrSize; j++) {

If (arr[i] == arr[j])

Count++;

If (count % 2 != 0)

Return arr[i];

Return -1;

Int main()

int array[] = { 8, 7, 4, 7, 8,

4,8, 4,8, 4, 8 };

int n = sizeof(array) / sizeof(array[0]);

cout << getOddNum(array, n);

return 0;
}

Q3

#include<stdio.h>

#include<iostream>

Using namespace std;

#define N 3

Int is_good(char l[N][N]);

Int main()

Char logo[N][N];

Int row, col, t, I;

Scanf_s(“%d\n”, &t);

For (I = 0;I < t;i++)

For (row = 0;row < 3;row++)

For (col = 0;col < 3;col++)

Scanf_s(“%c\n”, &logo[row][col]);

If (is_good(logo))

Printf(“yes\n”);
Else

Printf(“no\n”);

Int is_good(char l[N][N])

Int r, c;

For (r = 0; r < N – 1; ++r)

For (c = 0; c < N – 1; ++c)

If (l[r][c] == ‘l’ && l[r + 1][c] == ‘l’ && l[r + 1][c + 1] == ‘l’)

Return 1;

Return 0;

You might also like