Clabfile
Clabfile
PROGRAM:-
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
if(a>b){if(a>c){
}else {
if(b>c){
}else{
return 0;
}
OUTPUT:-
4. Write a program to display the following pattern upto N rows, taking the value of N from
the user.
23
456
7 8 9 10
PROGRAM:-
#include<stdio.h>
int main() {
int N, current_number = 1;
scanf("%d", &N);
current_number++;
printf("\n");
return 0;
}
OUTPUT:-
6. Write a program to search for a number entered by the user in a given array and display
the array in ascending order.
PROGRAM:-
#include<stdio.h>
int main() {
scanf("%d", &size);
int arr[size];
scanf("%d", &arr[i]);
scanf("%d", &target);
if (arr[i] == target) {
found = 1;
break;
if (!found) {
arr[i] = arr[j];
arr[j] = temp;
printf("\n");
return 0;
OUTPUT:-
8. Write a program to add , subtract, multiply and divide two numbers using pointers.
PROGRAM:-
#include <stdio.h>
int main() {
float division;
ptr1 = &num1;
ptr2 = &num2;
if (*ptr2 != 0) {
} else {
return 0;}
OUTPUT:-
10. Write a program to create two files with names ‘EvenFile’ and ‘OddFile’. Input 20 numbers
from the user and save even numbers in ‘EvenFile’ and odd numbers in ‘OddFile’.
PROGRAM:-
#include <stdio.h>
int main() {
int number;
return 1;
printf("Enter 20 numbers:\n");
scanf("%d", &number);
if (number % 2 == 0) {
} else {
fclose(evenFile);
fclose(oddFile);
OUTPUT:-
12. Write a menu driven program to perform the following operations:
PROGRAM:-
#include <stdio.h>
#include <math.h>
while (num != 0) {
digits++;
num /= 10;
num = original;
while (num != 0) {
num /= 10;
if (num % i == 0)
return 0;
}
return 1;
int reversed = 0;
while (num != 0) {
num /= 10;
return reversed;
int main() {
do {
printf("\nMenu:\n");
printf("4. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
scanf("%d", &N);
if (isArmstrong(i)) {
printf("\n");
break;
case 2:
scanf("%d", &N);
if (isPrime(i)) {
printf("\n");
break;
case 3:
scanf("%d", &num);
break;
case 4:
printf("Exiting program.\n");
break;
default:
return 0;
OUTPUT:
14. Write a program to calculate factorial of a number and display Fibonacci series upto N
terms using recursive functions.
PROGRAM:-
#include <stdio.h>
if (n <= 1)
return 1;
else
void fibonacci(int n) {
static int a = 0, b = 1;
if (n > 0) {
a = b;
b = a + b;
fibonacci(n - 1);
int main() {
int num, N;
scanf("%d", &num);
scanf("%d", &N);
printf("Fibonacci series up to %d terms: ", N);
fibonacci(N);
printf("\n");
return 0;
OUTPUT:-
16. Write a program to make use of arrays with structures in the following ways:
PROGRAM:-
#include<stdio.h>
struct Student {
char name[50];
int marks[5];
};
struct School {
char name[50];
int rollNumber;
float marks;
};
int main() {
scanf("%s", student1.name);
scanf("%d", &student1.marks[i]);
printf("\n");
scanf("%s", school[i].name);
scanf("%d", &school[i].rollNumber);
scanf("%f", &school[i].marks);
return 0;
}
OUTPUT:-
18. Write a program to perform I/O and make use of file positioning functions on binary files.
PROGRAM:-
#include <stdio.h>
#include <string.h>
struct Employee {
int id;
char name[30];
float salary;
};
int main() {
FILE *file;
if (file == NULL) {
return 1;
scanf("%d", &emp1.id);
scanf(" ");
scanf("%d", &emp2.id);
scanf(" ");
scanf("%f", &emp2.salary);
fseek(file, 0, SEEK_SET);
fclose(file);
return 0;
}
OUTPUT:-
20. Write a program to read time in string format and extract hours, minutes and second also
check time validity.
PROGRAM:-
#include <stdio.h>
#include <stdlib.h>
int main() {
char timeStr[10];
scanf("%s", timeStr);
return 1;
} else {
return 0;
}
OUTPUT:-