Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Get the number of rows of pattern from user and Write a C program to print the pattern

1. Pattern:
row=4
*
**
***
****
2. Pattern:
row=5
1
12
123
1234
12345
3. Pattern:
P
PR
PRE
PRES
PRESS
4. Pattern:
row=3
***
**
*
5. Pattern:
row=4
1234
123
12
1
6. Chef is looking to buy a TV and has shortlisted two models. The first one costs A rupees,
while the second one costs B rupees. Since there is a huge sale coming up on Chefzon,
Chef can get a flat discount of x rupees on the first TV, and a flat discount of y rupees on
the second one. Help Chef determine which of the two TVs would be cheaper to buy
during the sale.
print a single line containing the string First if the first TV is cheaper to buy
with discount, or Second if the second TV is cheaper to buy with discount. If both of
them cost the same after discount, print Any .
7. There are N children and the Chef wants to give them 1 candy each. Chef already has x
candies with him. To buy the rest, he visits a candy shop. In the shop, packets containing
exactly 4 candies are available. Determine the minimum number of candy packets Chef
must buy so that he is able to give 1 candy to each of the children.
Input Format
The first and only line of each test case contains two integers and — the number of
children and the number of candies Chef already has.
Output Format
The minimum number of candy packets Chef must buy so that he is able to give 1 candy
to each of the children.

8. Each pizza consists of 4 slices. There are N friends and each friend needs exactly x
slices. Find the minimum number of pizzas they should order to satisfy their appetite.
Input Format
Each test case consists of two integers, the number of friends and the number of
slices each friend wants respectively.
Output Format
output the minimum number of pizzas required.
9. While Alice was drinking sugarcane juice, she started wondering about the following
facts:
The juicer sells each glass of sugarcane juice for 50 coins.
He spends 20% of his total income on buying sugarcane.
He spends 20% of his total income on buying salt and mint leaves.
He spends 30% of his total income on shop rent.
Alice wonders, what is the juicer's profit (in coins) when he sells x glasses of sugarcane
juice?
Input Format
The first and only line of each test case contains an integer which is number of glasses
Output Format
output on a new line the juicer's profit when he sells given glasses of juice.
10. Get 10 numbers from user and print the difference between second largest number and
first largest number
11. Get 10 numbers from user and print the difference between largest number and smallest
number
12. Get 10 numbers from user and print the difference between largest even number and
smallest odd number in given elements
13. Get 10 elements from user and print the difference between the sum of odd numbers
and sum of even numbers
14. Write a program to find whether the given number is a prime number and if it is a prime
number print the sum of its digits.
15. Write a program to find whether the given number is a prime number and if it is not a
prime number print the number of its digits.
16. Write a program to print the factors and factorial of a given number
17. Get Date of birth from a user in the form of DDMMYY and generate a pin number which
is a single integer containing all the even numbers in given date of birth
Sample Input:
200896
Sample Output:
286
18. Write a C program to get two, two-dimensional array from the user and perform
multiplication of matrices and print the result Sample Input:

Matrices 1

12

34

Matrices 2

13

24

Output:

5 11

11 25

19. A shopping website is announcing offer for the students who are eligible to vote and whose age
is a multiple of 3. Get age from the user and print “YES” if the student is eligible for offer and
“NO” if the student is not eligible for offer
Sample Input:
Number = 21
Sample Output:
YES
20. Write a program in C to calculate and print the electricity bill of a given customer. The customer
ID, name, and unit consumed by the user should be captured from the keyboard to display the
total amount to be paid to the customer. The charge are as follow :

Unit Charge/unit

upto 199 @1.20

200 and above but less than 400 @1.50

400 and above but less than 600 @1.80

600 and above @2.00

If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill

should be of Rs. 100/- Test Data :


1001

James
800
Expected Output :
Customer IDNO :1001 Customer Name :James unit Consumed :800
Amount Charges @Rs. 2.00 per unit : 1600.00
Surchage Amount : 240.00
Net Amount Paid By the Customer : 1840.00
21. Write a program to get an array of 10 integers from the users and display the sorted array
Sample Input:
5 8 1 2 6 7 9 3 4 11
1 2 3 4 5 6 7 8 9 11
22. There are n students in a class, given, age and name of the students, write a program to
find the oldest person in the class
23. Write a program to print the multiplication table for a given n number up to 10 multiples
24. Write a C program to determine eligibility for admission to a professional course based
on the following criteria:
25. Eligibility Criteria : Marks in Maths >=65 and Marks in Phy >=55 and Marks in
Chem>=50 and Total in all three subject >=190 or Total in Maths and Physics >=140
INPUT:
Input the marks obtained in Physics :65
Input the marks obtained in Chemistry :51 Input the
marks obtained in Mathematics :72 Expected
Output :
The candidate is not eligible for admission.
26. Write a C program to read temperature in centigrade and display a suitable message
according to the temperature state below:
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot Temp
>=40 then Its Very Hot Test Data
:
42
Expected Output :
Its very hot.
27. Given an array of size 10, find and print the number of even numbers in the given array
Sample Input:
Enter the array : 2 1 5 3 4 6 7 8 9 10
Sample Output:
Even number = 5
28. Write a C program to check whether a character is an alphabet, digit or special
character.
Test Data :
@
Expected Output :
This is a special character.
29. Write a C program to check whether an alphabet is a vowel or a consonant.
Test Data :
k
Expected Output :
The alphabet is a consonant
30. Sketch a C program to find whether the given number is BEST number. A number whose digits
is 5 is called a BEST number. Print “YES” if the number is best number and print “NO”
otherwise
Sample Input:
Number = 1234
Sample Output:
NO

