Executable C programs

Question 1:

A war game is conducted between two countries A and B. Country A at its Air Force Base in Rimnicu Vilcea has some Rockwell B-1 Lancer Heavy Bombers and some Mitsubishi F-3 Fighters. Since bombers are comparatively slow and are not easily maneuverable each bomber should be accompanied by at least a squadron of three fighters. Rimnicu Vilcea Air Force Base has over 5000 liter of fuel, 200 pilots, 4 wing commanders and an Air Marshal. Moreover, enemy airfields of Sibiu and Fagaras are within reach of the bombers from Rimnicu Vilcea. So, airfields of Rimnicu Vilcea should remain operational, it is vital for winning the war. According to Air Marshal Prince Constantin Cantacuzino, “we need at least 10 fighters in the air to defend against their first wave of attack”.

Assume that both Rockwell B-1 Lancer Heavy Bomber and Mitsubishi F-3 Fighter can be operated by a single pilot. Assume that all the pilots, wing commanders and Air Marshal are competent pilots but due tactical reasons Air Marshals is not allowed to participate in any flying missions.

Can you write a C program to read the number of fighters and bombers from the user and identify the maximum numbers Rockwell B-1 Heavy Bombers that can be sent on a bombing run at a time by country A so that airfields of Rimnicu Vilcea won’t be vulnerable to air raids from Country B’s bombers?

You have input the number of fighter first followed by the number of bombers.

Sample Input/Output


0 0Output


Question 2:

Write a C program to read an integer from the user and check whether it is a palindrome or not. The program should output the number and say whether it is a palindrome or not.

After printing it, can you reverse the order of digits in the number the user has just entered. E.g. 1234 should become 4321. Display the result on the screen in an easily understandable format.

Sample Input/OutputInput:




Not Palindrome3411

Question 3:

Write a C program to read a string from the user and check whether the string is a pangram or not.

A pangram is a sentence containing every letter in the English alphabet. If the sentence is not a pangram print the alphabets that are missing that will make the sentence a pangram.

For example, the sentence, “The quick brown fox jumps over the lazy dog” is a pangram as it contains all the characters from ‘a’ to ‘z’. The sentence “The quick brown fox jumps over the dog” is not a pangram because the characters ‘a’, ‘l’, ‘z’ and ‘y’ are missing.

Sample Input/OutputInput:

The five boxing wizards jump quicklyOutput




Not Pangram

a y

Question 4:

Write a C program to generate prime numbers which has two equidistant prime numbers from it within a given range.

For example, 5 is one such number because we have two prime numbers 3 and 7 both of which are equidistant from 5. The distance in this case would be 2.

Can you generate all such numbers within a given range along with their corresponding two prime numbers and distance?

Sample Input/OutputInput:

2 10Output

3 5 7 2

Input10 30Output

11 17 23 6

17 23 29 6

Sample Solution
The post Executable C programs

Image result for Order Now images


Leave a Reply

Your email address will not be published. Required fields are marked *