Вы находитесь на странице: 1из 45

Back to Questions Page Question How to write a code for random pick from 1-1000 numbers?

The output should contain the 10 numbers from the range 1-1000 which should pick randomly, ie ,for each time we run the code we should get different outputs. Rank Answer Posted By Question Submitted By :: Umesh Koodali This Interview Question Asked @ NetApp I also faced this Question!! ALL Interview .com Answer #include <stdlib.h> #include <stdio.h> #include <time.h> int main(void) { int i; randomize(); printf("Ten random numbers from 0 to 1000\n\n"); for(i=0; i<10; i++) printf("%d\n", rand() % 100); return 0; } 5 Navdeep Singh Question WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS Rank Answer Posted By Question Submitted By :: Guest I also faced this Question!! ALL Interview .com Answer #include<conio.h> #include<stdio.h> void main() { int a[2][2],b[2][2],c[2][2];//declare 3 array int type int i,j,k; for(i=0;i<2;i++) { for(j=0;j<2;j++) { } scanf("%d",&a[i][j]);//inserting element in array a } for(i=0;i<2;i++)

{ for(j=0;j<2;j++) { } scanf("%d",&b[i][j]);//inserting element in array b } for(i=0;i<2;i++) { for(j=0;j<2;j++) { for(k=;k<2;K++) { c[i][j]+=a[i][k]*b[i][j];//multiply of a and b } } } for(i=0;i<2;i++) { for(j=0;j<2;j++) { printf("%d",a[i][j]);//printing element of array c } } }//main close 0 Shubham Singh Question simple c program for 12345 convert 54321 with out using string Rank Answer Posted By Question Submitted By :: Krtraj I also faced this Question!! ALL Interview .com Answer hi good morning folks... happy sunday....... #include<stdio.h> #include<conio.h> void main() { int n,m; printf("enter the number :"); scanf("%d",&n); for(int i=1;n>0;i++) { m=n%10; n=n/10; printf("\n %d",m); } getch(); } thank u

0 Vignesh1988i

Question convert 12345 to 54321 withoutusing strig Rank Answer Posted By Question Submitted By :: Krtraj I also faced this Question!! ALL Interview .com Answer #include<stdio.h> #include<conio.h> void main() { int i,j; printf("enter a number"); scanf("%d",&i); for(int n=1;n<=5;n++) { j=i%10; i=i/10; printf("%d",j); } getch(); } 0 Satrughna Sethi Question can we print any string in c language without using semicolon(;)(terminator) in whole program. Rank Answer Posted By Question Submitted By :: Pushpendra I also faced this Question!! ALL Interview .com Answer #include<stdio.h> int main() { while(printf("Hai")&&0){} } 0 Vinothkumar.r Answer

#include<stdio.h> void main() { if(printf("Hello")){} } 0 Nitish_bhasin Answer #include<stdio.h> void main() { while(printf("hello")?0:1) { } } 0 Gauravjeet Singh Gill Question program for validity of triangle from 3 side Rank Answer Posted By Question Submitted By :: Pictpatanga I also faced this Question!! ALL Interview .com Answer if a<c and b<c then c<a+b 0 Chandra Answer if(a < (b+c)) if( b < (c+a)) if(c < (a+b)) printf("its a triangle\n"); 0 Pritam Question find a number whether it is even or odd without using any control structures and relational operators? Rank Answer Posted By

Question Submitted By :: Vignesh1988i This Interview Question Asked @ Microsoft , Shashank Private Limited, Nagpur I also faced this Question!! ALL Interview .com Answer #include<stdio.h> int main() { int n=10000; char *s[2]={"Even","Odd"}; printf("%s",s[n&1]); return 0; } 0 Vinocit Answer A number anded with the lower number that is n & (n - 1) = 0 then it is even if it is anything else it is odd odd_even (int n) { if (!(n & (n -1)) number is odd else number is even } 0 Ramya Answer But its much efficient just to find whether the last bit is 0 or 1 0 Vinothkumar.r Answer the first answer is excellent .... superb..... this is what i expected........ marvalous.......... congrats

thank u 0

Vignesh1988i Answer #include<stdio.h> main() { int n; char *p[]={"Even","odd"}; Printf("Enter the number"); scanf("%d",&n); n=n%2; printf("The value is %s",a[n]); } 0 D.c.sathishkumar Answer #include<stdio.h> main() { int n; string p[2]={"Even","odd"}; Printf("Enter the number"); scanf("%d",&n); n=n%2; printf("The value is %s",p[n]); } 0 Vamsi Answer THE LAST two answers posted by two folks are correct but the declarations have been made wrong...... we cant make use of 1D array here , if so only 'e' or 'o' only will get printed.... but that is not our aim... so correct declaration is using a 2D array..... char a[][6]={{"even"},{"odd"}}; and also it is not the must to make use of array of pointers concept........... thank u 0 Vignesh1988i

Answer #include<stdio.h> #include<conio.h> void main() { int x; if(x%2==0) printf("even"); else printf("odd"); getch(); } 0 Guest Answer mind you sir == is an relational operator.................

thank u 0 Vignesh1988i Answer #include<stdio.h> main() { int n; string s[2]={"Even","odd"}; Printf("Enter the number"); scanf("%d",&n); n=n%2; printf("The value is %s",s[n]); } 0 Shashi Question why the execution starts from main function Rank Answer Posted By Question Submitted By :: Guest I also faced this Question!! ALL Interview .com Answer

it is the first function to be called or to be executed in the code of the compiler.......

thank u 0 Vignesh1988i Answer their will be a program written for creating a compiler..... so in that main() may be a first function call for that coding written in compiler

thank u 0 Vignesh1988i Answer the main function receives command line arguments and so if v pass any command line arguments as in put they have to b taken and executed for this reason the execution starts from main 0 Vamsi Answer The c run time system inserts some start up code before the main function and inserts some clean up code at the end of the program . The operating system loads the executable of the program in to the memory with the help of the loader and transfers the control to theprogram . 0 Vrushali Answer main is a special inbuilt function which is used to start the execution of the program,and the compiler searches for this function to start the execution of the program.

0 Rahat Question wap to print "hello world" without using the main function. Rank Answer Posted By Question Submitted By :: Rockon2050 This Interview Question Asked @ TCS I also faced this Question!! ALL Interview .com Answer the basic format or the first executable code line is the main function in C.... so if we try to print the anything without main we are trying to modify the basic concepts of C and this will not look nice.... thank u 0 Vignesh1988i Answer by using the comment lines we can get the output 0 Thirupathi Reddy Answer To display "hello world" printf("\"hello world\""); 0 Raghuram Answer main() method is the entry point for any c/c++ program which is compiled/linked as executable. C/C++ does not force anyone to use only main() method as the entry point. This is only the default behavior and can be changed. This is generally slightly different for different compiler. But you can do this.. Simply define any other method say noMe() to be the entry point for the executable. Who the hell uses main()to do main stuffs in any executable.. It should have been called something like start() ot begin().. :)

