C Programming Exercises for Students
C Programming Exercises for Students
No:1(A)
Program to convert Celsius to Fahrenheit
PROGRAM:
#include<conio.h>
void main()
{
float cel,fahren;
clrscr();
printf("\n Enter the Temparature in Celsius : ");
scanf("%f",&cel);
fahrenheit = (1.8 * cel) + 32;
printf("\n Temperature in Fahrenheit : %f ",fahren);
getch();
}
Input:
RESULT:
PROGRAM:
#include <stdio.h>
int main(void)
{
int x=62;
char a='b';
float p=8.5,q=3.32;
// Print Address
printf("%c is Stored at Address %u\n",a,&a);
printf("%d is Stored at Address %u\n",x,&x);
printf("%f is Stored at Address %u\n",p,&p);
printf("%f is Stored at Address %u\n",q,&q);
// Print Size
printf("\n size of short: %d", sizeof(short));
printf("\n size of int: %d", sizeof(int));
printf("\n size of long int: %d", sizeof(long));
return 0;
}
RESULT:
PROGRAM :
#include<stdio.h>
int main()
{
float amount, rate, time, si;
printf("\nEnter Principal Amount : ");
scanf("%f", &amount);
printf("\nEnter Rate of Interest : ");
scanf("%f", &rate);
printf("\nEnter Period of Time : ");
scanf("%f", &time);
si = (amount * rate * time) / 100;
printf("\nSimple Interest : %f", si);
return(0);
}
Input
Enter Principal Amount : 10000
Enter Rate of Interest : 5
Enter Period of Time : 4
Output
Si = 2000
RESULT:
PROGRAM :
#include <stdio.h>
int main()
{
int a, b, c, i, n;
/* Reads a number from user */
printf("Enter value of n to print Fibonacci series : ");
scanf("%d", &n);
a = 0; / * Initialize the value * /
b = 1;
c = 0; / * Sum the value * /
for(i=1; i<=n; i++)
{
printf("%d, ", c);
a=b;
b=c;
c=a+b;
}
return 0;
}
Input :
Enter value of n to print Fibonacci series : 100
Output:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
RESULT:
PROGRAM :
#include <stdio.h>
int main()
{
int i, num1, num2, min, hcf=1;
/* Reads two numbers from user */
printf("Enter any two numbers to find HCF: ");
scanf("%d %d", &num1, &num2);
min = (num1<num2) ? num1 : num2; // Conditional Operator
for(i=1; i<=min; i++)
{
/* If i is factor of both number */
if(num1 % i==0 && num2 % i==0)
{
hcf = i;
}
}
printf("HCF of %d and %d = %d\n", num1, num2, hcf);
return 0;
}
Input :
Enter any two numbers to find HCF: 12 30
Output:
HCF of 12 and 30 = 6
RESULT:
PROGRAM :
#include <stdio.h>
int main()
{
char ch; // declare a variable to get any character .
printf("Enter any character: ");
scanf("%c", &ch); /* Reads a character from user */
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch=='A' || ch=='E' || ch=='I' || ch=='O' ||
ch=='U')
{
printf("%c is VOWEL.\n", ch);
}
else if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
{
printf("%c is CONSONANT.\n", ch);
}
return 0;
}
Input :
Enter any character : a
Output:
a is VOWEL.
RESULT:
PROGRAM :
#include <stdio.h>
int main()
{
int rows, a, b, number = 1;
printf("Number of rows of Floyd's triangle to print:");
scanf("%d",&rows);
printf("FLOYD'S TRIANGLE\n\n");
for ( a = 1 ; a <= rows ; a++ )
{
for ( b = 1 ; b <= a ; b++ )
{
printf("%d ", number);
number++;
}
printf("\n");
}
return 0;
}
PROGRAM :
#include <stdio.h>
#include <conio.h>
void main()
{
int year;
clrscr();
printf("Enter the Year (YYYY) : ");
scanf("%d",&year);
if(year%4==0 && year%100!=0 || year%400==0)
printf("\nThe Given year %d is a Leap Year");
else
printf("\nThe Given year %d is Not a Leap Year");
getch();
}
Input :
Enter the Year (YYYY) : 1200
Output :
The Given year %d is a Leap Year
RESULT:
PROGRAM :
#include <stdio.h>
float add(float num1, float num2);
float sub(float num1, float num2);
float mult(float num1, float num2);
float div(float num1, float num2);
float squa(float num1, float num2);
int main()
{
char op;
float num1, num2, result=0.0f;
printf("WELCOME TO SIMPLE CALCULATOR\n");
printf("----------------------------\n");
printf("Enter [number 1] [+ - * /] [number 2]\n");
/* Input two number and operator from user */
scanf("%f %c %f", &num1, &op, &num2);
switch(op)
{
case '+':
result = add(num1, num2); break;
case '-':
result = sub(num1, num2); break;
case '*':
result = mult(num1, num2); break;
case '/':
result = div(num1, num2); break;
case 's':
result = squa(num1, num2); break;
default:
printf("Invalid operator");
}
/* Print the result */
printf("%.2f %c %.2f = %.2f", num1, op, num2, result);
return 0;
}
float add(float num1, float num2)
{
return num1 + num2;
}
RESULT :
Program:
#include<stdio.h>
int main()
{
int num,r,sum=0,temp;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while (num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is an Armstrong number",temp);
else
printf("%d is not an Armstrong number",temp);
return 0;
}
Input :
Enter a number: 153
Output:
153 is an Armstrong number
RESULT:
PROGRAM:
#include<stdio.h>
#include<math.h>
#include<conio.h>
int getWeight(int n)
{
int w=0;
float root=sqrt(n);
if(root==ceil(root))
w+=5;
if(n%4==0&&n%6==0)
w+=4;
if(n%2==0)
w+=3;
return w;
}
void main()
{
int nums[15];
int ws[15];
int i,j,t,n;
printf("Enter number of numbers : ");
scanf("%d",&n);
printf("\nEnter numbers : ");
for(i=0;i<n;i++)
scanf("%d",&nums[i]);
for(i=0;i<n;i++)
ws[i]=getWeight(nums[i]);
printf("\nBefore sorting:\n");
for(i=0;i<n;i++)
printf("%d:%d\t",nums[i],ws[i]);
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
if(ws[j]>ws[j+1])
{
t=ws[j+1];
Before Sorting
10:3 36:12 54:3 89:0 12:7 27:0
Sorted:
89:0 27:0 10:3 54:3 12:7 36:12
RESULT :
Populate an array with height of persons and find how many persons
are above the average height
PROGRAM:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
void readArray(int [] , int );
double findAverage(int [] , int);
int countAboveAverage(int [] , int , double);
double average;
int count;
int main()
{
int arr[SIZE];
int n;
printf("Enter a value for n: ");
scanf("%d", &n);
readArray(arr, n);
average = findAverage(arr, n);
count = countAboveAverage(arr, n, average);
printf("The number of persons above the average height is %d:",count);
return 0;
}
void readArray(int arr[], int n)
{
int i;
for(i=0; i<n; i++)
{
printf("Please enter #%d: ", i+1);
scanf("%d", arr + i); /* or &arr[i] */
}
}
double findAverage(int arr[], int n)
{
int sum = 0;
int i;
for(i=0; i<n; i++)
sum+=arr[i];
return (double)sum / n;
}
Input
Enter a value for n: 2
Please enter #1: 23
Please enter #2: 45
Output
The number of persons above the average height is 1
RESULT :
#include<stdio.h>
#include<conio.h>
#define feettomet 0.308
void main()
{
float a[10][10],bmi;
float ftom;
int n,i,j;
clrscr();
printf("enter the number o person\n");
scanf("%f",&n);
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
scanf("%f",&a[i][j]);
}
}
for(i=0;i<n;i++)
{
j=0;
bmi=0.00;
ftom=0.00;
ftom=a[i][j+1]*feettomet;
bmi=a[i][j]/(ftom*ftom);
printf("%.2f %.2f %.2f\n",a[i][j],a[i][j+1],bmi);
}
}
Sample Input and Output:
Input
Enter upper limit:2
Enter weight and height: 53 5.5 65 5.5
Output
53 5.5 BMI: 18
65 5.5 BMI: 23.1
RESULT :
PROGRAM :
#include<stdio.h>
#include<string.h>
void reverse(char str[10])
{
int r,l;
char c;
r= strlen(str)-1;
l=0;
while(l<r)
{
if(!(str[l]>='a' && str[l]<='z') || (str[l]>='A' && str[l]<='Z'))
l++;
else if(!(str[r]>='a' && str[r]<='z') || (str[r]>='A' && str[r]<='Z'))
r--;
else
{
c=str[l];
str[l]=str[r];
str[r]=c;
l++;
r--;
}
}
printf("%s",str);
}
int main()
{
// char str1[10]="g@vat";
char str1[10];
printf("Enter the String to be Reverse : \n");
scanf(“%c”, str1);
printf("Reverse String is : \n");
reverse(str1);
return 0;
}
Reverse String is :
tav@g
RESULT:
PROGRAM :
#include <stdio.h>
#include <conio.h>
#include<math.h>
#include<string.h>
long decimalToBinary(long n);
void octal_hex(int n, char hex[]); int hex_octal(char hex[]);
int main()
{
long decimal;
char hex[20],c; int n;
printf("Enter a decimal number\n");
scanf("%ld", &decimal);
printf("Binary number of %ld is %ld", decimal,
decimalToBinary(decimal));
printf("Enter octal number: ");
scanf("%d",&n);
octal_hex(n,hex);
printf("Hexadecimal number:%s",hex);
getch();
return 0;
}
/* Function to convert a decinal number to binary number */
long decimalToBinary(long n)
{
int remainder;
long binary = 0, i = 1;
while(n != 0)
{
remainder = n%2;
n = n/2;
binary= binary + (remainder*i);
i = i*10;
}
return binary; }
void octal_hex(int n, char hex[])
{
int i=0,decimal=0, rem;
while (n!=0)
RESULT:
PROGRAM :
#include <stdio.h>
#include <conio.h>
void main()
{
char a[100];
int len,i,word=1;
clrscr();
printf("\nENTER A STRING: ");
gets(a);
len=strlen(a);
for(i=0;i<len;i++)
{
if(a[i]!=' ' && a[i+1]==' ')
word=word+1;
}
printf("\nTHERE ARE %d WORDS IN THE STRING",word);
getch();
}
Input
ENTER A STRING abc abcd abcde abc
Output
THERE ARE 4 WORDS IN THE STRING
RESULT:
PROGRAM
#include <stdio.h>
#include <conio.h>
void main()
{
char s[100];
int len,i;
clrscr();
printf("\nENTER A SENTENSE: ");
gets(s);
len=strlen(s);
printf("\n");
for(i=0;i<len;i++)
{
if((i==0 && s[i]>=97 && s[i]<=122) || (s[i-1]==32 && s[i]>=97 && s[i]<=122))
printf("%c",s[i]-32);
else
{
if(i!=0 && s[i-1]!=32 && s[i]>=65 && s[i]<=90)
printf("%c",s[i]+32);
else
printf("%c",s[i]);
}
}
getch();
}
Input
ENTER A SENTENSE c programming
Output
C Programming
RESULT :
PROGRAM :
#include <stdio.h>
void towers(int, char, char, char);
int main()
{
int num;
printf("Enter the number of disks : ");
scanf("%d", &num);
printf("The sequence of moves involved in the Tower of Hanoi are :\n");
towers(num, 'A', 'C', 'B');
return 0;
}
void towers(int num, char frompeg, char topeg, char auxpeg)
{
if (num == 1)
{
printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg);
return;
}
towers(num - 1, frompeg, auxpeg, topeg);
printf("\n Move disk %d from peg %c to peg %c", num, frompeg, topeg);
towers(num - 1, auxpeg, topeg, frompeg);
}
RESULT:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void sort(int m, int x[]);
void main()
{
int i,n;
int num[10];
printf("Enter upper limit value:\n");
scanf("%d",&n);
printf("Enter the values to sort\n");
for(i=0;i<n;i++)
scanf("%d",&num[i]);
sort(n,&num[0]);
printf("after sorting:\n");
for(i=0;i<n;i++)
printf("%4d",num[i]);
printf("\n");
getch();
}
void sort(int m,int x[])
{
int i,j,t;
for(i=1;i<=m-1;i++)
for(j=1;j<=m-i;j++)
if(x[j-1]>=x[j])
{
t=x[j-1];
x[j-1]=x[j];
x[j]=t;
}
}
Input
Enter the limit value:
5
Enter the values to sort
45 6 9 100 4
Output
After sorting:
4 6 9 45 100
RESULT:
PROGRAM
#include<stdio.h>
#include<dos.h>
struct employee
{
int NO;
char NAME[10];
int DESIGN_CODE;
int DAYS_WORKED;
}EMP[12]={
{1,"GANESH",1,25},
{2,"MAHESH",1,30},
{3,"SURESH",2,28},
{4,"KALPESH",2,26},
{5,"RAHUL",2,24},
{6,"SUBBU",2,25},
{7,"RAKESH",2,23},
{8,"ATUL",2,22},
{9,"DHARMESH",3,26},
{10,"AJAY",3,26},
{11,"ABDUL",3,27},
{12,"RASHMI",4,29}
};
void main()
{
int EMPNO;
void gen_payslip(int);
clrscr();
printf("ENTER THE EMPLOYEE NO TO GENERATE PAYSLIP : ");
scanf("%d",&EMPNO);
if(EMPNO>0 && EMPNO<13)
gen_payslip(EMPNO);
else
printf("\nYOU HAVE ENTERED WRONG EMP NO. !!");
getch();
}
void gen_payslip(int EMPNO)
{
struct date D;
[Link] 200
GROSS EARN. 10000 TOTAL DEDUCTION. 1200
RESULT:
PROGRAM:
#include <stdio.h>
int main()
{
/* Pointer of integer type, this can hold the
* address of a integer type variable.
*/
int *p;
int var = 10;
/* Assigning the address of variable var to the pointer
* p. The p can hold the address of var because var is
* an integer type variable.
*/
p= &var;
printf("Value of variable var is: %d", var);
printf("\nValue of variable var is: %d", *p);
printf("\nAddress of variable var is: %p", &var);
printf("\nAddress of variable var is: %p", p);
printf("\nAddress of pointer p is: %p", &p);
return 0;
}
Output:
Value of variable var is: 10
Value of variable var is: 10
Address of variable var is: 0x7fff5ed98c4c
Address of variable var is: 0x7fff5ed98c4c
Address of pointer p is: 0x7fff5ed98c50
PROGRAM:
#include <stdio.h>
int main() {
int data[5];
printf("Enter elements: ");
for (int i = 0; i < 5; ++i)
Output:
Enter elements: 1
2
3
5
4
You entered:
1
2
3
5
4
PROGRAM:
#include<stdio.h>
#include<conio.h>
int string_ln(char*);
void main() {
char str[20];
int length;
clrscr();
printf("\nEnter any string : ");
gets(str);
length = string_ln(str);
printf("The length of the given string %s is : %d", str, length);
getch();
}
int string_ln(char*p) /* p=&str[0] */
{
int count = 0;
while (*p != '\0') {
Output :
Enter the String : pritesh
Length of the given string pritesh is : 7
PROGRAM:
#include <stdio.h>
#define MAX_SIZE 100 // Maximum string size
int main()
{
char str1[MAX_SIZE], str2[MAX_SIZE];
char * s1 = str1;
char * s2 = str2;
// Inputting 2 strings from user
printf("Enter 1st string: ");
gets(str1);
printf("Enter 2nd string: ");
gets(str2);
// Moving till the end of str1
while(*(++s1));
// Coping str2 to str1
while(*(s1++) = *(s2++));
printf("Concatenated string: %s", str1);
return 0;
}
Output
Enter 1st string: Information
Enter 2nd string: Technology
Concatenated string : Information Technology
PROGRAM:
#include<stdio.h>
int main()
{
char string1[50],string2[50],*str1,*str2;
int i,equal = 0;
printf("Enter The First String: ");
scanf("%s",string1);
printf("Enter The Second String: ");
scanf("%s",string2);
str1 = string1;
str2 = string2;
while(*str1 == *str2)
{
if ( *str1 == '\0' || *str2 == '\0' )
break;
str1++;
str2++;
}
if( *str1 == '\0' && *str2 == '\0' )
printf("\n\nBoth Strings Are Equal.");
else
printf("\n\nBoth Strings Are Not Equal.");
}
Output:-
Enter the first string: Panimalar
enter the second string: Panimalar
Both string are Equal
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<conio.h>
/*low implies that position of pointer is within a word*/
#define low 1
PROGRAM:
#include <stdio.h>
int main()
{
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
printf("Enter the number of rows (between 1 and 100): ");
scanf("%d", &r);
printf("Enter the number of columns (between 1 and 100): ");
scanf("%d", &c);
printf("\nEnter elements of 1st matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j)
{
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", (*(a+i)+j);
}
printf("Enter elements of 2nd matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j)
{
printf("Enter element b%d%d: ", i + 1, j + 1);
scanf("%d", (*(b+i)+j);
}
// adding two matrices
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j)
{
*(*(sum+i)+j) = *(*(a+i)+j) + *(*(b+i)+j);
Output:
Enter the number of rows (between 1 and 100): 2
Enter the number of columns (between 1 and 100): 3
Enter elements of 1st matrix:
Enter element a11: 2
Enter element a12: 3
Enter element a13: 4
Enter element a21: 5
Enter element a22: 2
Enter element a23: 3
Enter elements of 2nd matrix:
Enter element b11: -4
Enter element b12: 5
Enter element b13: 3
Enter element b21: 5
Enter element b22: 6
Enter element b23: 3
Sum of two matrices:
-2 8 7
10 8 6
PROGRAM:
#include <stdio.h>
#define ROW 3
#define COL 3
Output
Enter elements in first matrix of size 3x3
231
256
268
PROGRAM:
#include <stdio.h>
#include <stdlib.h>
int multiplyNum(int , int); //function declaration or prototype
int(*fptr)(int,int);
int main()
{
int num1,num2,product; //variable declaration
fptr=multiplyNum;
printf("Enter the two number ");
scanf("%d %d",&num1,&num2);//taking two number as input from user
product=multiplyNum(num1,num2);//calling the function
//The product value (returned by the function) is stored in product variable.
printf("The product of these numbers :%d",product);
product=(*fptr)(num1,num2);
printf(“The products:%d”, product);
//display the product value
getch();
return 0;
}
int multiplyNum(int a, int b)//defining function based in declaration
{
OUTPUT
Enter the two numbers 12
23
The product of these numbers :276
RESULT:
PROGRAM:
#include<stdio.h>
struct student
{
char name[20];
int rollno;
int m1,m2,m3,m4,m5,total,intern;
};
void total(struct student s[3])
{
int i=0;
for(i=0;i<3;i++)
{
s[i].total=s[i].m1+s[i].m2+s[i].m3+s[i].m4+s[i].m5;
}
for(i=0;i<3;i++)
{
s[i].intern=((s[i].total)/5)*0.20;
}
for(i=0;i<3;i++)
{
printf(" %d\t %d",s[i].total,s[i].intern);
}
}
int main( )
{
int i,n;
struct student s[3];
printf("Enter name, roll no. and marks Below :: \n");
for(i=0; i<3; i++)
{
printf("\nEnter %d record :: \n",i+1);
printf("Enter Name :: ");
scanf("%s",s[i].name);
printf("Enter RollNo. :: ");
scanf("%d",&s[i].rollno);
printf("Enter marks");
scanf("%d%d%d%d%d",&s[i].m1,&s[i].m2,&s[i].m3,&s[i].m4,&s[i].m5);
}
Output:
Enter name, roll no. and marks Below ::
Enter 1 record ::
Enter Name :: ABC
Enter RollNo. :: 12
Ebter marks 100 100 100 100 100
Enter 2 record ::
Enter Name :: DEF
Enter RollNo. :: 13
Ebter marks 50 50 50 50 50
Enter 3 record ::
Enter Name :: HIJ
Enter RollNo. :: 80
Enter marks 80 80 80 80 80
Name RollNo Marks Internals
ABC 12 500 20
DEF 13 250 10
HIJ 80 400 16
RESULT:
PROGRAM:
#include <stdio.h>
#include <string.h>
// declaring structure
struct struct_example
{
int integer;
float decimal;
char name[20];
};
// declaring union
union union_example
{
int integer;
float decimal;
char name[20];
};
void main()
{
// creating variable for structure and initializing values difference six
struct struct_example stru ={5, 15, "John"};
// creating variable for union and initializing values
union union_example uni = {5, 15, "John"};
printf("data of structure:\n integer: %d\n decimal: %.2f\n name: %s\n", [Link],
[Link], [Link]);
printf("\ndata of union:\n integer: %d\n" "decimal: %.2f\n name: %s\n", [Link],
[Link], [Link]);
// difference five
printf("\nAccessing all members at a time:");
[Link] = 163;
[Link] = 75;
strcpy([Link], "John");
printf("\ndata of structure:\n integer: %d\n " "decimal: %f\n name: %s\n", [Link],
[Link], [Link]);
[Link] = 163;
[Link] = 75;
strcpy([Link], "John");
printf("\ndata of union:\n integeer: %d\n " "decimal: %f\n name: %s\n", [Link],
[Link], [Link]);
printf("\nAccessing one member at a time:");
RESULT:
PROGRAM:
#include <stdio.h>
#include <conio.h>
#include <string.h>
struct employee
{
int empid;
char name[20];
char desig[20];
};
void main()
{
struct employee emp1, emp2;
FILE *fd1, *fd2;
char str[20];
int id, eno, pos, size;
fd1 = fopen("[Link]", "a");
fseek(fd1, 0, 2);
size = ftell(fd1);
id = 100 + size / sizeof(emp1);
printf("\n Enter employee details \n");
while(1)
{
[Link] = id++;
printf("\n Employee Id : %d", [Link]);
printf("\n Enter Name (\"xxx\" to quit) : "); scanf("%s",[Link]);
if (strcmp([Link],"xxx") == 0)
break;
printf("Enter Designation : ");
scanf("%s", [Link]);
fwrite (&emp1, sizeof(emp1), 1, fd1);
}
size = ftell(fd1);
fclose(fd1);
fd2 = fopen("[Link]", "r");
printf("\n Enter Employee id : ");
scanf("%d", &eno);
pos = (eno - 100) * sizeof(emp2);
RESULT:
Program:
#include<stdio.h>
#include<conio.h>
void creation();
void deposit();
void withdraw();
void lowbal();
int a=0,i = 1001;
struct bank
{
int no;
char name[20];
float bal;
float dep;
}s[100];
int main()
{
int ch;
do
{
printf("\n*********************");
printf("\n BANKING ");
printf("\n*********************");
printf("\n1. Create New Account");
printf("\n2. Cash Deposit ");
printf("\n3. Cash Withdraw");
printf("\n4. Low Balance Enquiry");
printf("\n5. Exit");
printf("\nEnter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1: creation();
break;
case 2: deposit();
break;
case 3: withdraw();
break;
case 4: lowbal();
RESULT:
PROGRAM;
#include<stdio.h>
#include<conio.h>
int first=5,second=5,third=5;
struct node
{
int ticketno;
int phoneno;
char name[100];
char address[100];
}s[15];
int i=0;
void booking()
{
printf("enter your details");
printf("\nname:");
scanf("%s",s[i].name);
printf("\nphonenumber:");
scanf("%d",&s[i].phoneno);
printf("\naddress:");
scanf("%s",s[i].address);
printf("\nticketnumber only 1- 10:");
scanf("%d",&s[i].ticketno);
i++;
}
void availability()
{
int c;
printf("availability cheking");
printf("\[Link] class\[Link] class\[Link] class\n");
printf("enter the option");
scanf("%d",&c);
switch(c)
{
case 1: if(first>0)
{
printf("seat available\n");
first--;
}
Ticket No Name
5 Arun
6 Varun
[Link]
[Link] cheking
[Link]
[Link]
[Link]
Enter your option:5