Sei sulla pagina 1di 1

Controlled copy Cognizant In-Campus Training Programme Problem Solving and C Programming Lab List 2 Write an algorithm and

d draw a flow chart for the following problems. Also convert the algorithms into C Programming Language code and test the program. 1. Write a program that can input student total credits in a semester and compute letter grades based on the credits (our exam pattern) & output a letter grade distribution, class grade point average. 2. Write a program to calculate the total cost of the vehicle by adding basic cost with excise duty 15%, sales tax 10%, octroi 5 % and Road Tax 1 %. Input the Basic cost. 3. Write a program to read a sequence of integers and to display the integers that appear one or more times in the input sequence. For example, if the input sequence is 617, 201, 450, 201, then 201 must appear just once in the output. Enhance the above program such that it counts the number of times an element appears in a list. 4. Using any C Language, write a program to implement the following pseudo code: loop copy characters up to /*; throw away the characters until */ is seen; end; Test the above program for all possible cases (including nested comments) 5. Write a complete C program which will read integers and display the average of the numbers in the input which are between 40 and 80 (inclusive). A negative value in the input marks the end of the input. Example: If the input is 29 35 65 49 38 79 93 80 28 29 58 -7 the output should be 66.2 since (65+49+79+80+58)/5=66.2 6. Write a program that reads the taxable income of a taxpayer and lists the taxable input and the taxes. Amounts Tax Calculation Over but not over 0 10,690 0 10,690 37,475 865.37 + 3% of amount over 10,690 37,475 56,783 1708.45 + 7 % of amount over 37,475 56,783 74,750 3007.73 + 13% of amount over 56,783 74,750 --------5365.28 + 17% of amount over 74,750 Inputs: The program should prompt for the following Employee First Name : Character string of 25 characters Employee Last Name : Character string of 25 characters Employee ID : 9 digits Taxable Income : real number Marital status : character (M/S) Display an appropriate error message and re-prompt for the invalid data. Output : Name :Last, First Taxable Income :xx,xxx,xxx.xx Marital Status :Married / Single Tax :xx,xxx,xxx.xx The program will prompt the user to Continue Y or N. If the response is N the program will terminate. If the response is Y the program will repeat the user prompts and calculate the taxes. 7. Find 4 digit numbers ABCD, where AB is a perfect square, CD is a perfect square and ABCD is itself a perfect square.

Copyright Cognizant Academy All Rights Reserved

Potrebbero piacerti anche