Well this is not the answer.. Just little guidance.. 0 Kk Answer And some deserts for Mr. Vignesh1988i .. For your kind attention sir.. Method main() is not the first line in any executable... Have you ever heard of initialization?? Yes you can say what ever the developer writes in any program starts in main().. 0 Kk Answer Here is a basic sample which uses main as the entry point.. #include <stdio.h> #define myProxyMain main int myProxyMain() { printf("\nHello World !!"); getchar(); return 0; } Just note that at source level there is no main but once preprocessing we still have the old main() method.. Which means we still have the main method in the object module as well as the executable.. 0 Kk Answer #include<stdio.h> #include<conio.h> printf("hello world"); 0 Guest Answer #include<stdio.h> #define nitish main void nitish()

{ printf("Hello World"); } 0 Nitish_bhasin Back to Questions Page Question Reverse a string word by word?? Rank Answer Posted By Question Submitted By :: Varu I also faced this Question!! ALL Interview .com Answer #include<stdio.h> #include<conio.h> void main() { char a[40],temp; int count=0; printf("enter the string :"); gets(a); for(int i=0;a[i]!='\0';i++) count++; for(i=0;a[i]!='\0';i++) { if(count>i) { temp=a[i]; a[i]=a[count-1]; a[count-1]=temp; count--; } else break; } printf("the reversed ones is : "); puts(a); getch(); } thank u 0 Vignesh1988i Answer #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h>

void main() { int n,i,j=0; char str[100]; char str1[100]; clrscr(); puts("Enter string:"); gets(str); n=strlen(str); for(i=n-1;i>=0;i--) { if(str[i]==' ') { str1[j]='\0'; strrev(str1); printf("%s ",str1); j=0; } else { str1[j++]=str[i]; } } if(i==-1) { str1[j]='\0'; strrev(str1); printf("%s ",str1); } getch(); } //strtoke //isvowel 0 Vishnu948923 Answer strrev(str1,str2); 0 Guest

Answer #include<iostream.h> #include<string.h> #include<stdio.h> #include<conio.h> void main() {

