C language : Interview Question in hindi c भाषा पर आधारित प्रश्न उत्तर इंटरव्यू के लिए हिंदी में

c भाषा पर आधारित प्रश्न उत्तर इंटरव्यू के लिए हिंदी में C language : Interview Question answer in hindi :-

C language सभी advance कंप्यूटर language की जननी है |ज्यादातर इंटरव्यू मे basic concept को पुचा जाता है |ये सभी basic question के answer c language मे छुपा होता है लेकिन candidate को सही समय पर सही concept trigger हो जाना चाहिए|

इसलिए आज इस article मे हम C language based basic question का set provide करा रहे है जिससे की आप सभी को आने वाले इंटरव्यू मे मदद मिल सके|

Question 1 :- Print Hello world without using a semicolon ?

Solution : जब किसी printf() statement को if /while / switch statement मे लिखते है तब without semicolon ,हम hello world print हो सकता है |

main()

{

if(printf(“hello world”))

{

}

}

Question 2.Convert Roman Number to decimal number?

solution:

Input Format

Roman Number Between 1-100
Roman Numbers will be of Capital letters only

Output Format

Decimal number

Sample Input

VI

Sample Output

6
इस question का लॉजिक बहुत easy है |लेकिन हमे रोमन number का ज्ञान होना चाहिए |जैसे Roman – Decimal
I – 1,V – 5,X – 10,L – 50,C – 100 आदि |
उदहारण के लिए

input : VI

जब len=2,i=1और d=1होगा :जब s1<s condition फॉलो होगी तब n=n+d हो जायेगा |or n की value 1 होगी |

फिर len की value मे DECREMENT होगा ,len=1 होने पर while loop चलेगा |a[1] की value V होने पर d की value 5 हो जाएगी |फिर d<d1 की condition फॉलो होने के कारण n की value 1+5 =6 हो जाएगी |

code:

#include <stdio.h>

#include <string.h>

#include<conio.h>

int main()

{

char a[100000];

int d=0,d=0,n=0,len,i=0,c=0;

scanf(“%s”,a);

len=strlen(a);

i=len-1;

while(len)

{

if(a[i]==’I’)

{

d=1;

}

else if(a[i]==’V’)

{

d=5;

}

else if(a[i]==’X’)

{

d=10;

}

else if(a[i]==’L’)

{

d=50;

}

else if(a[i]==’C’)

{

d=100;

}

if(d1<d||d1==d)

{

n=n+d;

}

else if(d1>d)

{

n=abs(n-d);

}

len–;

i–;

d1=d;

}

printf(“Decimal Output”);

printf(“%d”,t);

getch();

}

question 3.You are given an array of integers of size ‘N’ You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.

Solution :

इस question मे ,array के element की size बहुत बड़ी होगी इसलिए हम जो variable को use करेगे उसका data type long long होगा |यही concept को check किया जाता है |

code:

#include <stdio.h>

#include <string.h>

#include<conio.h>

int main()

{

long long int len,a[10000],i,k=0;

len=strlen(a);

for(i=0;i<len;i++)

{

scanf(“%Ld”,&a[i]);

k=k+a[i];

}

printf(“%Ld”,k);

}

Question 4.C programe to check perfect square .

Solution :

code

#include<stdio.h>

#include<conio.h>

void main()

{

int num,i;

printf(“Enter Number”)

scanf(“%d”,&num);

for(i=0:i<=num;i++)

{
if(num==i*i)

{
printf(“Yes”);

}

}

printf(“No”);

}

Question 5:

Given an unsorted array of positive and negative numbers. Create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers respectively.
Example:

Input
10 5 -3 -2 -6 6 1 -4 3

Output
10 -3 5 -2 6 -6 1 -4 3

code:

#include <stdio.h>

#include <conio.h>
void main() {
long long int t,n;
scanf(“%Ld”,&t);
while(t–)
{
scanf(“%Ld”,&n);
long long int a[n],b[n],c[n],p=0,s=0,i;
for(i=0;i<n;i++)
{
scanf(“%Ld”,&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]>=0)
{
b[p]=a[i];
p++;
}
else if(a[i]<0)
{
c[s]=a[i];
s++;

}
}
p=0;
s=0;
for(i=0;i<n;i++)
{
if(i%2==0)
{
printf(“%Ld “,b[p]);
p++;
}
else if(i%2!=0)
{
printf(“%Ld “,c[s]);
s++;
}
}
}
printf(“Alternative Array”);

for(i=0;i<t;i++)

{

printf(“%d\t”,b[i]);
}

getch();
}

Question 6.Bouncy number:

Solution :

जब कोई number के digits बढते कम्र मे होते है तब उसे increasing number कहते है |

जब कोई number के digits घटते कम्र मे होते है तब उसे deceasing number कहते है |

और वे number जो की incresing number और deceasing number नहीं होते है उसे bouncy number कहते है |

उदाहरण के लिए :

135789 एक increasing number है |

9854321 एक deceasing number है |

123454435 एक bouncy number है |

code

#include <stdio.h>
#include<conio.h>
void main()

{
int n,i=0,a[100],j,sum=0,l,e,h,g=0,f=0;
scanf(“%d”,&n);
h=n;
while(n)
{
a[i]=n%10;
n=n/10;
i++;
}
for(j=0;j<i;j++)
{
if(a[j]>a[j+1])
{
g++;
}
else if(a[j]<a[j+1])
{
f++;
}
}
if(g==i)
{
printf(“The number %d is Increasing number.”,h);
}
else if(f==i)
{
printf(“The number %d is Decreasing number.”,h);
}
else
{
printf(“The number %d is bouncy number.”,h);
}
getch();
}

