Motionzen
☰
×
◈ Introduction
◈ WIN-IT
◈ Smartplay Technologies
◈ TATA Power
◈ Sasken Technology
◈ MREC Tech
◈ RRSTB Consultancy
◈ Methode Electronics
◈ Hyundai Mobis
◈ Dexcel Electronices
◈ Data Patterns
◈ PROTECH
◈ VVDN - I
◈ VVDN - II
◈ VVDN - III
◈ UST Global - I
◈ UST Global - II
◈ UST Global - III
◈ Other Companies - I
◈ Other Companies - II
◈ Other Companies - III
Home
About
Consulting
Training
Tutorial
Interview Questions
Contact
Interview Questions
UST Global- Interview Experience
Home
Company Interview Experience
◈ Introduction
◈ WIN-IT
◈ Smartplay Technologies
◈ TATA Power
◈ Sasken Technology
◈ MREC Tech
◈ RRSTB Consultancy
◈ Methode Electronics
◈ Hyundai Mobis
◈ Dexcel Electronices
◈ Data Patterns
◈ PROTECH
◈ VVDN - I
◈ VVDN - II
◈ VVDN - III
◈ UST Global - I
◈ UST Global - II
◈ UST Global - III
◈ Other Companies - I
◈ Other Companies - II
◈ Other Companies - III
Interview Questions
UST Global- Interview Questions III
« Prev
Next »
UST Global- Interview Questions III
Program 31 Write a c program to get the offset in bytes of member “x” from the below structure. #include
#include
struct st { char ch; int num; double m; }; main() { struct st s; printf("char : %d\n",offsetof(struct st ,ch)); printf("num : %d\n",offsetof(struct st ,num)); printf("marks : %d\n",offsetof(struct st ,m)); // or use 2nd method . this is better printf("Offset for ch is : %d\n",(char *)(&s.ch)-(char *)(&s)); printf("Offset for num is : %d\n",(char *) (&s.num)-(char *)(&s)); printf("Offset for marks is: %d\n",(char *)(&s.m)-(char *)(&s)); } Program 32 Imagine there is no definition of NULL in the standard C library. How do you define your own NULL macro? #include
#define nil ((void *)0) main() { int *p=nil; printf("%d\n",(int)p); } Program 33 Wap to convert Hexadecimal to decimal. #include
#include
main() { int i,n=0,k=1,j; char a[5],b[5],c; printf("Enter hex number\n"); gets(a); j=strlen(a); for(i=0;a[i];i++) { if(a[i]>='0' && a[i]<='9') n+=(a[i]-48)*(1<<4*(j-i-1)); else if(a[i]>='a' && a[i]<='f') n+=(a[i]-87)*(1<<4*(j-i-1)); else if(a[i]>='A' && a[i]<='F') n+=(a[i]-55)*(1<<4*(j-i-1)); else { printf("Wrong input\n"); return; } } printf("Decimal is %d\n",n); } Program 34 Wap to print highest-length substring in given string? #include
#include
main() { char a[50],b[50],c[50],d[25],*p; int i,j,k,l,c1=0,c2=0; gets(a); gets(b); i=strlen(a); j=strlen(b); for(k=0;k
c2) { c2=c1; strcpy(d,c); } } } } printf("The highest substring length is %d %s\n",c2,d); } Output abcdefghijklmnop abcdabcdefghi The highest substring lenght is 9 abcdefghi Program 35 Pseudo code for the “mystery algorithm” 1.input two integers: a,b 2.initialize the value of “x to a” and the value of “y to b”. 3.if x>y then set x to x-y. 4.if x
main() { int a,b,x,y,c=0; printf("Enter a and b\n"); scanf("%d%d",&a,&b); x=a; y=b; while(x!=y) { if(x>y) x=x-y; else if(x
main() { int n=0x50505050; int k=0x00000005; int c=0,i; for(i=0;i<=31;) { if((n & k)==5) { c++; i=i+4; n=n>>4; } else { n=n>>1; i++; } } printf("%d times\n",c); } Program 37 Wap to print largest sum among the entire “hour-glass” pattern in given array? #include
main() { int i,j,sum=0,a[6][6]; int max=-2147483647; for(i=0;i<6;i++) { for(j=0;j<6;j++) scanf("%d",&a[i][j]); } for(i=0;i<6;i++) { for(j=0;j<6;j++) { if(j+2 < 6 && i+2 < 6) { sum=a[i][j]+a[i][j+1]+a[i][j+2]+a[i+1][j+1]+a[i+2][j] +a[i+2][j+1]+a[i+2][j+2]; if(sum>max) max=sum; } } } printf("max sum =%d\n",max); } Program 38 Wap to print digit value from last in given number ? #include
int findDigit(int ,int); void main() { int num, n,digit; printf("enter number \n"); scanf("%d",&num); printf("enter digit number\n"); scanf("%d",&n); n = findDigit(num,n); if(n==0) printf("given digit number is not found\n"); else printf("Digit is %d\n",n); }i nt findDigit(int num, int n) { int ret; while(n--) { ret = num%10; num = num/10; } return ret; } Output enter the number 987 enter the digit 37 Program 39 Wap to reserve and re-set the seat in the theatre. ? #include
void main() { int a[5][5]; int i,j,n,count =0; char ch; for(i=0;i<5;i++) for(j=0;j<5;j++) a[i][j]=0; printf("All 25 seats are available right now\n"); while(1) { printf("enter seat number to reserve\n"); scanf("%d",&n); if(n>25) printf("Invalid Seat no"); else { count = 0; for(i=0;i<5;i++) { for(j=0;j<5;j++) { count++; if(count==n) { if(a[i][j]==0) { printf("Seat no is reserved\n"); a[i][j]=1; } else if(a[i][j]==1) printf("Seat is already reserved\n"); } } } } printf("Do you want to reserve another seat: YES or NO\n"); scanf(" %c",&ch); if(ch=='y'||ch=='Y') continue; else break; } printf("\nSeating arrangement : R- reserved, A- available\n"); for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(a[i][j]==0) printf("A "); else printf("R "); } printf("\n"); } } Program 40 Implement user-define sqrt() function ? Code 1 #include
void sort(char *); main() { int n,sum=1,i,j,k; char a[10]; printf("Enter a number to find square root\n"); scanf("%d",&n); for(j=2,i=0;n!=1;j++) { if(n % j ==0) { a[i++]=j; n=n/j; j=1; } } for(j=0;j
p[j]) { ch=p[i]; p[i]=p[j]; p[j]=ch; } } Code 2 #include
main() { float m,n=0.001,i; printf("Enter number to find square root\n"); scanf("%f",&m); for(i=0;;i=i+n) { if((i*i)>m) { printf("i=%f\n",i); i=i-(n/10); break; } } printf("Sqrt is %0.2f\n",i); }
« Prev
Next »
Helpful Links
Sateeshkg Home
Interview Questions
Corporate Training
Recommended Books
Linux Consulting
Apply for Job Assistance
If you have any queries please email us at
info@motionzen.com