31. Write a C program to remove the duplicate characters in a given string and print the
string without duplicates

Sample Input:

enter a string: MALAYALAM

Sample Output:

Output: MALY

32. Given integer array with size M , containing odd and even numbers . Print the difference
between smallest odd number and largest odd number

Test Case
M: 6

12 43 54 67 87 89

Output:

The difference is 46

33. Write a program in C to accept a grade and declare the equivalent description :

Grade Description

E Excellent

V Very Good

G Good

A Average

F Fail

Test Data :

Input the grade :A

Expected Output :

You have chosen : Average

34. Sketch a code to check whether the given password is valid or not.
A valid password must satisfy the following conditions
1. Length must be greater than 8
2. Must contain a lower case alphabet
3. Must contain a uppercase alphabet
4. Must contain a digit and a special character
If the given password is valid, print “Valid” else print “Invalid”
Sample Input 1:
Password = Abcd1234@
Sample Output 1:
Password is Valid
Sample Input 2:
Password = abcd1234@
Sample Output 2:
Password is Invalid
35. Chef wants to become fit for which he decided to walk to the office and return home by
walking. It is known that Chef's office is X km away from his home. If his office is open
on 5 days in a week, find the number of kilometers Chef travels through office trips in a
week. And print fit is he walks more than 10km and not fit otherwise.
36. Alice likes numbers which are even, and are a multiple of 7. Bob likes numbers which
are odd, and are a multiple of 9. Given A is the number, If Alice likes A, Alice takes home
the number. If Bob likes A, Bob takes home the number. If both Alice and Bob don't like
the number, Charlie takes it home. Given A, find who takes it home.
37. Note: There is no integer A such that both Alice and Bob like it.
38. Given 3 numbers N , L and R. Print 'yes' if N is between L and R else print 'no'. Sample
Testcase :
INPUT
3
26
OUTPUT
Yes
39. Write a program to convert the given string1 to uppercase and string2 to lowercase without
using in-built function
Sample Input:
String 1 = Hello
String 2 = WORLD
Sample Output:
HELLO
world
40. Kabali is a brave warrior who with his group of young ninjas moves from one place to
another to fight against his opponents. Before Fighting he just calculates one thing, the
difference between his ninja number and the opponent's ninja number and print yes if he
could fight with the opponent and no otherwise. The input contains two numbers in every
line. These two numbers in each line denotes the number ninjas in Kabali's clan and his
opponent's clan . print the absolute difference of number of ninjas between Kabali's clan
and his opponent's clan. Each output should be in seperate line.
Sample Testcase :
INPUT
100 200
OUTPUT
100, Yes
41. Write a C program to find the length of the string without using in-built function
42. Get a 3×3 matrix from user and write a program to transpose the matrix
43. Write a program to check whether the string is palindrome or not without using strrev()
in built function
44. All String programs without using library function
45. Get two names from the user and compare the length of the two names without
using string library functions, if the length is same, print the reverse of first string
as output,if the length is not same, print the reverse of second string as output

Sample Input:

1st string : rama

2nd string : ramya

Expected Output : aymar

46. Solve the below pattern


Row=5
*
**
***
****
*****
47. Solve the below pattern
Row=4
1
12
123
1234
48. Chef started watching a movie that ran for a total of x minutes. Chef has decided to
watch the first y minutes of the movie at twice the usual speed as he was warned by his
friends that the movie gets interesting only after the first y minutes. How long will Chef
spend watching the movie in total?
Note: It is guaranteed that y is even.
49. Chef has started working at the candy store. The store has 100 chocolates in total.
Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee.
However, if the Chef exceeds his daily goal, he gets 2 rupees per chocolate for each
extra chocolate. If the Chef sells Y chocolates in a day, find the total amount he made.
50. Chef has X 5 rupee coins and Y 10 rupee coins. Chef goes to a shop to buy chocolates
for Chefina where each chocolate costs Z rupees. Find the maximum number of
chocolates that Chef can buy for Chefina.

You might also like