int length,i,j; char string[500];clrscr(); printf("Enter the string="); gets(string); length=strlen(string); int y=length,z=0; for(i=length-1;i>=0;i--) { if(int(string[i])==32) { printf(" "); for(j=i+1;j<length;j++) { printf("%c",string[j]); z++; } length=y-z; } if(i==0) { j=i; printf(" "); while(int(string[j])!=32) { printf("%c",string[j]); j++; } } } getch(); } 0 Rohit_Kamlakar Answer #include<stdio.h> #include<conio.h> void main() { char a[40],temp; int count=0; printf("enter the string :"); gets(a); for(int i=40;a[i]!=a[1];i--) printf (a[i]); printf (a[1]); } 0 Vamsi Question tell me the full form of c?

Rank Answer Posted By Question Submitted By :: Mangal I also faced this Question!! ALL Interview .com Answer C is the successor of the language of B... so their is no any full forms for C... it's just an alphabet 0 Vignesh1988i Answer although some says that C's abbreviation is compiler (as if it is compiler based language) i will agree vth first answer 0 V Amsi Question write a function which accept two numbers from main() and interchange them using pointers? Rank Answer Posted By Question Submitted By :: Praveen I also faced this Question!! ALL Interview .com Answer #include<iostream.h> #include<conio.h> void main() { int a,b; void swap(int *,int *); //Functioin Prototype clrscr(); cout<<"\nEnter the number::\n"; cin>>a>>b; cout<<"\nValues before INterchange are \na=<<" and \nb="<<b; swap(&a,&b); //Functiion Calling

cout<<"\nValues after interchange\na=<<" and \nb="<<b; getch(); } void swap(int *a,int *b) int temp; temp=*a; *a=*b; *b=temp; } //Function Defintioon

Thanks friends if any mistake pls coorect it by again urs answer 0 Amritpal Singh Answer #include<stdio.h> #include<conio.h> void main() { int a,b,*ptr1,*ptr2,temp; printf("enter the values "); scanf("%d%d",&a,&b); ptr1=&a; ptr2=&b; temp=(*ptr1); *ptr=(*ptr2); *ptr2=temp; printf("\n now the values are a=%d b=%d ",a,b); getch(); } thank u 0 Vignesh1988i Answer #include<stdio.h> main() { int *p,*q; *p=10; *q=20 void swap(int &p,int &q); } void swap(int *x,int *y); { int *tmp; *tmp=*x; *x=*y; *y=*x; printf("%d,%d",*x,*y); } 0 Sarathi

Question any string of bits of length 'n' represents a unique nonnegative integer between.............? Rank Answer Posted By Question Submitted By :: Praveen I also faced this Question!! ALL Interview .com Answer 2^n 0 Vinocit Question if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order? Rank Answer Posted By Question Submitted By :: Praveen I also faced this Question!! ALL Interview .com Answer always the 2D array will be stored in column order only , in C.... so only , it is a must that we must specify the column subscript however we miss the row subscript..... thank u 0 Vignesh1988i Answer it's order is a[5,5] because it takes 2 bytes for every elements i.e a[1,1]=1000 a[1,2]=1002 a[1,3]=1004 a[1,4]=1006 a[1,5]=1008 a[2,1]=1010.............. 0 .................... Answer The order of array cannot be defined as we dont know the max size of the array. however we can calculate the column subscript of the array as followsa[1,1] = 1000, a[1,2] = 1002, a[1,3] = 1004, a[1,4] = 1006, a[1,5] = 1008. After this the 2nd row will start as a[2,1] = 1010, and so

on. So we can define the no. of columns, i.e. 5, in this array but not the no. of rows. 0 Parul_Kul Question main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how? Rank Answer Posted By Question Submitted By :: Geetha I also faced this Question!! ALL Interview .com Answer This output is 4 2 4 Explanation: sizeof('1 or 2 or 3,......or n')=4 sizeof("0")=2 sizeof("10")=3 sizeof("100")=4 sizeof("1000")=5 sizeof("10000")=6 . . . . . sizeof("n")=n sizeof(1 or 2 or 3......or n)=4 3 K.thanigaivel Answer 1 2 4 0 Manik Answer 4 2 4

sizeof('3') means it will take ascii value which is an integer, it shows size of integer. sizeof("3") means, here it will treat it as an array, it will print size of an array, so array contain '3' and '\0' so out put is 2. try size("3ashwin") it will give 8 as out put. sizeof(3) means directly we asking size of an integer. thank you if is an wrong answer plz write correct answer to molugu.ashwin@gamil.com 0 Ashwin Answer Answer is : 1 2 2 because sizeof('3')takes 3 as character and so, size of a character is 1 byte sizeof("3") takes 3 as a string so, here strinf contains one character 3 and end character '\0'. so, sizeof("3") gives o/p 2 and sizeof(3) takes 3 as integer so size of an integer is 2 bytes 0 Vinay Kabra Answer answer is :1 2 2 ; size('3')means character constant so it is short int size it will ocupi 1. size("3")it will treated as string. 2 size(3) it is integer 2 0 Raj Answer o/p 1 2 2

