Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: C Programming Questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[attachment=72877]



C Programming Questions
1) Your teacher has given you the task of drawing a staircase structure. Being an expert programmer, you decided to make a program to draw it for you instead. Given the required height, can you print a staircase as shown in the example?
Input
You are given an integer NN depicting the height of the staircase.
Output
Print a staircase of height NN that consists of # symbols and spaces. For example for N=6N=6, here's a staircase of that height:
#
#
#
#
#
#
The last line has 0 spaces before it.

2) Jesse is standing at the head of a straight line of NN rocks of varying strengths, and can break a rock, ii, if his strength (strengthJessestrengthJesse) is greater than or equal to strengthRockistrengthRocki. Jesse can skip a single rock in the line without breaking it (but no more rocks can be skipped after that) and must stop after reaching a rock that cannot be either broken or skipped. Starting at the first rock and going through the line in order, help Jesse find the maximum number of rocks (maxRocksmaxRocks) that can be broken.
Note: A skipped rock is not broken.
Input Format
The first line contains 22 space-separated integers, NN (the number of rocks) and strengthJessestrengthJesse, respectively.
The second line contains a list of NN space-separated integers (strengthRock0strengthRock0 through strengthRockN−1strengthRockN−1) describing the strength of each rock.
Constraints
1≤N≤1051≤N≤105
1≤strengthJesse≤1091≤strengthJesse≤109
1≤strengthRocki≤1091≤strengthRocki≤109, where 0≤i≤N−10≤i≤N−1
Output Format
Print maxRocksmaxRocks as a single integer.
Sample Input
7 6
4 3 7 6 7 2 2
Sample Output
3
In this example, strengthJesse=6strengthJesse=6. Jesse breaks rocks 00 and 11, but skips rock 22 as strengthRock2>strengthJessestrengthRock2>strengthJesse. Jesse then breaks rock 33, but stops at rock 44 because strengthRock4>strengthJessestrengthRock4>strengthJesse and rock 22 was already skipped. As 33 rocks were broken and 11 was skipped before Jesse had to stop, maxRocks=3maxRocks=3 and we print 33.

3) Given a time in AM/PM format, convert it to military (24-hour) time.
Note: Midnight is 12:00:00AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock and 12:00:00 on a 24-hour clock.
Input Format
A time in 12-hour clock format (i.e.: hh:mmConfusedsAM or hh:mmConfusedsPM), where 01≤hh≤1201≤hh≤12.
Output Format
Convert and print the given time in 24-hour format, where 00≤hh≤2300≤hh≤23.
Sample Input
07:05:45PM
Sample Output
19:05:45
4) Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.)
After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams.
Given a sentence ss, tell Roy if it is a pangram or not.
Input Format
Input consists of a string ss.
Constraints
Length of ss can be at most 103103 (1≤|s|≤103)(1≤|s|≤103) and it may contain spaces, lower case and upper case letters. Lower-case and upper-case instances of a letter are considered the same.
Output Format
Output a line containing pangram if ss is a pangram, otherwise output not pangram.
Sample Input
Input #1
We promptly judged antique ivory buckles for the next prize
Input #2
We promptly judged antique ivory buckles for the prize
Sample Output
Output #1
pangram
Output #2
not pangram
Explanation
In the first test case, the answer is pangram because the sentence contains all the letters of the English alphabet.