View Code
View Code
assignment-p-02.c
Write a C program that includes a user-defined function named isArmstrong with the signature int isArmstrong(int num);. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153
View Code
assignment-p-03.c
Write a C program that includes a user-defined function named isPerfect with the signature int isPerfect(int num);. A perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself. For example, 28 is a perfect number because the sum of its divisors (1, 2, 4, 7, 14) equals 28.
View Code
View Code
View Code
View Code
assignment-p-07.c
Write a C program that includes a user-defined function named binarySearch with the signature int binarySearch(int arr[], int size, int target);. The function should perform a binary search on a sorted array of integers and return the index of the target element if found, and -1 otherwise.
View Code
View Code
View Code
View Code
assignment-p-11.c
Write a C program that defines a structure Student containing the attributes rollNumber, name, and marks. Include a user-defined function named displayStudent with the signature void displayStudent(struct Student s);. The function should display the details of a student.
View Code
View Code
View Code
assignment-p-13.c
Write a C program that accepts a string as a command line argument and includes a user- defined function named isPalindrome with the signature int isPalindrome(char str[]);. The function should check if the given string is a palindrome and return 1 if it is, and 0 otherwise.
View Code
View Code
assignment-p-15.c
Write a C program that reads a sequence of integers from a file named 'input.txt'. This program should segregate the odd numbers from the even numbers and store the odd numbers in a new file named 'ODDFile.txt' while storing the even numbers in another file named 'EVENFile.txt'
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
assignment-s-14.c
Write a menu-driven program to perform the following string operations: a. Show address of each character b. Concatenate two strings without using strcat() c. Concatenate two strings using strcat() d. Compare two strings e. Find string length using pointers f. Convert lowercase to uppercase g. Convert uppercase to lowercase h. Count number of vowels i. Reverse the string
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
sudipto1.c
A smart home security controller monitors the state of several sensors to decide what action to take. Each second, the system reads data from sensors that can either be active or inactive. Based on the current state of all sensors, the controller must perform exactly one action, such as activating a warning, checking a specific zone, or declaring an intrusion. Write a C program that reads the sensor states as input and prints the corresponding system action. -- Conditions: 1. You must determine exactly one action for every possible combination of sensor states. 2. You are not allowed to use any conditional statements (if, else if, else, or the ternary operator?). 3. You are not allowed to use logical operators. 4. You must use a single switch statement to control the program's behaviour. 5. Loops may only be used for reading input, not for making decisions. 6. The program should handle all possible combinations of the sensors' active/inactive states and print the appropriate response each time. -- Example (for understanding): If all sensors are inactive, the system should remain idle. If some sensors are active, the system should issue warnings or alerts based on the situation. If all sensors are active, the system should declare a confirmed intrusion.
View Code
sudiptoown01.c
A smart home security controller monitors the state of several sensors to decide what action to take. Each second, the system reads data from sensors that are either an active or inactive. Based on the current state of all sensors, the controller must perform exactly one action, such as activating a warning, checking a specific zone, or declaring an intrusion. Write a C program that reads the sensor status as input and prints the corresponding system action. Hints: 1. The most determinative action wins for every possible combination of sensor states. 2. You are not allowed to use any conditional statements (if, else if, else, or the ternary operator?). 3. You are not allowed to use logical operators. 4. You must use a single switch statement to control the program's behavior. 5. The program should handle all possible combinations of the sensors' active/inactive states and print the appropriate response each time. 6. All sensors are inactive, the system should remain idle. 7. If some sensors are active, the system should issue warnings or alerts based on the situation. 8. If all sensors are active, the system should declare a confirmed intrusion. Solution: We can solve this problem simply by assigning each case its own distinct integer. There are 2 possibilities for a sensor and therefore there are 2^4 = 16 cases. Using arrays we can assign each case its own index value and print it as per the encoded binary integer.
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
IP-16.c
Write a C program that includes a user-defined function named isArmstrong with the signature int isArmstrong(int num);. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153
View Code
IP-17.c
Write a C program that includes a user-defined function named isPerfect with the signature int isPerfect(int num);. A perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself. For example, 28 is a perfect number because the sum of its divisors (1, 2, 4, 7, 14) equals 28.
View Code
View Code
IP-19.c
Write a C program that includes a user-defined function named binarySearch with the signature int binarySearch(int arr[], int size, int target);. The function should perform a binary search on a sorted array of integers and return the index of the target element if found, and -1 otherwise.
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
luc006.c
Write a program to receive values of latitude (L1, L2) and longitude (G1, G2), in degrees, of two places on the earth and output the distance (D) between them in nautical miles. The formula for distance in nautical miles is : D = 3963 cos^-1(sin L1 sin L2 + cos L1 cos L2 * cos(G2 - G1))
View Code
luc007.c
Wind-chill factor is the felt air temperature on exposed skin due to wind. The wind-chill temperature is always lower than the air temperature, and is calculated as per the following formula. wcf = 35.74 + 0.6215t + (0.4275t - 35.75) * v^0.16 Where t is temperature and v is wind velocity. Write a program to receive values of t and v and calcualate wind-chill factor (wcf).
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
luc020.c
In digital world colors are specified in Red-Green-Blue (RGB) format, with values of R, G, B varying on an integer scale from 0 to 255. In print publishing the colors are mentioned in Cyan-Magenta-Yellow-Black (CMYK) format, with values of C, M, Y, and K varying on a real scale from 0.0 to 1.0. Write a program that converts RGB color to CMYK color as per the following formulae: White = Max(Red/255, Green/255, Blue/255) Cyan = (White-Red/255) / White Magenta = (White-Green/255) / White Yellow = (White-Blue/255) / White Black = 1 - White Note that if the RGB values are all 0, then the CMY values are all 0 and the K value is 1.
View Code
luc021.c
A certain grade of steel is graded according to the following conditions: (i) Hardness must be greater than 50 (ii) Carbon content must be less than 0.7 (iii) Tensile strength must be greater than 5600 The grades are as follows: Grade is 10 if all three conditions are met Grade is 9 if conditions (i) and (ii) are met Grade is 8 if conditions (ii) and (iii) are met Grade is 7 if conditions (i) and (iii) are met Grade is 6 if only one condition is met Grade is 5 if none of the conditions are met Write a program, which will require the user to give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.
View Code
luc022.c
The Body Mass Index (BMI) is defined as ratio of weight of the person (in Kilograms) to square of the height (in meters). Write a program that receives weight and height, calculate the BMI, and reports the BMI catagory as per the following table. BMI Catagory BMI Starvation < 15 Anorexic 15.1 to 17.5 Underweight 17.6 to 18.5 Ideal 18.6 to 24.9 Overweight 25 to 25.9 Obese 30 to 39.9 Morbidly Obese >= 40
View Code
View Code
View Code
View Code
= 25000 && sal <= 40000) printf("Manager\n"); else if(sal >= 15000 && sal < 25000) printf("Accountant\n"); else printf("Clerk\n"); return 0; }" loading="lazy" class="w-full h-auto opacity-90 group-hover:opacity-100 transition-opacity">
View Code
luc027.c
= 25000 && sal <= 40000) printf("Manager\n"); else if(sal >= 15000 && sal < 25000) printf("Accountant\n"); else printf("Clerk\n"); return 0; }">Rewrite the folowing program using conditional operations #include int main() { float sal; printf("Enter the salary"); scanf("%f", &sal); if(sal >= 25000 && sal <= 40000) printf("Manager\n"); else if(sal >= 15000 && sal < 25000) printf("Accountant\n"); else printf("Clerk\n"); return 0; }
View Code
View Code
View Code
luc030.c
Write a program for a matchstick game being played between the computer and a user. Your program should ensure that the computer always wins. Rules for the game are as follows : - There are 21 matchsticks. - The computer asks the player to pick 1, 2, 3, or 4 matchsticks. - After the person picks, the computer does its picking. - Whoever is forced to pick up the last matchstick loses the game.
View Code
View Code
View Code
View Code
View Code
View Code
luc035.c
According to a study, the approximate level of intelligence of a person can be calculated using the following formula. i = 2 + (y + 0.5x) write a program that will produce a table of values of i, y and x, where y varies from 1 to 6, and, for each value of y, x varies from 5.5 to 12.5 in steps of 0.5
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
luc043.c
Write a program to find the grace marks for a student using switch. The user should enter the class obtained by the student and the number of subjects he has failed in. Use the following logic. - If the student gets first class and he fails in more than 3 subjects, he does not get any grace, Otherwise, he gets a grace of 5 marks per subject. - If the student gets second class and he fails in more than 2 subjects, he does not get any grace. Otherwise, he gets a grace of 4 marks per subject. - If the student gets third class and he fails in more than 1 subject, then he does not get any grace. Otherwise, he gets a grace of 5 marks.
View Code
View Code
View Code
View Code
View Code
luc048.c
Define a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are A(x1, y1), B(x2, y2), and C(x3, y3). Use these functions to develop a function which returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise returns a value 0. Would you get any advantage if you develop these functions to work on call by reference principle?
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
lucproblem003.c
If a character is entered through the keyboard, Write a program to determine whether the character is a capital letter, a small case letter, a digit or a speacial symbol. The following table shows the range of ASCII values for various characters : Characters ASCII Values A - Z 65 - 90 a - z 97 - 122 0 - 9 48 - 57 special symbols 0 - 47, 58 - 64, 91 - 96, 123 - 127
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
lucproblem011.c
Write a menu driven program which has following options : 1. Factorial of a number 2. Prime or not 3. Odd or even 4. Exit Once a menu item is selected the appropriate action should be taken and once this action is finished, the menu should reappear. Unless the user selects the 'Exit' option the program should continue work.
View Code
View Code
View Code
View Code
View Code
View Code
lucproblem016.c
Figure 9.4 shows three memory locations and values stored in them. Write a program to declare variables that implement the relationship shown. How will you print the values and addresses shown in the figure? On which machine the program should be executed to get such addresses? Figure 9.4: value: 3.14, memory_address: 7fff9489c79c value: 7fff9489c7a0, memory_address: 7fff4fd134b8 value: 7fff9489c79c, memory_address: 7fff9489c7a0
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
P025.c
WAP to input the electricity unit consumed and calculate the total bill amount according to the given condition : for 1st 50 unit Rs. 0.50 per unit next 100 unit Rs. 0.75 per unit next 100 unit Rs. 1.20 per unit above 250 unit Rs. 1.50 per unit And additional charge of 20 percent is added to the bill.
View Code
View Code
P027.c
Purchase Discount on Discount on Amount Laptop Desktop -------- ----------- ----------- Upto 20k 3.0% 5.0% 20001 - 50k 5.0% 7.5% 50001 - 75k 7.5% 10.5% more than 75k 10.0% 15.0% WAP to input amount of purchase and type of purchase ('L' : laptop, 'D' : desktop) and display the discount amount and the discounted price (Net Amount).
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
View Code
No matching snippets found.