sizeof('3')takes 3 as character and so, size of a character is 1 byte sizeof("3") takes 3 as a string so, one character 3 and end character '\0'. so, sizeof("3") gives o/p 2 and sizeof(3) takes 3 as integer so size of an integer is 2 bytes 0 Deepali Chandra Question main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain Rank Answer Posted By Question Submitted By :: Geetha I also faced this Question!! ALL Interview .com Answer the o/p depends upon the compiler and cant be predicted wat's hapenning inside .... each will have different opinion.....my opinion is : here in the first printf statement "good morning" acts as an string and 5+"good morning" means print the string after the 5th character in the string starting from 0.... so o/p is : morning for second one : this printf can be re-written as the first printf statement printf("%c",4+"abcdefgh"); here only the 4th character will get printed ... in this case it will print 'e'.. thank u 0 Vignesh1988i Question what is link list?

Rank

Answer Posted By

Question Submitted By :: Guest I also faced this Question!! ALL Interview .com Answer list are the set of items which are brought from various parts and binded together in which each data may or may not be having relation..... linked list is basically set of data 's which has link (locative address) to refer the next data of that list... thank u 0 Vignesh1988i Question Write a C program that reads a series of strings and prints only those ending in "ed" Rank Answer Posted By Question Submitted By :: Saphira I also faced this Question!! ALL Interview .com Answer void main() { char *s[10]; int n; printf("No of strings:"); scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%s",s[i]); } for(i=1;i<=n;i++) { int len; len=strlen(*s[i]); len=len-1; if(*s[len]='e' && *s[len--]='d') { printf("%s",*s[i]); } else { printf("no match"); } } getch(); } } 0 Antony From Chennai

Question void main() {int a[5],i,b=16; for(i=0;i<5;i++) a[i]=2*i; f(a,5,b); for(i=0;i<5;i++) printf("\n %d",a[i]); printf("\n %d",b); } f(int *x,int n,int y) { int i; for(i=0;i<n;i++) *(x+i)+=2; y=y+2; }wat r the errors in the prg.and improvise the prg to get o/p.? Rank Answer Posted By Question Submitted By :: Agita I also faced this Question!! ALL Interview .com Answer 2 4 6 8 10 16 0 Masakali Answer so , i can understand at first you are inputting implicitally the values in the array using the variable used in for loops... then you are changing the values again by writing the function... sending the base address of the array.. then only once the y value will get added by 2... as for as me their is no error in your program... so ur o/p will be : 2 4 6 8 10 16 BUT IN ORDER TO MAKE OUT THE VALUE OF 'Y' TO BE INCREMENTED FOR EACH VALUE IN THE LOOP AND TRY TO MAKE CHANGE DIRECTLY IN THE ADDRESS , make these corrections f(a,5,&b); , f(int *x,int n,int *y) , the for loop may be like this : for(i=0;i<n;i++) { (*(x+i))=(*(x+i))+2;

(*y)=(*y)+2; } after this ur o/p will be : 2 4 6 8 10 26 thank u 0 Vignesh1988i Question wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain Rank Answer Posted By Question Submitted By :: Geetha I also faced this Question!! ALL Interview .com Answer this is declaration as well as definition.... according to me., DECLARATION here means that for some maniplation inside the program we are going to use that variable y... but what is y we want to tell the compiler so we are giving a new DEFINITION to the alphabet as float DATA TYPE and thus we are making the full variable thank u 0 Vignesh1988i Answer the diff b/w defination and declaration is defination is allocating memory to the variable ddeclaration is telling what type of variable it is and not allocating memory for it float y is defination as compiler allcates memory for it if you give as extern float y it is declaration 0 Kantilal

Question #include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf("hello \n"); return 0; } int fun() { printf("hi"); } answer is hello.how??wat is tat while(i) mean? Rank Answer Posted By Question Submitted By :: Geetha_raj2007 I also faced this Question!! ALL Interview .com Answer I am not an expert but you can try one thing that I did. Remove the while loop and put the follow if (i) printf ( "hi\n" ); The result is that printf statement never gets any print out! My guess would be because the value of 'i' is NOT defined so, that while loop doesn't get assess at all! So, the result is only "hello" 0 Who Cares Answer see first of all variable 'i' is declared as a global storage class variable .. so according to that storage class whenever we define an variable i before the main function and explicatily we haven't initilized that variable means it will defaultly variable i will have 0.... so when this while is compiled i has 0 which makes the loop false.. so it will compile the very first statement after that loop... so it prints hello........... thank u 0

