C Assignment
C Assignment
Table of Contents
Basics of C
Sr. No. Assignment Question
Write a pseudo code and draw a flowchart to accept a value in degrees Celsius
1
and to convert it into Fahrenheit. [Hint: C/5 = (F-32)/9].
Column A Column B
abc Double
1. int a=4^4
2. int a=23.34
3. a = 10
b = a + a++
4. a=-5
b=-a
2
Write a C program that accepts the salary and age from the user and displays the
same on the screen as output.
HRA : $150
TA : $120
Others : $450
Tax cuts – a) PF :14% of Basic salary and b) IT: 15% of Basic salary
2
Write a program which will take the input as a floating (real) number. This number
represents the centimeters. Print out the equivalent number of feet(floating, 1
decimal) and inches (floating, 1 decimal), with feet and the inches given to an
accuracy of one decimal place.
3
Find the value of iResult for the following assignment statements:
int iResult, a = 10, b = 8, c = 6, d = 5, e =2;
iResult = a - b - c - d;
iResult = a - b + c - d;
iResult = a + b / c / d;
iResult = a + b / c * d;
iResult = a / b * c * d;
iResult = a % b / c * d;
iResult = a % b % c % d;
iResult = a - (b - c) - d;
iResult = (a - (b - c)) - d;
iResult = a - ((b - c) - d);
iResult = a % (b % c) * d * e;
iResult = a + (b - c) * d - e;
iResult = (a + b) * c + d * e;
iResult = (a + b) * (c / d) % e;
Print out the float variable dump using two decimal places
To read a decimal value from the keyboard, into the integer variable sum
#include <stdio.h>
void main()
{
int breadth;
float length, height;
scanf(“%d%f%6.2f”,breadth,&length,height);
printf(“%d %f %e”,&breadth, length, height);
}
4 Write a program which takes name, basic , daper ( ie, percentage of D.A), bonper
(ie, percentage bonus) and loandet ( loan amount to be debited) for an employee.
Calculate the salary using the following relation:
Calculate salary and then print the result under the following headings.
(Salary to be printed to the nearest dollar.)
Condition
Sr. No. Assignment Question
1
Write a program that accepts two numbers a and b and checks whether or not a is
divisible by b.
2
Write a program to accept 2 numbers and tell whether the product of the two
numbers is equal to or greater than 1000.
3
Write a program to accept 2 numbers. Calculate the difference between the two
values.
If the difference is equal to any of the values entered, then display the following
message:
If the difference is not equal to any of the values entered, display the following
message:
A 300
B 250
Others 100
Calculate the salary at the end of the month. (Accept Salary and Grade from the user)
5
Write a program to evaluate the Grade of a student for the following constraints:
Condition (Lab)
Sr. No. Assignment Question
1 Declare two variables x and y. Assign values to these variables. Number x should
be printed only if it is less than 2000 or greater than 3000, and number y should
be printed only if it is between 100 and 500.
2 Write a program to show your computer’s capabilities. The user types in a letter of
the alphabet and your program should display the corresponding language or
package available. Some sample input and output is given below :
Input Output
A or a Ada
B or b Basic
C or c Cobol
D or d dBase III
f or F Fortran
p or P Pascal
V or V Visual C++
Using the ‘switch’ statement to choose and display the appropriate message. Use
the default label to display a message if the input does not match any of the
above letters.
Loop
*******
******
*****
****
***
**
*
Loop (Lab)
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 67
1 2 3 4 5 678
1 2 3 4 5 6789
Ar rays
Sr. No. Assignment Question
1 Write a program to arrange the following names in alphabetical order.
George
Albert
Tina
Xavier
Roger
Tim
William
3 Write a program that accepts the following numbers in an array and reverses the
array.
34
45
56
67
89
Ar rays (Lab)
Sr. No. Assignment Question
1 Write a C program to find the minimum and the maximum value in an array.
2 Write a C program to count the number of vowels and the number of consonants
in a word.
Pointer s
Sr. No. Assignment Question
1 Write a program to accept a string and find out if it is a palindrome.
2 Write a program using pointer to strings that accepts the name of an animal and a
bird and returns the names in plural.
Pointer s (Lab)
Sr. No. Assignment Question
1 Write a C program to find the minimum and the maximum value in an array.
2 Write a C program to count the number of vowels and the number of consonants
in a word.
Functions (Lab)
Sr. No. Assignment Question
1 Write a C program to find the area and perimeter of a circle.
Strings
Sr. No. Assignment Question
1 Write a program that accepts two strings. The program should determine whether
the first string occurs at the end of the second string.
2 Write a program that accepts an array of integers and displays the average. Use a
function to calculate the average.
Strings (Lab)
Sr. No. Assignment Question
1 Write a C Program to accept 5 names and a prefix. Insert the prefix at the
beginning of each name in the array. Display the modified names.
2 Write a C Program to accept the average yearly temperature of the past five
years, for five cities. Display the maximum and minimum temperature for each
city. Use functions to determine the maximum and minimum temperatures.
2 Write a C program to store employee details in a structure array. The data should
include employee ID, name, salary, and date of joining. The date of joining should
be stored in a structure. The program should perform the following operations
based on a menu selection:
<= 2000 15 %
>5000 No increase
File Handling
Sr. No. Assignment Question
1 Write a program that accepts data into a file and prints it in reverse order.
2 Write a program that transfers data from one file to another, excluding all the
vowels (a, e, i, o, u). Exclude vowels in both upper and lower case. Display the
contents of the new file.