Question  1. c language मे  Storage Class क्या है ?
Answer 
Storage Class ये keyword होते है जो variable lifetime,validity और scope से releated जानकारी देता है :ये char प्रकार के होते है | (i) AUTO (ii) STATIC (iii) REGISTER (iv) EXTERN


Question 2. variable का scope क्या है ?
Answer
scope से मतलब है की variable की ACCESSIBILITY | और variable को कितना use कर सकते है |


Question 3. C language के key feature क्या है ?
Answer
Portability : ये किसी platfrom पर निर्भर नहीं करती है | 
Modularity : किसी बड़े प्रोग्राम को छोटे छोटे प्रोग्राम मे तोड़ सकते है |
Flexibility   : प्रोग्रामर code को control कर सकता है |
Extensibility : प्रोग्रामर किसी नए feature को add कर सकता है |


Question 4. Recursion क्या है ?
Answer 
जब कोई function खुद को बार बार call करता है उसे Recursion  कहते है |


Question 5. Syntax Error क्या है ?
Answer 
जब कोई C प्रोग्राम मे syntax मे error होती तब syntax error occur होती है |जैसे  incorrect number of parameters when called a method /function, data type mismatches |


Question 6. Program क्या है ?
input: 
AEIOaeio
output:
AaEeIiOo
 
input:

Appleant
output:

Aapplent


source code:
#include <stdio.h>
#include<string.h>

#include<conio.h>
void main {

char a[50];

 

scanf(“%s”,a);

 

int len,m,n;

 

len=strlen(a);

 

for(m=0;m<len;m++)
{

 

 

if(a[m]!=’ ‘)

 

{

 

printf(“%c”,a[m]);

 

for(n=m+1;n<len;n++)

 

{
if(abs(a[m]-a[n])==32||abs(a[m]-a[n])==0)

 

{

 

printf(“%c”,a[n]);

 

a[n]=’ ‘;

 

}

 

}

 

}

 

}

getch();

}



Question 7.Pattern को print करे ?


INPUT:
KOLKATA

OUTPUT:

K     K
 O   O
  L L
   K
  A A
 T  T
A    A


SOURCE CODE: 
#include <stdio.h>
#include<string.h>

#include<conio.h>
void main() 

 {
char a[100],b[100][100];
scanf(“%s”,a);
int len,m,n;
len=strlen(a);
for(m=0,n=(l-1);m<len && n>=0 ; m++,n–)
{
b[m][n]=a[m];
b[m][n]=a[m];
}
for(m=0;m<len;m++)
{
for(n=0;n<l;n++)
{
if(b[m][n])
printf(“%c”,b[m][n]);
else
printf(” “);
}
printf(“\n”);
}

getch();
}



Question 8: abs() or fabs() क्या अंतर है ?
Answer 
abs (): इस function का use string को integer मे convert करने के लिए किया जाता है |
fab (): इस function का use string को float मे convert करने के लिए किया जाता है |


question 9:Modifier क्या है ?
Modifier ये keyword होते है जो किसी data type के आगे लग कर इसके data size को change कर सकते है 
जैसे :
short ,long ,singed , unsigned,long long आदि |


Question 10. Random number को generate करने के लिए प्रोग्राम लिखे?
rand () एक function होता है जो की random numbers genrate करता है |
#include<conio.h>
#include<stdio.h>
void main()
{
int a[20];
int i;
for(i=0;i<20;i++)
{
a[i]=rand();
printf(“%d”,a[i]);
}
getch ();
}


Question 11.32768 को किस data type मे store करेगे ?
Solution:
आपका जवाब होगा integer type मे |लेकिन नहीं ,क्योकि integer की limit – 32768 to 32767 होती है |इसलिए 32768 को long integer मे store करेगे |


Question 12. किसी string को reverse print करने का code लिखे ?

E.g.
Input: i am parth
Output: parth am i
code: 
#include <stdio.h>
#include <conio.h>
#include<string.h>
int main(void)
{
char b[100];
int len,i,s=0,j,c=0;
printf("enter the string\n");
gets(b);
len=strlen(b);
for(i=len-1;i>=0;i--)
{
s++;
if(b[i]==' ')
{
for(j=i+1;j<i+s;j++)
{
if(b[j]!=' ')
{
printf("%c",b[j]);
c++;
}
else if(b[j]==' '||j== len-1)
{
printf(" ");
s=0;
j=i+s+10;
}
}
}
else if(i==0)
{
for(j=i;j<i+s;j++)
{
if(b[j]!=' ')
{
printf("%c",b[j]);
c++;
}
else if(b[j]==' '||j== len-1)
{
printf(" ");
s=0;
j=i+s+10;
}
}
}
if(c>0)
{
printf(" ");
c=0;
}
}
getch();
} 



Question 13.किसी series मे एसे number को find करे जिसमे  2 & 5 ही आये
जैसे 2,5,22,25,53,55,222,225,252,255,…..मे 
आउटपुट होगा 2,5

source code:
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
int n;
scanf(“%d”,&n);
n=n+1;
int a[100]={0},i=0;
while(n)
{
a[i]=n%2;
n=n/2;
i++;
}
for(int j=i-3;j>=0;j–)
{
if(a[j]==1)
printf(“5”);
else if(a[j]==0)
printf(“2”);
}
getch();
}