Vignesh1988i Answer in response to the previous answer... there is no storage class specification for i..so by default it is auto..if an auto variable is not initiallized it would give a garbage value..then how come while(0)....? 0 Agita Answer As "int i" is not defined/declared inside any function, by default it is declared as external variable not as auto. Thats why, it takes the 0 as its default value. 0 Parul_Kul Back to Questions Page Question can we print any string without using terminator? Rank Answer Posted By Question Submitted By :: Pushpendra This Interview Question Asked @ Infosys , Infosys I also faced this Question!! ALL Interview .com Answer Yes, We can print the string without using the terminator. like this #include <stdio.h> int main() { if(printf("this is yogesh")) { printf("then you must be good boy"); } return 0; } Its a working example. when the control comes to if() statement. first it will execute the printf statement inside if() and the printf function will return number of character printed which is an integer value and if() is true for any value greater than 0. so it will go inside and execute the rest of the code.

Hope the explanation is clear to you. 0 Yogesh Bansal Question HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER Rank Answer Posted By Question Submitted By :: Guest I also faced this Question!! ALL Interview .com Answer I Am the Person who is very co-operative and what ever i do i do with fully dedication.i donot give-up the problams untill unless i will not find any optimistic solution for that problam.and i am also very down to earth.i belive if you have something so there is no need to show that thing. thank you. 0 Amit Kumar Sisodia Question write program on arrays Rank Answer Posted By Question Submitted By :: Guest This Interview Question Asked @ GE , Poly I also faced this Question!! ALL Interview .com Answer #include<sotdio.h> #include<conio.h> void main() { int a[5]; int b=1; while b<5; printf("/n enter value of a1"); scanf("%d",a0); printf("/n enter value of a1"); scanf("%d",a1); printf("/n enter value of a1"); scanf("%d",a2); printf("/n enter value of a1"); scanf("%d",a3); printf("/n enter value of a1"); scanf("%d",a4); printf("/n values are :- %d, %d, %d, %d, %d"a[i]); getch();

clrscr(); } 0 Shrish Cahndra Tripathi

Answer #include<stdio.h> #include<conio.h> void main() { int a[10],i; for(i=1;i<=10;i++)//getting data from user { scanf("%d",&a[i]); } for(i=1;i<=10;i++)//print the data { printf("%d",a[i]) } getch(); } 0 Antony Question main() { float a=3.2e40; printf("%d",a); } Rank Answer Posted By Question Submitted By :: Iftekhar This Interview Question Asked @ Satyam I also faced this Question!! ALL Interview .com Answer as for as i know , here however 'a' is a float variable when it comes to printf , the floating numbers will be truncated and it outputs as 3 thank u 0 Vignesh1988i Answer

i run this and i found that the answer is zero because a is declared as float and it is print ans integer and its mantissa part is also a float therefore the output is zero. thank you... 0 Pankaj Bhalerao Answer main() { int i=300*300/300; printf("%d",i); } 0 Iftekhar Answer after running the program i got the answer is 0. 0 Pushpanjali Panda Answer the o/p=0 because here we are trying to print the value in int form which has been of float datatype.since float has a higher precendence over int therefore it will give the o/p=0 and similarly after this every output will be =0.this is the function of the compiler that we cannot print the value of a higher data type using a lower datatype. 0 Deepali Chandra Question main() {int a=200*200/100; printf("%d",a); } Rank Answer Posted By Question Submitted By :: Amir This Interview Question Asked @ TCS I also faced this Question!! ALL Interview .com

Answer output is : 400 0 Vignesh1988i Answer 400 0 Pawan Singh Answer a=200*200 =40000/100 =400 a=400 0 Jaga Answer 400 0 Ismail Answer 200*200=40000; as the range of int(-32768 to +32767) 40000 exeeds +32767 &hence goes to the other side, 40000-32767=7233; now (-32768+7233)=(-25535); hence the value of 40000 will be -25535; result be (-24435/100)="-244"(integer value). thank u 0 Pravin Question main() { int arr[5]={23,67};

printf("%d%d%d",arr[2],arr[3],arr[4]); } Rank Answer Posted By Question Submitted By :: Shahzad This Interview Question Asked @ TCS I also faced this Question!! ALL Interview .com Answer The rest will be initialized to zero ....so it'll be 000 .. 0 Vikas Upendra Answer all wil print the garbage values in the respected memories... since we only initilized for two locations in th array.... so other locations in the array wil have garbage values 0 Vignesh1988i Answer in linux it will give garbage values... in unix it will give 000(automatically initialized to 0) 0 Jaga Answer 000 0 Kantilal Answer garbage value 0 Ismail Question writw a program to insert an element in the begning of a doubly linked list

