GeekInterview.com
Series: Subject: Topic:

C Interview Questions

Showing Questions 1 - 20 of 589 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

If the following program (myprog) is run from the command line as myprog friday tuesday Sunday, what would be the output? main(int argc, char *argv[]) { printf("%c",*++argv[1]); } a) r b) f...

Asked By: Interview Candidate | Asked On: Jul 7th, 2005

Answered by: Amber Bhardwaj on: Apr 15th, 2014

For example, the command line gcc -o myprog myprog.c would result in the following values internal to GCC: "c argc 4 argv[0] gcc argv[1] -o argv[2] myprog argv[3] myprog.c ...

Answered by: nirupa on: Feb 22nd, 2008

The answer is a) r as argv[1] is friday
and argv[0] is myprog

How do I design an algorithm to check if a number is an armstrong number?

Asked By: Moses Iisa | Asked On: Apr 19th, 2006

Answered by: jbode on: Mar 7th, 2014

First, count up the number of digits in the candidate value; an easy way to do this is take the floor value of the log of the number and add 1 (for example, floor(log10(1234)) = 3, so 3 + 1 = 4 digits...

Answered by: Kapil S Shinde on: Feb 25th, 2014

"c start Accept num noOfDigit=calculate number of digits //use counting digit function while(num!=0) { remainder=inum%10; sum=sum+pow(remainder,noOfDigit); //use power func...

What is result for of this C code block?

Asked By: jyotirmoyy | Asked On: Sep 3rd, 2011

What is the result main() { int x=15; printf("%d %d %d",x!=15,x=20,x

Answered by: jbode on: Feb 18th, 2014

The behavior is undefined; the arguments to printf aren't guaranteed to be evaluated in any particular order. The *result* of each expression is guaranteed to be passed in the order specified, but th...

Answered by: suresh on: Feb 14th, 2014

1 20 20

What is the output of the following program:

Asked By: lalithakasiraj | Asked On: Dec 15th, 2012

Code
  1. int main()
  2. {
  3. char a = 120, b = 140;
  4. int i;
  5. i = a + b;
  6. printf("%d", i);
  7. return 0;
  8. }

a) 260 b) 0 c) -1 d) 1

Answered by: Surajsingh Rajput on: Feb 12th, 2014

the answer is 4. because range of char is -128 to 127 so at 140 it get considered as 127,-128,-127,-126,....,-116.
so 120+(-116)=4

Answered by: ish mahajan on: Jan 16th, 2014

260

Is it possible to write a C program without semicolons?

Asked By: kamba | Asked On: Nov 29th, 2007

Answered by: prasanna on: Dec 4th, 2013

max and min program without semicolon

Answered by: Manali on: Sep 18th, 2011

Code
  1. #include<stdio.h><br /><br />void main()<br /><br /> {<br /><br />   if(printf("no semicolon"))<br /><br /> {}<br /><br /> }


Program to print all prime numbers btw 1 to 100

Asked By: Pavani Shiny | Asked On: Nov 17th, 2013

C program to print all prime numbers btw 1 to 100.. pls explain the program: what is if(p)?? #include #include int main() { int num,n,div,p; printf("enter any number: "); scanf("%d", &num); for(n=2; n

What is the difference between structure & union?

Asked By: sathishkumar | Asked On: Oct 21st, 2007

How can we multiply this a*b without using "*" operator?

Answered by: SEETU SAHU on: Oct 24th, 2013

1.union allocates the memory equal to the maximum memory required by the member of union,Structure allocate the memory to the total memory required by the member.

2. in union one block is used by all member of union,in structure each member have their own memory space

Answered by: sounak pandey on: May 21st, 2013

All the members of the structure can be accessed at once,where as in an union only one member can be used at a time. Another important difference is in the size allocated to a structure and an union. ...

What is page thrashing?

Asked By: Interview Candidate | Asked On: Mar 6th, 2005

Some operating systems (such as UNIX or windows in enhanced mode) use virtual memory. Virtual memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate ram (random-access memory). In the 80386 and higher intel cpu chips, and in most...

Answered by: kranthi tadisetty on: Oct 20th, 2013

