Programming Exam Preparation Guide
Programming Exam Preparation Guide
This program calculates the sum of all prime numbers between 1 and 100 using a loop and if statements.
Steps:
Code:
```c
#include <stdio.h>
int main() {
isPrime = 1;
if(i % j == 0) {
isPrime = 0;
break;
if(isPrime)
Programming Exam Preparation Guide
sum += i;
return 0;
```
This program accepts 10 numbers into an array, finds the maximum number, and displays all even numbers.
Steps:
Code:
```c
#include <stdio.h>
int main() {
Programming Exam Preparation Guide
int arr[10], i;
scanf("%d", &arr[i]);
printEven(arr, 10);
return 0;
max = arr[i];
return max;
if(arr[i] % 2 == 0)
Programming Exam Preparation Guide
```
This program simulates a simple banking system using switch and nested if-else.
Steps:
Code:
```c
#include <stdio.h>
int main() {
int choice;
while(1) {
scanf("%d", &choice);
Programming Exam Preparation Guide
switch(choice) {
case 1:
scanf("%f", &amount);
balance += amount;
break;
case 2:
scanf("%f", &amount);
printf("Insufficient balance!\n");
else
balance -= amount;
break;
case 3:
break;
case 4:
return 0;
default:
printf("Invalid choice!\n");
```
Programming Exam Preparation Guide
This program prints a triangle pattern and its inverted form using nested loops.
Code:
```c
#include <stdio.h>
int main() {
int i, j;
printf("Normal Pattern:\n");
printf("*");
printf("\n");
printf("Inverted Pattern:\n");
printf("*");
printf("\n");
Programming Exam Preparation Guide
return 0;
```