Rank Answer Posted By Question Submitted By :: Guest I also faced this Question!! ALL Interview .com Answer #include<stdio.h> typedef struct node { int data; struct node *leftlink; struct node *rightlink; }node; node *start=NULL; node *tail=NULL; void add_begin(node *); main() { ....... ....... add_begin(start); ....... ....... } void add_begin(node *temp) { node *new_node=NULL; int idata; printf("enter the data part value: "); scanf("%d",&idata); if(start==NULL && tail==NULL ) { new_node=(node *)malloc(sizeof(node)); new_node->data=idata; new_node->leftlink=NULL; new_node->rightlink=NULL; start=new_node; tail=new_node; } else { new_node=(node *)malloc(sizeof(node)); new_node->data=idata; temp->leftlink=new_node; new_node->rightlink=temp; new_node->leftlink=NULL; start=newnode; } } 0 Mani

Question how to print value of e(exp1)up to required no of digits after decimal? Rank Answer Posted By Question Submitted By :: Vijay Kumar I also faced this Question!! ALL Interview .com Answer i dont no the answer please tell that answer 4 Sundarapandian Question create an SINGLE LINKED LISTS and reverse the data in the lists completely Rank Answer Posted By Question Submitted By :: Vignesh1988i I also faced this Question!! ALL Interview .com Answer create linklist, with node having DATA which contain information and NEXT which cointain address of next node. The pointer START pointing to first node of linklist. PREV pointer point to first node(where START point) and TEMP pointer which point at last node(by traversing). Swap data of TEMP and PREV. Now increment TEMP(TEMP=TEMP>NEXT) and decreament TEMP. Repeat this untill TEMP=PREV 0 Akansha Sharma Answer dear sir , your logic might be incorrect , AND GIVE THE FULL PROGRAM SIR sir you have told that TEMP pointer which point to the last node.... ok ,for first you can swap the data.... ie STARTING to TEMP. but how will you arrive at next pair of node for swapping by decrementing the TEMP , ... a single linked lists can travel only in one direction from HEAD till NULL ...... THANK U

0 Vignesh1988i Question what is the output for the code : main() { int i,j; printf("%d %d ",scanf("%d%d",&i,&j)); } Rank Answer Posted By Question Submitted By :: Vignesh1988i This Interview Question Asked @ Infosys I also faced this Question!! ALL Interview .com Answer no out put 0 Rampoojan Gupta Answer The user will enter two nos. The output will be- 2 <First no. entered> 4 Monish Answer First of all, we need to give two integer number as input.Since scanf return the no of arguments passed to it, except format specifier.So out is: 2,unknown valu e 0 Vantees Answer The result of this program will be: you have to enter two int numbers output : 2 <the last number entered> 5 Tasneemuddin Answer

ans 1 2 0 Nitin Sharma Answer 2 2 0 Satish Kondapalli Answer what input to give that number can display 0 Sundar Answer the output will be 2(no. of inputs) <last number entered> 0 Vaibhav Answer first variable is used to print the no of inputs and remaining r used to print the values from the last i.e.third second first.........so on.. 0 Shahzad Answer first the computer will take the two values as inputs & then will show junk value 0 Prashant Sharma Answer for give input is 1 2 an output is 22

0 Sundar Question 5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer Rank Answer Posted By Question Submitted By :: Mreddy I also faced this Question!! ALL Interview .com Answer #include <stdio.h> #define FEETS 5280 #define INCH 12 #define CENTIMETER 2.54 #define CMPERKM 100000 int main() { unsigned int miles=0; unsigned feets; unsigned inches; double centimeter; double KM; printf("please enter the distance in miles\n"); scanf("%u",&miles); feets = miles * FEETS; printf("the distance in feets %u\n",feets); inches = feets * INCH; printf("the distance in inches %u\n",inches); centimeter = inches * CENTIMETER; printf("the distance in centimeter %fd\n",centimeter); KM = centimeter/CMPERKM; printf("the distance in KM %fd\n",KM); return 0; } 0 Yogesh Bansal Question 4.weight conversion: Write a program that will read weight in pounds and convert it into grams.print both the original weight and the converted value.There are 454 grams in a pound.design and carry out a test plan for this program. Rank Answer Posted By Question Submitted By :: Mreddy This Interview Question Asked @ Wipro I also faced this Question!! ALL Interview .com

