Posts

Showing posts with the label inlab

INLAB-10

Image
INLAB-10        PROGRAM: #include<stdio.h> int main() {        char UGC[13];     scanf("%s",&UGC);     UGC[12]=' ';     UGC[13]=' ';     int sum = 0;     for(int i = 0;i<11;i+=2)         sum += (UGC[i] - '0');     sum *= 3;     for(int i = 1;i<11;i+=2)         sum += (UGC[i] - '0');     if ((UGC[11] == '0') && ((sum%10)==0))         printf("Validated");     else if ((UGC[11]-'0') == (10-(sum%10)))         printf("Validated");     else if(UGC[12]==' ' || UGC[13]!=' ')          printf("Cannot be processed");     else         prin...

INLAB-9

Image
INLAB-9      Print the Appreciation for the student.       Program: #include<stdio.h> int main() {  int gr, a, s;  scanf("%d%d%d", &gr, &a, &s);  if (gr >= 3 && a >= 90 && s >= 2)  printf("Excellent");  else if (gr >= 3 && a >= 90)  printf("Very good");  else if (gr >= 3 && s >= 2)  printf("Good"); }

INLAB-8

INLAB-8 In FFCS students portal, the Register number, name, age, gender, address, phone number, hobby, blood group are stored. Assume that the details are present in a file named as ‘ffcs.csv’ and each field of a record are separated by a ‘,’. Write an algorithm to achieve the following and implement it using functions in Python: a) Read and print the content of the file b) Get a new record with the fields mentioned in order and append the file c) Get a new record with the fields mentioned in order and append to file if the record is new and do nothing otherwise. Register number shall be used for checking if a record is new. d) Find the number of male football players from Kerala e) List the name and phone numbers of girls from Tamilnadu having A+ blood group Write functions for the purpose of items (a) to (e) and call those functions defined in the order from (a) to (e). Input Format For items (b) and (c), read a record from the user. Details of each student are given in the o...

INLAB-7

INLAB-7 Q. In a small village library, books are lended to the members for a period of one week. Details such as name of the book, author, date of purchase, accession number and availability status are stored for each book. Given the details of the 'n' books sorted by the accession number of book and an accession number to search, develop an algorithm and write the Python code to perform binary search in the given data. Print 'Found' or 'Not Found' appropriately. Input Format First line contains the number of books in the library, n Next n*5 lines contains the details of the book in the following order: name of the book author of the book date of purchase of the book accession number of the book availability status of the book Next line contains the accession number of book to be searched 'n' Output Format Print Found or Not Found INPUT: First line contains the number of books in the library, n Next n*5 lines contain...

INLAB 6

IN-LAB 6 Q.Given ‘n’ integers, write an algorithm and the subsequent Python code to print all numbers that are sum-equivalent to the first number. Two numbers  ‘m’ and ‘n’ are said to be sum-equivalent if  ‘m’ and ‘n’ have the same number of digits and the sum of the digits in ‘m’ and ‘n’ are equal.  12381 is sum-equivalent to 10545. Here both the numbers are five digit numbers. Sum of the digits in 12381 is 1+2+3+8+1=15. Similarly the sum of the digits in 10545 is 15. Write a function to check whether two numbers are sum-equivalent or not. If none of the numbers are sum-equivalent then print ‘No sum-equivalent’. Input Format First line contains the number of elements, n Next ‘n’ line contains the numbers Output Format Print first number in the first line Next few lines contain the numbers that are sum-equivalent to first number. If the none of the numbers are sum-equivalent , then Print “No sum-equivalent” Input: the number of elements ...

Practice Problem 6- Heterophic Number

Practice Problem 6 Heterophic Number: Given ‘n’ integers, write an algorithm and the subsequent Python code to print all numbers that are heterophic to the first number. Two numbers with non-distinct (numbers in which digits get repeated) digits are said to be heterophic if they have the same number of digits in it and the sets of positions having the same digits contain only odd positions in one number and the sets of positions having the same digits, contain only even positions, in the other number. Positions of digits are numbered from left to right starting from 1. For example: 12161 is oddophic to 76968 . Both the numbers are of length five. In 12161, positions 1, 3 and 5 have the same digit 1. Hence the set of positions having the same digit are {1,3,5}. Similarly , for the number 76968, the set of positions having the same digit is {2,4}. In 12161,the sets of positions having the same digit contains only odd positions and in 76968, the sets of positions having the s...