GeekInterview.com
Series: Subject: Topic:

C Interview Questions

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

The C language terminator isa. Semicolonb. Colonc. Periodd. Exclamation mark

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

Answered by: parthiban on: Oct 13th, 2014

A

Answered by: uma on: Oct 6th, 2014

D

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: vilishens on: Oct 4th, 2014

1

Answered by: bharathireddy on: Oct 1st, 2014

Goto

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: daisy on: Sep 24th, 2014

enter ur no. at field STDIN Input: "c #include ; void main() {char a[10][10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE ; char b[10][10]={"ELEVEN","TWELVE","...

Answered by: Shridhar on: Jun 27th, 2014

Code
  1. #include<stdio.h>
  2. main() {        int n,u,t,h,th;            
  3. jamkhandi: printf("enter a 4 digit non negative number  ");    
  4. scanf("%d",&n);    
  5.  if(n<0) goto jamkhandi;    
  6.   printf(" the entered number is :-  ");    
  7.  if(n==0)printf("zero ");    
  8. else {          
  9. u=n%10;        
  10. n=n-u;    
  11.         t=n%100; t=t/10;        
  12. h=n%1000;
  13. h=h/100;        
  14. th=n%10000; th=th/1000;         }        
  15. switch(th)    {         case 1: {                    
  16. char th1[100]="one thousand";                        
  17. printf("%s ",th1);break;             }            
  18.  case 2: {                 
  19. char th1[100]="two thousand";                        
  20. printf("%s ",th1);break;             }            
  21. case 3: {                    
  22. char th1[100]="three thousand";                      
  23. printf("%s ",th1);break;             }            
  24. case 4: {                    
  25. char th1[100]="four thousand";                       
  26. printf("%s ",th1);break;             }                          
  27. case 5: {                  
  28.  char th1[100]="five thousand";                      
  29. printf("%s ",th1);break;             }            
  30. case 6: {                    
  31. char th1[100]="six thousand";                        
  32. printf("%s ",th1);break;             }            
  33. case 7: {                  
  34.  char th1[100]="seven thousand";                   
  35.  printf("%s ",th1);break;             }            
  36. case 8: {                  
  37.  char th1[100]="eight thousand";                     
  38. printf("%s ",th1);break;             }            
  39. case 9: {                    
  40. char th1[100]="nine thousand";                       
  41. printf("%s ",th1);break;             }    }  
  42. switch(h)    {          case 1: {                    
  43. char h1[100]="one hundred";                  
  44. printf("%s ",h1);break;             }            
  45. case 2: {                    
  46. char h1[100]="two hundred";                  
  47. printf("%s ",h1);break;             }            
  48. case 3: {                    
  49. char h1[100]="three hundred";                        
  50. printf("%s ",h1);break;             }            
  51. case 4: {                  
  52.  char h1[100]="four hundred";                        
  53. printf("%s ",h1);break;             }                        
  54.  case 5: {                   
  55. char h1[100]="five hundred";                         
  56. printf("%s ",h1);break;             }            
  57.  case 6: {                 
  58.  char h1[100]="six hundred";                       
  59.  printf("%s ",h1);break;             }          
  60.   case 7: {                  char h1[100]="seven hundred";                 
  61.  printf("%s ",h1);break;             }          
  62.   case 8: {                  char h1[100]="eight hundred";               
  63.    printf("%s ",h1);break;             }          
  64.   case 9: {                  char h1[100]="nine hundred";                
  65.   printf("%s ",h1);break;             }    }    
  66.   switch(t)     {          case 1:             
  67.  { if(u==1)              {                     
  68. char t1[100]={e,l,e,v,e,n,};
  69.         printf("%s",t1);        
  70. break;         }
  71.          if(u==2)                {                     
  72. char t1[100]={t,w,e,l,v,e,};        
  73.  printf("%s",t1);       break;         }  
  74.        if(u==3)                  {                     
  75. char t1[100]={t,h,i,r,t,e,e,n,};      
  76.   printf("%s",t1);      
  77. break;    
  78.     }         if(u==4)         
  79.  {                     
  80. char t1[100]={f,o,u,r,t,e,e,n,};    
  81.     printf("%s",t1);            
  82. break;         }      
  83.    if(u==5)              {                     
  84. char t1[100]={f,i,f,t,e,e,n,};      
  85.   printf("%s",t1);      
  86. break;      
  87.    }      
  88.   if(u==6)             
  89.  {                     
  90. char t1[100]={s,i,x,t,e,e,n,};  
  91.       printf("%s",t1);          
  92. break;         }    
  93.      if(u==7)            {                     
  94. char t1[100]={s,e,v,e,n,t,e,e,n,};        
  95.  printf("%s",t1);       break;         }    
  96.      if(u==8)            {                     
  97. char t1[100]={e,i,g,h,t,e,e,n,};        
  98.  printf("%s",t1);       break;         }      
  99.   if(u==9)               {                     
  100. char t1[100]={n,i,n,t,e,e,n,};        
  101.  printf("%s",t1);    
  102.         break;         }         if(u==0)      
  103.   {        
  104.         char t1[100]={t,e,n,};          
  105. puts(t1);        
  106.         break;      }            }             
  107.  case 2: {                     
  108. char t1[100]={t,w,e,n,t,y,};    
  109.                 printf("%s ",t1);                      
  110. break;           }               
  111.  case 3: {               
  112.         char t1[100]={t,h,i,r,t,y,};           
  113.  printf("%s ",t1);                             
  114. break;           }                               
  115.  case 4: {               
  116.         char t1[100]={f,o,r,t,y,};                     
  117. printf("%s ",t1);                
  118.         break;           }               
  119.  case 5: {             
  120.         char t1[100]={f,i,f,t,y,};                     
  121. printf("%s ",t1);                      
  122. break;         
  123.  }               
  124.  case 6: {                     
  125. char t1[100]={s,i,x,t,y,};                     
  126. printf("%s ",t1);                      
  127. break;           }               
  128.  case 7: {                     
  129. char t1[100]={s,e,v,e,n,t,y,};                 
  130. printf("%s ",t1);                      
  131. break;           }               
  132.  
  133. case 8: {                      
  134. char t1[100]={e,i,g,h,t,y,};                   
  135. printf("%s ",t1);                      
  136. break;           }               
  137.  
  138. case 9: {                      
  139. char t1[100]={n,i,n,e,t,y,};                   
  140. printf("%s ",t1);                                              
  141. break;           }                 }  
  142.  if(t!=1)    {         
  143. switch(u)    {         
  144.  case  1: {            
  145.   char u1[100]={o,n,e,};               
  146.  puts(u1);               
  147. break;                   }  
  148.          case 2:  {      
  149.  char u1[100]={t,w,o,};                
  150.  puts(u1);             
  151.  break;                  }                             
  152. case 3:
  153.  {         char u1[100]={t,h,r,e,e,};    
  154.        puts(u1);               
  155.   break;                 }                    
  156.    case 4:  {    
  157.  char u1[100]={f,o,u,r,};              
  158.  puts(u1);             
  159.   break;             
  160.     }                    case 5:  {      
  161.  char u1[100]={f,i,v,e,};              
  162.  puts(u1);         
  163.      break;              }               
  164. case 6:  {         char u1[100]={s,i,x,};              
  165.  puts(u1);               
  166. break;                   }             
  167.  case 7:  {        
  168. char u1[100]={s,e,v,e,n,};             
  169.  puts(u1);           
  170.     break;               }             
  171.  case 8:  {      
  172.  char u1[100]={e,i,g,h,t,};            
  173.   puts(u1);            
  174.  break;                  }           
  175.     case 9:  {    
  176.  char u1[100]={n,i,n,e,};      
  177.          puts(u1);               
  178. break;                   }       }    }        
  179. getch(); }
  180.  </stdio.h>

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: vinay on: Sep 24th, 2014