Answer i#includ<tdio.h> #include<conio.h> void main() { float pounds , grams; clrscr(); printf("enter ur weight in pounds :"); scanf("%f",&pounds); printf("%f pounds is equivalent to %f grams ",pounds,pounds*454); getch(); } thank u 0 Vignesh1988i Question 2.Given the short c program that follows a. make a list of the memory variables in this program b.which lines of code contain operations that change the contents of memory? what are those operations? Void main( void) { Double base; Double height; Double area; Printf( enter base and height of triangle : ); Scanf( %lg , &base); Scanf( %lg , &height); Area=base*height/2.0; Printf( the area of the triangle is %g \n ,area); } Rank Answer Posted By Question Submitted By :: Mreddy This Interview Question Asked @ Wipro I also faced this Question!! ALL Interview .com Answer 1 void 2{ 3 4 5 6 7 8 9 10 11} main( void) double base; double height; double area; printf("enter base and height of triangle :"); scanf("%lg", &base); scanf("%lg", &height); area=base*height/2.0; printf("the area of the triangle is %g \n",area);

Answer for a. 3 double base;

4 5 Answer 7 8 9

double height; double area; for b. scanf("%lg", &base); scanf("%lg", &height); area=base*height/2.0;

Operations ----------The scanf() function scans input from the file designated by stdin under control of the argument format. The format string here is %lg to get double. Following the format string is the list of addresses of items to receive values. and and assignment operation Back to Questions Page Question what is the use of keyword volatile?? Rank Answer Posted By Question Submitted By :: Guest This Interview Question Asked @ LG-Soft I also faced this Question!! ALL Interview .com Answer volatile keyword is a one in which assigns some garbage value to the variables declared with this keyword.......... before assigning some values by the user to the variables. 0 Vignesh1988i Answer Volatile qualifier indicates to the compiler that the variable can be modified at any stage of the program execution. This can happen even if the region of code being executed might not have any access to the variable in question. In that sense, Volatile qualifier does the opposite of the Const qualifier. @Vignesh1988i -> Volatile qualifier does not assign any garbage value to the variable. 0 Kishor Narayan Question An interactive c program to read basic salary of 15 persons. each person gets 25% of basic as HRA, 15%of basic as conveyance allowances, 10%of basic as entertainment allowances.The total salary is calculated by adding

basic+HRA+CA+EA.Calculate how many out of 15 get salary above 10,000.Rs also print the salary of each employee Rank Answer Posted By Question Submitted By :: Sushmitha I also faced this Question!! ALL Interview .com Answer #include<stdio.h> #include<conio.h> void main() { int salary[50],n,count=0,result[50]; float HRA,CON,JOLLY,TOT_salary; clrscr(); printf("enter no. of employees : "); scanf("%d",&n); for(int i=1;i<=n;i++) { printf("%d) ",i); scanf("%d",&salary[i-1]); HRA=0.25*salary; CON=0.15*salary; JOLLY=0.10*salary; TOT_salary=HRA+CON+JOLLY; printf("\nnet salary for %d) is :%f\n",i,TOT_salary); if(TOT_salary>10000) { count++; // TO COUNT EMPLOYEES GETTING MORE THAN 10,000 result[i-1]=i; //TO SAY WHICH SERIAL NO. GETS ABOVE 10,000 } } printf("the total no. of employees crossed rs. 10,000 is :%d & respected numbers as above is :",count); for(i=0;i<count;i++) printf("%d)\n ",result[i]); getch(); } 0 Vignesh1988i

Answer void main() { int COUNT=0,BS,HRA,CA,EA,TOTAL[20] ; FOR(int i=0;i<15;i++) { cout<<"enter basic salary"; cin>>BS; HRA=(BS/100)*25; CA=(BS/100)*15; EA=(BS/100)*10;

TOTAL=BS+HRA+CA+EA; cout<<"total salary of"<<i<< "employee is"<<TOTAL[i]; } FOR(INT I=0;I<=14;I++) { if(TOTAL[I]>=10000) COUNT++ } COUT<<"THE NUMBER OF EMPLOYEES ABOVE 10000 ARE"<<COUNT; } 0 Gunda Raj Question what is difference between c and c++ Rank Answer Posted By Question Submitted By :: Shailender I also faced this Question!! ALL Interview .com Answer C 1) C is an structured oriented language 2) C use structures where no function and data's inside involved . only outside we can write functions and initilization could be done 3) variables should be initilized on the first line after the main function 0 Vignesh1988i Answer C 1)Structured programing. 2)In build functions are used to allocate the memory dynamically. 3)Struct members are public by default. 4)Data and functions are separated. C++ 1)Object oriented programing. 2)New ,Delete operators are used to allocate the memory dynamically 3)class members are private by default. 4)Together data and functions into single entity. 0 Vantees C++ object oriented lang. here it contains classes where it contains both data's as well as member functions wherever we wann we can initilize the variable