thrashing means "high pagefaultservice time ",bcoz of that reason the operating system can applying pagereplacement algorithms are very highly,i.e(processor busy with executing pagereplacement algorithms rather than executing userinstructions

Answered by: amit1220 on: Dec 13th, 2012

Thrashing is caused by under allocation of the minimum number of pages required by a process, forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU util...

Why is C considered as a high level language and a low level language?

Asked By: chidinma ojialor | Asked On: Aug 18th, 2013

Answered by: Satt Crypt on: Oct 16th, 2013

Here the 1st answer is 22 and second is 15 because in case of ++a + ++a + ++a then 1st increment then addition let temp=(++a + ++a)==7+7=14 and then ++a =14+8=22
and for 2nd case 5+5+5=15.

Answered by: jbode on: Aug 19th, 2013

C is a high-level language because it abstracts away a large part of the underlying machine; instead of dealing with registers and opcodes, youre dealing with objects and expressions. Streams are abs...

A=5;c=++a + ++a + ++a;what would be value of C after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;what would be the value of C then?

Asked By: ashwini_nith | Asked On: Nov 22nd, 2007

Answered by: Jitendra Kumar on: Sep 8th, 2013

In the first case it gives answer 22 because it form a tree like structure and start from bottom i.e ++a and ++a in first ++a=6 and in the 2nd time ++a=7 and again aad take max[6,7] in the case of re-...

Answered by: narender yadav on: Aug 27th, 2013

in the first case: a=5; c= ++a + ++a + ++a; now in first pre increment the value of a will be 6 and after 1st pre-increment the value in secont pre-increment statement will be 7, so that the value in ...

Pre and post increment operators

Asked By: Ruhani Chawlia | Asked On: Jul 28th, 2012

Why does ++i * ++i give 49 when i=5?

Answered by: Malli on: Aug 21st, 2013

why does ++x * ++x give 49 when x=5? If you directly give this in printf stmt it gives you the result as 42,7 x=5 printf("%d %d ",++x * ++x,x) But if you assign this to some vari...

Answered by: Jaspal on: Sep 27th, 2012

it increments i by 1i.e i becomes 6 in first subexpression and becomes in 7 in second subexpression.finally 42 is answer

C program to count numbers of positive and negative numbers

Asked By: Tai | Asked On: Oct 12th, 2007

Write a C program using arrays to count the numbers of positive and negative numbers which accepts the inputs as "size of the array" & "elements of the array" and outputs as "number of negative numbers in an array are" & "numbers of positive numbers in an array are" ?

Answered by: asdasda on: Aug 10th, 2013

Code
  1. #include<conio.h>
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. int value(int a);
  7.  
  8. int main ()
  9. {
  10.     int a, num, count=0;
  11.    
  12.      cout<<"How many values: ";
  13.      cin>>num;
  14.    
  15.     getch ();
  16.    
  17.    
  18.    
  19. int value(int a);
  20.    
  21.    
  22.     for (a=1;a<=num;a++)
  23.     {
  24.    
  25.         cout<<"Enter value "<<a<<": ";
  26.         cout<<endl;
  27.         }
  28.        
  29.        
  30.         getch ();
  31.         return 0;
  32.         }
  33.        
  34.  

Answered by: kesineni on: Jul 12th, 2009

#include <stdio.h>main(){   int a[] = { 1,-3,-5,-4,-9,2,8};   int len,i,val;   int npos=0, nneg=0;   len = sizeof(a)/sizeof(a[0]);   printf(&quo...

Two numbers are entered through keyboard, write a program to find the value of one number raised to the power another.

Asked By: sweety | Asked On: Oct 28th, 2007

Answered by: Shivam on: Jul 15th, 2013

Code
  1. #include<conio.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4. main()
  5. {
  6.     int a,b,num,i;
  7.     printf("enter the number ");
  8.     scanf("%d",&a);
  9.     printf("enter the number  in power");
  10.     scanf("%d" , &b);
  11.   num = pow(a,b);
  12.  
  13.    printf("%d" , num);
  14.     getch();
  15. }

Answered by: jechanter on: Feb 8th, 2010

main() {        scanf("%d",&a); // base         scanf("%d",&b); //power  &nbs...

Break statement can be simulated by using 1. Go to 2. Return 3. Exit 4. Both return and exit

Asked By: Rujul | Asked On: Mar 9th, 2007

Answered by: ahammedsadhik on: Jun 28th, 2013

return to the next executive statement

Answered by: jintojos on: Jun 10th, 2008

The Break statement can be simulated by using the "goto" statements.The exit statement is used for exiting the program and the return statement is for returning to the calling function. So b...

Write a program to implement the fibonacci series

Asked By: Interview Candidate | Asked On: Jun 3rd, 2005

Star Read Best Answer

Editorial / Best Answer

Answered by: baseersd

View all answers by baseersd

Member Since Jun-2007 | Answered On : Jul 27th, 2007

Code
  1.  
  2. #include
  3. int main()
  4. {
  5. unsigned int i = 0, j = 0, sum = 1, num;
  6. printf("nEnter the limit for the series ");
  7. scanf("%d", &num);
  8. while (sum < num) {
  9. printf("%d ", sum);
  10. i = j;
  11. j = sum;
  12. sum = i + j;
  13. }
  14. getch();
  15. }
  16.  

Answered by: keerthi on: Jun 7th, 2013

Code for fibonacci series

Code
  1. #include<stdio.h>
  2. void main(){
  3. int i=0,j=1,sum=0,num;
  4. printf("enter the size of the series");
  5. scanf("%d",&num);
  6. while(sum<num){
  7. printf("%d",sum);
  8. i=j;
  9. j=sum;
  10. sum=i+j;
  11. }
  12. getch();
  13. }
  14.  

Answered by: n.m.sudesh kumar on: Mar 20th, 2013

Code
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int pre=0,next=1,sum=0,n;
  6. clrscr();
  7. printf("enter the value of n:");
  8. scanf("%d",&n);
  9. while(pre<=n)
  10. {
  11. printf("the fibonacci series; %d
  12. ",pre);
  13. sum=pre+next;
  14. pre=next;
  15. next=sum;
  16. }
  17. getch();
  18. }

Write a program to convert numbers into words?For ex: 547five hundred and forty seven

Asked By: Preetham | Asked On: Oct 4th, 2006

Answered by: jbode on: Apr 24th, 2013

The following handles up to 32-bit integer values. Not the prettiest code in the world, but it works pretty well. Sample output: [fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 1 one [fbgo448@n9...

Answered by: mm on: Apr 22nd, 2013

"c #include #include void pw(long,char[]); char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen...

Removing duplicate words from a string

Asked By: pro_learner | Asked On: Apr 6th, 2013

Code
  1. int main()
  2. {
  3.         char arr[1000];
  4.         char *temp=NULL;
  5.         char *temp1=malloc(100);
  6.         int len;
  7.         printf("enter the string:
  8. ");
  9.         gets(arr);
  10.         len=strlen(arr);
  11.         puts(arr);
  12.         printf("len:%d
  13. ",len);
  14.         temp=strtok(arr," ");
  15.        
  16.         if(temp!=NULL)
  17.                 strcpy(temp1,temp);
  18.        
  19.         while(temp!=NULL)
  20.         {
  21.                
  22.                 temp=strtok(NULL," ");
  23.                
  24.                 if(strstr(temp1,temp)==NULL)
  25.                 {
  26.                        
  27.                         strcat(temp1," ");
  28.                         strcat(temp1,temp);
  29.                        
  30.                 }
  31.         }
  32.         strcpy(arr,temp1);
  33.         printf("arr:%s",arr);
  34.         return 0;
  35. }
  36.  

This is giving me runtime error why ?

Answered by: jbode on: Apr 10th, 2013

You need to check that temp isnt null after the call to strtok() in the loop. See the attachment for a fix.

Code
  1. temp = strtok(NULL, " ");
  2.  
  3. if (temp != NULL && strstr(temp1,temp) == NULL)

What do you mean by "paridium"....?

Asked By: bcac2 | Asked On: Apr 8th, 2013

What is wild pointer?

Asked By: pbchaudhari | Asked On: Aug 21st, 2007

Answered by: chandu on: Apr 5th, 2013

wild pointer is a pointer which has not been initialized i.e point to nothing

Answered by: sunil on: Feb 20th, 2013

A pointer which does not hold any valid address is called wild pointer

Difference between printf and cprintf

Asked By: Ruhani Chawlia | Asked On: Oct 27th, 2012

What is the difference between cprintf and printf? Please explain in detail.

Answered by: Howard Lee Harkness on: Apr 4th, 2013

cprintf outputs to the console device.
fprintf outputs to a stream specified by the 1st parameter.

Answered by: Ravindra Kittad on: Dec 20th, 2012

printf outputs to the standard output stream (stdout)

fprintf goes to a file handle (FILE*)

sprintf goes to a buffer you allocated. (char*)

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.