Ans: 42
i=5;
++i * ++i
6 7

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...

In the following code, what is p2? Typedef int* ptr ptr p1, p2;

Asked By: Interview Candidate | Asked On: Dec 10th, 2005

A) an integer b) an integer pointerc) a pointerd) none of the above

Answered by: B.Padmashri on: Sep 21st, 2014

B) an integer pointer

Answered by: abhimanipal on: Jan 28th, 2010

The answer is integer pointer. But the reason for this is not so apparent. When we write typedef int* ptr         We create a new type int* . So when we writept...

How a variable value is stored and retrieved at runtime in c?For example main(){ int a; a=5; }where is the value of 'a' stored and how it is retrieved at runtime?

Asked By: arunkumar2003 | Asked On: May 16th, 2007

Answered by: jbode on: Sep 19th, 2014

See the attached snippet for a general picture of how a compiled program is loaded into memory for x86-based systems. Some architectures (such as Harvard architecture) dont store program text and dat...

Answered by: sourav punoriyar on: Sep 5th, 2013

all the above code is in the code section of memory...as int a;a=5;are automatic storage class type..so they will come to life when this function is called.as local variables are stored in stack sect...

How to find entered number is even or odd without using conditional statement(not using if.. Else,if.. , else if..,while, do... While...., for....)

