C Interview Questions
Questions Answers Views Company eMail

What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }

2 4310

1)which of following operator can't be overloaded. a)== b)++ c)?! d)<=

Siemens, CybOrg,

16 22827

2)#include main() { printf("Hello World"); } the program prints Hello World without changing main() the o/p should be intialisation Hello World Desruct the changes should be a)iostream operator<<(iostream os, char*s) os<<'intialisation'<<(Hello World)<


4 8136

6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } after calling swap ,what are yhe values x&y?

3 13886

18)struct base {int a,b; base(); int virtual function1(); } struct derv1:base{ int b,c,d; derv1() int virtual function1(); } struct derv2 : base {int a,e; } base::base() { a=2;b=3; } derv1::derv1(){ b=5; c=10;d=11;} base::function1() {return(100); } derv1::function1() { return(200); } main() base ba; derv1 d1,d2; printf("%d %d",d1.a,d1.b) o/p is a)a=2;b=3; b)a=3; b=2; c)a=5; b=10; d)none 19) for the above program answer the following q's main() base da; derv1 d1; derv2 d2; printf("%d %d %d",da.function1(),d1.function1(),d2.function1 ()); o/p is a)100,200,200; b)200,100,200; c)200,200,100; d)none 20)struct { int x; int y; }abc; you can not access x by the following 1)abc-->x; 2)abc[0]-->x; abc.x; (abc)-->x; a)1,2,3 b)2&3 c)1&2 d)1,3,4

1 6352

write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101)

Bosch, College School Exams Tests,

1 4515

How to add two numbers without using arithmetic operators?

Infosys, TCS, Sapient, College School Exams Tests, e track, Pan Parag,

18 30949

how we can make 3d venturing graphics on outer interface


1 2665

what is the defrenece between structure and union

Aloha Technology,

5 5175

Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor



What is volatile

2 3209

how to find the size of the data type like int,float without using the sizeof operator?

13 16005

what is the use of a array in c

6 3337

How to avoid structure padding in C?

Tech Mahindra,

7 43088

Why does not use getgh(); and in c language.


3 6447

Post New C Questions

Un-Answered Questions { C }

write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software


difference between native and cross compilers


a program that can input number of records and can view it again the record


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.


what will be the output for the following main() { printf("hi" "hello"); }


What is the difference between declaring a variable by constant keyword and #define ing that variable?


write a c program to find largest of three numbers using simple if only for one time.


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f


write a progrmm in c language take user interface generate table using for loop?


what value is returned to operating system after program execution?


I need help with the following lab. Can anyone explain it to me on how to approach this problem. Coding would be great too !!! No busy waiting allowed. Remember that Java monitors are 'signal and continue'. The input data is called the database (DB). In this problem, it consists of a single variable initialized in the main thread, to contain the current time of day in HH:MM:SS:mmm format (mmm is milliseconds) truncated to 3 digits. Threads follow these rules: 1. Readers may all attempt to read at the same time, but NOT if a writer is writing (i.e.; the writer is in the monitor. 2. Writing is exclusive (only 1 writer at a time, no readers while writing). 3. Options: (to be specified by instructor) a. Readers have absolute priority over writers. b. Writers have absolute priority over readers c. When a reader arrives and a writer is waiting, the reader is suspended behind the writer instead of being admitted immediately. Thus, a writer waits for readers that were running when it arrived, but does not to wait for new readers. You may program this in C++ or Java. There are 4 controlling input values: 1. r – number of readers 2. w – number of writers 3. R – delay for a reader to restart 4. W – delay for a writer to restart Create the following program consisting of 1 main process (your main program) with n threads: 1. The main thread: a. Creates the 'n' threads needed. Of these, r of them are readers and w of them are writers. Starts all readers and writers. b. Waits for all 'n' threads to complete. You may use any method to detect when they are all complete. c. Prints out the resulting outputs from the threads. 2. Threads: a. When a thread starts to run, it immediately tries to enter the monitor. b. A reader thread reads the DB, outputs the exact message below, then exits: >>> DB value read =: HH:MM:SS:mmm by reader number: rr where the underlined text is replaced with actual data. c. A writer thread updates the DB with a new value (from the system time), outputs the exact message below, then exits: *** DB value set to: HH:MM:SS:mmm by writer number: ww where the underlined text is replaced with actual data. d. Each thread accesses the data a total of 10 times, exiting, then re-entering the monitor after each access. Hints: 1. File access *might* not be thread-safe, so you should be prepared to handle this. Read the documentation for the language you are using. 2. Suggested values for delays are: a. If looping, R >=1,000,000 and W>=100,000 b. If using “sleep”, then R=100 ms, W=50 ms. Additional: • Thread output is to ONE file used by ALL threads (so you need to synchronize access to it). • Readers must provide sufficient delay that results are useful (delay by R before re-trying). R is another input value. • Writers must also delay. Delay by W, updating the DB each time. W is an input. • Test your program with AT LEAST TWO different sets of values for r and w (#s of readers and writers) plus this set: r = 4, w=2. Basic operation of a thread: attempt to enter the monitor. If unsuccessful, you get put on a queue. When you get in, read or write the data (depending on type of thread), exit the monitor, wait the required delay amount, then try again. Repeat 10 times.


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions