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 II
« Prev
Next »
UST Global- Interview Questions II
Program 16 Write a program for Addition using shift operator #include
main() { int a,b,c,res; printf("enter 2 number\n"); scanf("%d%d",&a,&b); while(b!=0) { c=a&b; a=a^b; b=c<<1; // printf("b = %d\n",b); } printf("addition = [%d]\n",a); } Program 17 Write a c program for Addition using shift operator #include
main() { int a,b,r; printf("enter two number :\n"); scanf("%d%d",&a,&b); r=printf("%*s%*s",a," ",b," "); printf("sum of [%d] and [%d] is : [%d]\n",a,b,r); } /* here * is present in b/w % and s , the printf() will print the string "" after 10 space and "" after 20 spaces and then the printf() will return 30 as , it has printed 30 characters, so o/p will be 30 */ Program 18 Write a c program for comparison #include
main() { int a,b; printf("enter 2 numbers\n"); scanf("%d%d",&a,&b); !(a^b) ? printf("same\n") : printf("different\n"); } Program 19 Write a c program for deletion #include
main() { int num,pos,bit,i,j; printf("enter the number:\n"); scanf("%d",&num); printf("enter the position:\n"); scanf("%d",&pos); printf("how many bits u want to delete:\n"); scanf("%d",&bit); printf("before deleting anything no is:\n"); for(i=31;i>=0;i--) { printf("%d",num>>i&1); if(i%8==0) printf(" "); } //...logic for(i=pos,j=pos+bit;j<=31;i++,j++) { if((num>>i&1)!=(num>>j&1)) num=num^(1<
=0;i--) { printf("%d",num>>i&1); if(i%8==0) printf(" "); } } Program 20 Write a c program for 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,j=j-1;j>i;i++,j--) { c=a[i]; a[i]=a[j]; a[j]=c; } for(i=0;a[i];i++) { if(a[i]>='0' && a[i]<='9') b[i]=a[i]-48; else if(a[i]>='a' && a[i]<='f') b[i]=a[i]-87; else if(a[i]>='A' && a[i]<='F') b[i]=a[i]-55; else { printf("Wrong input\n"); return; } } j=strlen(a); b[i]='\0'; for(i=0;i
main() { int a,b,c,max,res; printf("enter two number:\n"); scanf("%d%d",&a,&b); c=a-b; res=(c>>31)&0x1; max=a-res*c; printf("max=%d\n",max); } Program 22 WAP for Multiplication #include
main() { int a,b,sum=0,i,j; printf("enter 1st and 2nd number\n"); scanf("%d%d",&a,&b); for(i=31;i>=0;i--) { if(b & 1<
#include
static char a[100]; static int i=2; void swap(int j,int k) { char temp; if(((a[j]>=65)&(a[j]<=90))|((a[j]>=97)&(a[j]<=122))) { if(((a[k]>=65)&(a[k]<=90))|((a[k]>=97)&(a[k]<=122))) { temp=a[j]; a[j]=a[k]; a[k]=temp; }}} main() { printf("enter string\n"); gets(a); while(a[i]) { swap(i,i+1); i=i+4; } printf("%s\n",a); } Program 24 WAP Square root #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; } } Program 25 WAP Suqart short #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); } Program 26 WAP Subtraction #include
main() { int a,b,c,res; printf("enter 2 number\n"); scanf("%d%d",&a,&b); while(b!=0) { c=(~a)&b; a=a^b; b=c<<1; printf("a = %d b = %d c= %d\n",a,b,c); } printf("subtraction = [%d]\n",a); } Program 27 Write a program to print sum of 4, 100 digits decimal number. #include
main() { int a[100], b[100], c[100], d[100], r[101], cy=0; int i; for(i=0;i<100;i++) a[i]=b[i]=c[i]=d[i]=9; for(i=99;i>=0;i--) { r[i+1]=a[i]+b[i]+c[i]+d[i]+cy; cy=r[i+1]/10; r[i+1]=r[i+1]%10; } r[0]=cy; for(i=0;i<=99;i++) printf("%d",r[i]); } Output: 399999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999 Program 28 Write a function to get the value between two given bit positions from an integer? #include
main() { int n1,n2,n,num=0,i,j; printf("Enter a number\n"); scanf("%d",&n); printf("Enter bit positions\n"); scanf("%d%d",&n1,&n2); for(i=n1+1;i
>(n1+1); // shift previous j to correct position printf("The number between bit position [%d] & [%d] is [%d] \n",n1,n2,j); } Program 29 Wap to find how many 1's having 0 on its right side and 1 on left side( i.e 110) in given hexadecimal number ? #include
main() { int n,x=6, i,c=0; printf("Enter the hexadecimal number\n"); scanf("%d",&n); for(i=0;i<=31;) { if(((n>>i)&x)==6) { c++; i=i+3; } else i++; } printf("110 is %d times\n",c); } Program 30 Wap to convert given integer value into Boolean. #include
#define boo(x) (x==0 ? x : 1) main() { int i,n; printf("Enter a number\n"); scanf("%d",&n); i=boo(n); printf("Bool for n is %d\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