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

Lab PF Bsit

The document contains three programming problems for C language. The first problem involves counting prime numbers in an array, the second problem focuses on counting the frequency of elements, and the third problem requires rearranging an array to place negative numbers before positive numbers. Sample inputs and outputs are provided for each problem.

Uploaded by

Waleed Zafar Dar
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)
5 views2 pages

Lab PF Bsit

The document contains three programming problems for C language. The first problem involves counting prime numbers in an array, the second problem focuses on counting the frequency of elements, and the third problem requires rearranging an array to place negative numbers before positive numbers. Sample inputs and outputs are provided for each problem.

Uploaded by

Waleed Zafar Dar
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/ 2

In-Lab Programming Fundamentals

C C-112

Question 1: Count Prime Numbers in an Array


Problem Statement:
Write a C program that reads `n` integers into an array and counts how many of them are prime
numbers.

Sample Input:
Enter number of elements: 5
Enter elements: 3 4 7 10 11

Sample Output:
Number of prime elements: 3

Question 2: Frequency of Elements


Problem Statement:
Write a program in C that counts the frequency of each element in the array and displays it.
Assume all elements are non-negative and less than 100.

Sample Input:
Enter number of elements: 6
Enter elements: 2 3 2 5 3 2

Sample Output:
Element 2: 3 times
Element 3: 2 times
Element 5: 1 time

1
Question 3: Arrange Negative Before Positive
Problem Statement:
Write a program in C that rearranges the elements of an array so that all negative numbers
appear before positive numbers. The relative order among negative or positive numbers does not
matter.

Constraints: Use an in-place algorithm.

Sample Input:
Enter number of elements: 8
Enter elements: 1 -2 3 -4 5 -6 7 -8

Sample Output:
Rearranged array: -2 -4 -6 -8 5 3 7 1
(Note: Order among positives or negatives may vary)

You might also like