What is the output of the below program and how it is?

void main()
{
static int var=5;
printf("%d",var--);
if(var)
main();
}

Answers were Sorted based on User's Feedback



What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / anuj awasthi

above the program output is = 54321

Is This Answer Correct ?    18 Yes 5 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / gaurang

Programming Techniques Assignments

1) Write down an algorithm to get the weight (in kilograms)
and height (in meters) of a person. Then calculate and
print the Body Mass Index (BMI) according to the formula:
BMI = weight / (height*height)
The BMI should be printed with 3 decimal places. You
should choose an appropriate data types and names for your
variables.

2) Write down an algorithm to read in a temperature in
Celsius and convert it to Fahrenheit. The relationship
between Celsius and Fahrenheit is
C = (F-32)*5/9.

3) Write down an algorithm that reads in a positive integer
x and tests if it is a prime number.
Note: (1) A number is prime if it is only divisible by 1
and itself.
(2) The integer 1 is defined as non-prime.

4) Write down an algorithm to find out smallest and largest
amongst 3 elements.

5) Modify the above algorithm so that it will work with N
elements where N is accepted from the user.

6) Write down an algorithm to read in an integer between 0
and 99 and output the value in English. For example, if
the input is 28, it should output “twenty-eight”.

7) Write down an algorithm to find out roots of a quadratic
equation. Please note that roots can be imaginary.

8) Write down an algorithm that reads in the number of
seconds and converts it to hours, minutes and seconds. A
sample output of your program is as follows. Don’t bother
with the singular or plural forms of the nouns.






Hint: Use the / and % operators.


9) Write down an algorithm that reads in a mark of a
student (which is an integer between 0 and 100) and prints
the corresponding grades (A-F). The mark-to-grade
conversion table is as follows:

Grade A B C D F
Range &#8805;80 65-79 50-64 40-49 <40

1. Modify the program to allow user-specified grade
boundaries. You may need to define more variables.
2. Modify the program so that it checks if the input
is between 0 and 100. If not, it should ask the user to
input again until the input is in the correct range. Use
while statements.
3. Modify the program so that it repeats the above
computation on 50 students. Use while statements.

10) Write down an algorithm which will perform following
functionality
1) Read an integer array
2) Display above array
3) Find out sum of all elements of an array
4) Find out mean of an array
5) Find out standard deviation of an array
6) Find out probability of occurrence of every element
in an array
7) Draw histogram

11) Write down an algorithm to
1) Read and display Float array
2) Reverse an array
3) Check whether array is a palindrome
4) Sort an array
5) Search an element in an array
6) Find out how many times a given element is
appearing in an array


12) Write a nalgorithm to perform following operations on
an array :-
a) Insert element at nth position in an array. Please
note it should insert and not overwrite.
b) Delete an element at a given position
c) Display an array. Take care of proper validations.


13) A “password” file contains username and password. Write
an algorithm to accept the username and password and
crosscheck it with the password file and display
appropriate message.

14) Write down an algorithm to simulate a stack.
It should allow following operations on stack :-
a) Pushing an element onto stack
b) Popping an element on stack
c) Display TOS
d) Check whether stack is full or empty. Let the stack
be a stack of Characters.

15) Write down an algorithm to simulate a Queue. It should
allow following operations on Queue.
a) Adding an element into queue at the end
b) Deleting an element on queue from front
c) Display Contents of queue 4) Check whether queue is
full or empty. Let the Queue be a Queue of Employee where
Employee is user defined data type.

16) Write down an algorithm to read a set of sentence from
user till user enters a sentence QUIT.
Find out following statistical data such as number of
characters, words and sentences.

17) In above algorithm only perform following modification.
Reverse ordering of sentences as well as reverse ordering
of character within a sentence.

18) Write an algorithm to perform an encryption as well as
decryption of a file. Use any algorithm to perform above
said activity. Simplest possible algorithm is to read every
character, add 128 to it and stores it while performing an
encryption and do reverse step while performing a
decryption.

19) Write down an algorithm to:-
a) Display contents of a file
b) Copy a file to another file
c) Compare two files

20) Write down an algorithm to merge two sorted STRING
arrays to create third sorted STRING array.

21) Write down an algorithm to accept string consisting of
anything between ‘o’ to ‘9’ and convert it into
corresponding integer. Don’t assume any inbuilt function.

22) Write an algorithm to perform any five operations on
string such as :-
a) String Length
b) Changing case
c) Reversing a string
d) Checking for palindrome etc.