Asked By: kapilmandge | Asked On: Feb 16th, 2006

Answered by: shweta on: Sep 13th, 2014

(i%2==0)?even:odd

Answered by: cageordie on: Jun 17th, 2011

    Assuming i contains the number we wish to evaluate...    char *oddeven[] = {"even", "odd"};    printf("number is %sn",oddeven[i%2]);

C program for delete a node from linked list

Asked By: praveen.g | Asked On: May 6th, 2006

Answered by: oly on: Sep 14th, 2014

What is the program for delete a list in an linked list?

Answered by: Sukumar Paul on: Aug 1st, 2010

yaa i am writing the full program here for better understanding:This program will be run on Turbo C++ 3.0 without any error or warning. "c #include #include //Declaring node of li...

Where is the function declared as static stored in memory?

Asked By: vjaya | Asked On: Apr 18th, 2008

The usage of static with a function or variable restricts their scope.Is this behaviour memory related?

Answered by: Jeevan on: Sep 1st, 2014

Yes static keyword would not effect where the function gets stored, even if it is static a function will always be stored in stack! But it hides the function from being used in other files other than in which it is declared.

Answered by: vijaykumarkatoch on: Jul 19th, 2008

The keyword static dose not effect the sorage of function as it dose in case of variable a static variable means that it is stored in static dat  section but a static function dose not mean that alhough it means this function would not be accessibe in the other file.

Tricky C program questions

Asked By: ganesan81 | Asked On: Jun 5th, 2007

1)write a C program to find a peculiar two digit number which is three times the sum of its digits.2) bacteria are known to multiply very rapidly. If a certain container contains just one bacterium on the first day and there are twice as many on the next day. In this manner the number of bacteria in...

Answered by: paritosh on: Aug 24th, 2014

#include
using namespace std;
int main()
{
int end=13312;
for(int i=0;i

Answered by: sourav punoriyar on: Sep 5th, 2013

"c //code for goat and duck #include //with command line input... main(int argc,char **argv) { int eyes,foot,gf,ge,de,df; int r1,r2,cnt1=0,cnt2=0,r3,r4; if(argc!=3) { prin...

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: atul kumar on: Aug 20th, 2014

If you compile code by turboc compiler then you will get 21 while in gcc you will get 22 for first statement

Answered by: shweta gupta on: Jun 25th, 2014

It is completely dependent on the compiler to evaluate. we can see different behavior on different compilers. Example if u use turbo c the find the o/p of c=++a + ++a + ++a; is 24 and for c=a++ + a+...

What is pointer linking with operating system?

Asked By: jaganmaya | Asked On: Jul 23rd, 2008

Answered by: Ami Sheth on: Aug 11th, 2014

When we declare a null pointer it addresses the 0 address which is the address of operating system so we cannot use that address this is what the pointer is linked to OS

Difference between program memory, data memory, stack memory and heap memory?

Asked By: senthil | Asked On: Jun 8th, 2007

Answered by: Amol Patil on: Aug 4th, 2014

Program memory:where place your variable,you can read and write values

data memory:where tee application is stored some chips allows part of the program memory to be modified in block
,but you cant store a variable in the program memory.means initilize variable is not change in program memory.

Answered by: mukesh patil on: Aug 4th, 2014

Data memory = where you place your variables. You can read and write values. Program memory = where the application is stored. Some chips allows parts of the program memory to be modified in blocks ...

How to write a program for fibonacci series using perl?

Asked By: kutta20 | Asked On: Jul 31st, 2014

Can someone help me in writing program for fibonacci series using perl..

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: shweta gupta on: Jul 21st, 2014

It traverse the char type format specifier from left to right and assign the value from stdin to the address of the variable. Scanf return type is int and return the number of argument.


Its syantax is scanf(const char *,...), there is the ... represent the variable argument list.

Answered by: sudhakar on: Jul 19th, 2014

How to work the scanf function?

What change is required in the following program so that its output becomes 3,6,11,20,37,......1034?

Asked By: Swati Goel | Asked On: Dec 1st, 2012

Code
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int a=1,r=2,i;
  6. for (i=0;i<=10;i++)
  7. printf(",%d ", a * pow(r,i));
  8. return 0;
  9. }

Answered by: nira on: Jul 1st, 2014

Much easier approach, this is a logic question, not programming

Code
  1.    
  2.     #include<stdio.h>
  3.     #include<math.h>
  4.     int main()
  5.     {
  6.     int a=1,r=2,i;
  7.     for (i=0;i<=10;i++)
  8.     printf(",%d ", a * pow(r,i) + i);
  9.     return 0;
  10.     }

Answered by: shweta gupta on: Jun 25th, 2014

Code
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int temp=3;
  6. for(int i=0;i<10;i++){
  7.         cout<<temp<<endl;
  8.         temp=temp*2-i;
  9.  
  10.  
  11. }
  12.  
  13.     return 0;
  14. }

