| Back to Questions Page |
| |
| 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();
}  |
| 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;
}  |
| 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 C++
1) C is an structured oriented object oriented lang.
language
2) C use structures where no here it contains classes
function and data's inside where it contains both data's
involved . only outside we as well as member functions
can write functions and
initilization could be done
3) variables should be wherever we wann we can
initilized on the first line initilize the variable
after the main function  |
| 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.  |
| Vantees |
| |
| |
| 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.  |
| Tapan Pal |
| |
| |
| 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  |
| Ravi |
| |
| |
| Answer | it is a predefined function..............  |
| Vignesh1988i |
| |
| |
| Answer | predfined  |
| 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 .  |
| Subodh Sharma |
| |
| |
| Answer | "userdefined" because we are writing the code for main()
or we are defining the boby for main()  |
| 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.  |
| Nara Venkata Satyanarayana |
| |
| |
| Answer | main() is a predefined function because compiler starts
executing only in main() function. It better to press F7
function key after compiling your program because the
control first passes only to main() function  |
| M.kirthika |
| |
| |
| 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  |
| 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.  |
| Yogesh Bansal |
| |
| |
| Answer | its working but not correct.  |
| Chumurva |
| |
| |
| Answer | Then which one is the answer. i think the above one works
perfectly and they both will yield you the same results
which you wanted.
is this a tricky qustion? if so whats the answer for this  |
| Naveen |
| |
| |
| Question |
How can we open a file in Binary mode and Text mode?what is
the difference? |
Rank |
Answer Posted By |
|
Question Submitted By :: Laxman |
| This Interview Question Asked @ PanTerra |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | fopen("file1.txt","wb"); will open the file file1.txt in
binary read and write mode. Binary mode is useful to write
a file with 0s and 1s. For example, sometimes it would be
required to open a executable file. In that case, binary
mode is useful.
fopen("file1.txt","w"); will open the file1.txt in text
mode which means you can write regular letters and numbers
in that file.  |
| Sha |
| |
| |
| 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 on data..
one mr thing.. structural follows top down approach whereas object oriented follows bottom up approach  |
| 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.  |
| Laxman |
| |
| |
| Answer | Head file should not contain defining instances of global
variables and function bodies.  |
| 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.  |
| 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  |
| Vignesh1988i |
| |
| |
| Answer | switch statement is more faster and consumes less memory
than if-else statement the reason being that the switch
statement is applied when we have a single variable to
check but in case of if-else different variable may be
checked at the same time.  |
| Deepak Upadhyay |
| |
| |
| Answer | According to me, switch is faster. cause in nested if-
else, the checking occurs in each step. So, more the
compiler checks, the more it takes time. So switch case is
faster.  |
| Abhradeep Chatterjee |
| |
| |
| 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  |
| Nisha |
| |
| |
| Answer | 0 0 1 3 1
correct me if im wrong  |
| Praveen |
| |
| |
| Answer | 0 0 1 3 1
as for as i know this is the output........
thank u  |
| Vignesh1988i |
| |
| |
| Answer | 0 0 1 3 1  |
| Abhradeep Chatterjee |
| |
| |
| Answer | 0 0 0 3 1  |
| Dally |
| |
| |
| Answer | 0 0 1 3 1
m=-1&&-1&&0||2;//i.e,m=1;and i,j,m,l are incrimented  |
| Valli |
| |
| |
| Answer | 0 0 1 3 1
this answer is write  |
| Manojkumar |
| |
| |
| 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  |
| 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  |
| 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  |
| Ashwin Kumar |
| |
| |
| Answer | 2222228344 will be the answer. I think everybody answered
before me is correct.  |
| Abhradeep Chatterjee |
| |
| |
| Question |
What is the difference between constant pointer and pointer
to a constant. Give examples. |
Rank |
Answer Posted By |
|
Question Submitted By :: Narasimha |
| This Interview Question Asked @ TCS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Pointer to constant: If pointer is pointing to constant
variable is caller pointer to constant. We can not change
the value of that constant.
const int constVariable = 6;
int *ptrConstVar = &constVariable;
Constant Pointer: We declare a pointer as constant. We can
change the content pointed by pointer. But we can not do any
airthmatic operation on the pointer like increment or decrement.
int localVariable =10;
const int *p = &localVariable;
we can not do p++ or p--;  |
| Santosh |
| |
| |
| Answer | Constant pointer :
it is a pointer which points to the same memory location or
to same address and and whatever value the variable which is
pointed by the pointer holds.
for eg :
char a;
char const *p;
p=&a;
here var. a is a memory location having a address and that
variable contains some character data . but this pointer
p points to the same address ( a ) however the value in
var. a changes. finally, THE POINTER POINTED TO AN ADDRESS
IS A CONSTANT ,WHATEVER THE VALUE INSIDE THE VARIABLE MAY BE..
POINTER TO A CONSTANT :
this is a pointer which points to a constant variable
assigned to that pointer. and another pointer can also be
assigned to a same const. variable to point to.
for eg :
char Const a;
char *p,*q;
p=&a;
q=&a;
thank u  |
| Vignesh1988i |
| |
| |
| Answer | ya, vignesh, your answer is correct. thanx for giving such
a good answer.  |
| Abhradeep Chatterjee |
| |
| |
| Question |
Can we include one C program into another C program if yes how? |
Rank |
Answer Posted By |
|
Question Submitted By :: Narasimha P |
| This Interview Question Asked @ Infosys |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Not Sure..But If the below way is correct. then yes, we can
do that
#include <stdio.h>
int main()
{
printf("this is first program\n");
int main()
{
printf("this is second program\n");
return 0;
}
main();
return 0;
}  |
| Yogesh Bansal |
| |
| |
| Answer | I think its not possible.  |
| Abhradeep Chatterjee |
| |
| |
| Answer | may be using the preprocessor directives.. like..
#include "prog1.c"
#include<stdio.h>
int main()
{
.
.
.
.
}  |
| Vinay Kashyap |
| |
| |
| Answer | You can include a C file in an another file as depicted in the above example.
And you can also include an another process call ( which is basically a program) in a running program like..
int main()
{
main() // example 1
system("./RunMyProg"); // example 2
system("ls -l"); // example 3
}  |
| Cheers! |
| |
| |
| Question |
what is the output of the following code?
main()
{
int I;
I=0x10+010+10;
printf("x=%x",I);
}
give detailed reason |
Rank |
Answer Posted By |
|
Question Submitted By :: Vikram |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 12  |
| Arpita |
| |
| |
| Answer | Output of this program is 22
reason is :
0x10 is hexadecimal value which is equal to 16 in decimal.
010 is octal value which is equal to 8 in decimal
10 is decimal value
so total is 16+8+10= 34
I value is 34.
Now we are printing the value of I on hexadecimal using %x
34 is equal to 0x22 in hexadecimal.
so the output is 22 in hexadecimal
Hope its is clear to you  |
| Yogesh Bansal |
| |
| |
| Answer | Output of this program is 22
reason is :
0x10 is hexadecimal value which is equal to 16 in decimal.
010 is octal value which is equal to 8 in decimal
10 is decimal value
so total is 16+8+10= 34
I value is 34.
Note:The person above me has given the corrst infm however the output is 34.
Try and run the program in C Compiler  |
| Kartik |
| |
| |
|
| |
|
Back to Questions Page |