23) A file contains AAAAABBCCCDD. Write an algorithm to
read such file and find out run length of every character
in above file. For example, in above case A is appearing 5
times, B 2 times and so on. So the output should look like
as follows:
A5B2C3D2
Also write down another program which will read above
output and come out with original data such as
AAAAABBCCCDD. By the way this is very preliminary algorithm
used in compression and is known as RunLength Coding.

24) Task
You are to write an algorithm for a telephone company
(Company A) to generate the phone bills for its customers.
The input to the program is a sequence of call records, one
for each customer. Each call record consists of a customer
ID, followed by the start and end time of each call made by
that customer during the last month. The program should
calculate the charge on each call and then sum up the total
for each customer.
To attract more customers, the company has promised to
offer the cheapest rate compared with 2 other rival
companies, B and C. That is, for each call, it will
calculate the charges for all 3 companies and take the
cheapest one. The rates for the 3 companies are shown in
the following table:

Company A $0.80/min
Company B $1.00/min during 9:00 – 21:00 $0.60/min
during 21:00 – 9:00
Company C $0.90/min for the first hour $0.70/min
for the rest

Your program should
1. Input the number of customers (at most 99999).
2. For each customer, input his/her call record
consisting of:
a. The customer ID (an integer between 10000 and
99999).
b. For each call made by the customer, the start time
and end time of the call. (We assume that no calls have
duration more than 23 hrs 59 mins.)
c. After the last call, there is a special time value
(-1:-1) to signify the end of the list of calls.
3. For each customer, output his/her billing
information consisting of:
a. The customer ID.
b. For each call, the start time, duration (in
minutes) and the charge (in dollars).
c. The total duration (in minutes) and total charge
(in dollars) for that customer. (We assume that the total
duration is at most 99999.)
4. There should be one blank line after the billing
information of each customer.

* You cannot use array and self-defined function for this
assignment.
Output Format
1. Time: Each time value is represented in the format
hh:mm where hh is an integer between 0 and 23, and mm is an
integer between 0 and 59.
2. Call Duration: It should be printed in a field of
width 7, right-justified.
3. Money: Each monetary value should be printed with
a ‘$’ sign followed by a decimal value in fixed-point
notation with 2 decimal places. The decimal value should
occupy a field of width 7, right-justified.



Sample Input/Output
Observe carefully the special cases as well as the
spacing/format of the input/output.

Is This Answer Correct ?    12 Yes 8 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / arti yadav

error

Is This Answer Correct ?    4 Yes 4 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / sireesha

54321

Is This Answer Correct ?    0 Yes 0 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / shubham

----2nd Ans----

Start
Step 1-> Declare function to convert celsius to fahrenheit
float convert (float celsius)
declare float fahrenheit
set fahrenheit = celsius * (9/5) + 32
return fahrenheit
Step 2-> In main()
declare and set float celsius = 38.00
call convert(celsius)
Stop

Is This Answer Correct ?    0 Yes 0 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / ferose

write a cprogram in 0 to 50 interger value divisble by 8

Is This Answer Correct ?    4 Yes 5 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / anirban

if-statement is not properly declared
so error is there in the program

Is This Answer Correct ?    6 Yes 9 No

What is the output of the below program and how it is? void main() { static int var=5; printf(..

Answer / thiyagu

since the value of var is declared as static
the output will be 4 for each time printf is called by
recursive method main().

Is This Answer Correct ?    5 Yes 19 No

Post New Answer

More C Interview Questions

What is a buffer in c?

0 Answers  


What is the difference between File pointer and Internal Charecter Pointer?

2 Answers   TATA,


i have a written test for microland please give me test pattern

0 Answers   Microland,


My teacher ask to make a program that can: Insert record in front Insert record at the end Insert in between Search node record Delete record in front Delete record at the end Delete record in between Using Data structure Linked List type. But I'm really confused about the codes and I can't go through. Please help Thanks in advance. Also here is my unfinished code if someone can make changes it will be more good.

1 Answers  


what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,






How can a program be made to print the name of a source file where an error occurs?

0 Answers  


What is the function of volatile in c language?

0 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

0 Answers  


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


what is level of tree if leaf node is at level 4.please explain.

1 Answers   Wipro,


Famous puzzles which are generally asked by companies during interviews ?

1 Answers   3D PLM, Yahoo,


Categories