Question Is main() function predfined or userdefined? Rank Answer Posted By Question Submitted By :: Naveenm I also faced this Question!! ALL Interview .com Answer userdefined 0 Ravi Answer it is a predefined function.............. 0 Vignesh1988i Answer predfined 0 Guest Answer The main function is predefine and have three arguments which return the value to the operating system and main is also called by operating system . 0 Subodh Sharma Answer "userdefined" because we are writing the code for main() or we are defining the boby for main() 0 Gunda Rajkumar Answer First we should know whether main() belongs to C/C++ or

java. If it is in C/C++ it is "user-defined" because not available in any header file and body defined by user, but compiler will starts body execution from main() function only. But in java without main() also we can execute programs and get output eg:-using static blocks. Here also it is "user-defined" one. 0 Nara Venkata Satyanarayana Question I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed Rank Answer Posted By Question Submitted By :: J I also faced this Question!! ALL Interview .com Answer #include<stdio.h> #include<conio.h> void main() { char a[50],temp; int count=0; printf("enter the string"); gets(a); for(int i=0;a[i]!='\0';i++) count++; for(i=0;i<count;i++) { for(int j=0;j<count;j++) { if(a[j]=a[j+1]; { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("\n"); puts(a); getch(); } thank u 0 Vignesh1988i Answer

#include <stdio.h> int main() { char arr[100]; int count =0; int j,i,k; char temp; printf("enter the string\n"); gets(arr); for(i=0;arr[i]!='\0';i++) count++; printf("value of count is %d\n",count); for(k=0;k<=count;k++) { for(j=0;j<count-1;j++) { if(arr[j]>arr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } puts(arr); return 0; } This is the correct and working program. 0 Yogesh Bansal Answer its working but not correct. 0 Chumurva Question what is the difference between structural,object based,object orientd programming languages? Rank Answer Posted By Question Submitted By :: Laxman This Interview Question Asked @ PanTerra I also faced this Question!! ALL Interview .com Answer In structural focus is more on procedures whereas in oject based focus is more o n data..

one mr thing.. structural follows top down approach whereas object oriented foll ows bottom up approach 0 Himanshu Singh Question What should not contain a header file? Rank Answer Posted By Question Submitted By :: Fahim I also faced this Question!! ALL Interview .com Answer header file should contain only declarations and structure templates.It should not contain function definitions. 0 Laxman Answer Head file should not contain defining instances of global variables and function bodies. 0 Ada Question In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory? Rank Answer Posted By Question Submitted By :: Praveen I also faced this Question!! ALL Interview .com Answer switch is faster because when in nested if condition has to check for each time. where as in switch it diectly check only labels. 0 Battini.laxman Answer as for as me is concerned switch is faster....

in if-else first it will check the if condition , if it is true it's no problem.. but if it falls false, it will go to the else part ... but in switch case , the argument given inside switch statement will see and automatically to the necessary case of it... so by comaring the time constraint ,switch saves the time for checking each else statement for every if.... thank u 0 Vignesh1988i Question what is the output of the following program? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++ l++; printf("%d %d %d %d %d",i,j,k,l,m); } Rank Answer Posted By Question Submitted By :: Vikram I also faced this Question!! ALL Interview .com Answer -1 -1 0 2 1 4 Nisha Answer 0 0 1 3 1 correct me if im wrong 0 Praveen Answer 0 0 1 3 1 as for as i know this is the output........ thank u

0 Vignesh1988i Question what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } } Rank Answer Posted By Question Submitted By :: Vikram I also faced this Question!! ALL Interview .com Answer 2222228344 0 Praveen Answer 2222228344... the above code can be remodified as : printf("%d",*q); in first printf statement to get the same output for both printf statements

thank u 0 Vignesh1988i Answer output is 2222228344 in loop 1

as we know that array variable contain the base address of the array *c means we are trying to print the value of contained in the base address which is not changed in the loop note we can't change the base address of the array that is we can't do 'c++' as in loop for 5 times contain of the base address will be printed as 22222

in loop 2 in assigned base address of the array to pointer p here we are printing the contain of address stored in p and increment the value of p ( that is pointing to the next element of the array ) so we will get output for 2nd loop is 28344 overall answer is 2222228344 if any wroung in my aswer plz info me at molugu.ashwin@gamil.com

Вам также может понравиться