Print number of distinct characters in a string.

Asked By: levis | Asked On: Nov 23rd, 2011

How do I implement a C program that reads a string and prints a table with the number of occurrences of each character in the string. ex: rubber. R = 2, u = 1, b = 2, e = 1.

Answered by: shweta gupta on: Jun 25th, 2014

Code
  1.  
  2. int main()
  3.  
  4. {
  5.  
  6. char str[11]="aabcadefge";
  7. int a[26];
  8. for(int i=0;i<26;i++) a[i]=0;
  9. int couner=0;
  10. for(int i=0;str[i]!=;i++){
  11.         a[(str[i]-a)]+=1;
  12. }
  13.  
  14.  

Answered by: jbode on: Aug 31st, 2012

Simple, fairly brain-dead example. Assumes any input characters fall into the range [0...CHAR_MAX). "c #include #include #include int main(int argc, char **argv) { int coun...

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: shweta gupta on: Jun 25th, 2014

Code
  1. #include<iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4. int main(){
  5. cout<<"enter the size of array"<<endl;
  6. int size,count_neg=0,count_pos=0;
  7. cin>>size;
  8. int a[size];
  9. for(int i=0;i<size;i++){
  10. cout<<"enter element of a["<<i<<"]=";
  11. cin>>a[i];
  12. if((a[i]>>31)==-1) count_neg++;
  13. else count_pos++;
  14. }
  15. cout<<"total negative numbers "<<count_neg<<" and positive number is "<<count_pos;
  16.  
  17. return 0;
  18. }

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.  

Function syntax

Asked By: ak.nextptr | Asked On: Jul 31st, 2012

String abc = showdata()["hello"]; can somebody explain what is use of ["hello"] after function call?

Answered by: shweta gupta on: Jun 25th, 2014

There is showdata is returning index .
example when it return 1 then abc="ello";

Answered by: jbode on: Aug 6th, 2012

C doesn't have a String data type, unless that supposed to be a typedef for something. Having said that, I think this is taking advantage of the fact that array indexing in C is commutative; IOW, "...

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)??

Code
  1. #include
  2. #include
  3. int main()
  4. {
  5.  int num,n,div,p;
  6.  printf("Enter any number: ");
  7.  scanf("%d", &num);
  8.  for(n=2; n<=num; n++)
  9.  {
  10.   for(div=2; div  {
  11.    if(n%div==0)
  12.    {
  13.      p=0;
  14.      break;
  15.    }
  16.    p=1;
  17.   }
  18.   if(p)
  19.     printf("    %d",n);
  20.  }
  21.  getch();
  22.  
  23. }

Answered by: shweta gupta on: Jun 25th, 2014

Code
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. for(int i=1;i<=100;i++){
  5.         int flag=0;
  6.         if(i/2==0||i/2==1)
  7.         {
  8.                 cout<<"prime"<<i<<endl;
  9.                 continue;
  10.         }
  11.         for(int j=2;j<=i/2;j++){
  12.                 if(i%j==0){flag=0; break;}
  13.                 else flag=1;
  14.         }
  15.         if(flag){
  16.                 cout<<"prime "<<i<<endl;
  17.         }
  18. }
  19.  
  20. return 0;
  21. }
Code
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. for(int i=1;i<=100;i++){
  5.         int flag=0;
  6.         if(i/2==0||i/2==1)
  7.         {
  8.                 cout<<"prime"<<i<<endl;
  9.                 continue;
  10.         }
  11.         for(int j=2;j<=i/2;j++){
  12.                 if(i%j==0){flag=0; break;}
  13.                 else flag=1;
  14.         }
  15.         if(flag){
  16.                 cout<<"prime "<<i<<endl;
  17.         }
  18. }
  19.  
  20. return 0;
  21. }

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.