sidhartha


{ City } vizag
< Country > india
* Profession *
User No # 40746
Total Questions Posted # 0
Total Answers Posted # 28

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 370
Users Marked my Answers as Wrong # 209
Answers / { sidhartha }

Question { 9773 }

write a program to sum of its digit with using control
structure or with out using loop. for ex: let the number is
25634 then answer will be=2+5+6+3+4=20


Answer

#include
#include
void main()
{
int s=0,c,n;
clrscr();
printf("\n ENTER A VALUE : ");
scanf("%d",&n);
while(n>0)
{
c=n%10;
s=s+c;
n=n/10;
}
printf("\n THE SUM OF INDIVIDUAL DIGITS : %d",s);
getch();
}

Is This Answer Correct ?    10 Yes 10 No

Question { 7915 }

what is the output for this question:
main()
{
int i=1;
printf("%d%d%d",i,i++,++i);
}


Answer

3,2,2 is the correct output. Because the the associativity
of ++ operator is from right to left.

since i=1

++i = 2(since it is a preincrement operator it is
incremented before printing the value)

i++ = 2(since it is a postincrement operator it is
incremented after printing the value)

i = 3

so it is displayed like 3,2,2.

Is This Answer Correct ?    8 Yes 0 No


Question { 7805 }

# define x=1+4;
main()
{
int x;
printf("%d%d",x/2,x/4);
}


Answer

The preprocessor syntax is wrongly written. It should be as
follows :

#define x 1+4

void main()
{
printf("%d%d",x/2,x/4);
}

There is no need of declaring the variable 'x' in
between 'main()' function since it is already declared
in '#define' directive.

The output will be : 3 and 2

Is This Answer Correct ?    2 Yes 0 No

Question { 4829 }

what would be the output of the follwing

struct st
{
char name[20];
int i;
float f;

};
main()
{
struct st emp = {"forum"};
printf("%d %f",emp.i,emp.f);

}


Answer

0,0.000000

Is This Answer Correct ?    3 Yes 0 No

Question { 13475 }

/*program to calculate hra,da in salary if salary less than
10000 then hra15%,da13% otherwise hra20%,da18%/*


Answer

#include
#include
void main()
{
long int bs,da,hra;
clrscr();
printf("\n enter the basic salary of employee=");
scanf("%f",&bs);
if (bs<10000)
{
printf("\n da : %f",da=(bs*15)/100);
printf("\n hra : %f",hra=(bs*13)/100);
printf("\n net salary: %f",da+hra);
}
else
{
printf("\n da : %f",da=(bs*20)/100);
printf("\n hra : %f",hra=(bs*18)/100);
printf("\n net salary: %f",da+hra);
}
getch();
}

Is This Answer Correct ?    11 Yes 0 No

Question { 27512 }

write a program to check whether a number is Peterson or not.


Answer

Peterson number means sum of factorials of digits of a given
number.

//code :
#include
#include
void main()
{
int n,c,s=0,m,i,f=1;
clrscr();
printf("\n ENTER A VALUE : ");
scanf("%d",&n);
m=n;
while(n>o)
{
c=n%10;
for(i=0;i f=f*i;
s=s+f;
f=1;
n=n/10;
}
if(s==m)
printf("\n THE ENTERED NUMBER IS PETERSON
NUMBER.");
else
printf("\n THE ENTERED NUMBER IS NOT A
PETERSON NUMBER.");
getch();
}

Is This Answer Correct ?    55 Yes 22 No

Question { 5931 }

out put of printf(ā€œ%dā€,printf(ram));


Answer

the variable ram is undeclared,

Is This Answer Correct ?    0 Yes 1 No

Question { 5235 }

Hi Every one......... Please Any body give me the answer for
my question. Is it possible to print the word "PRINT F",
without using printf() statement in C-Language.


Answer

Yes..... By using puts() we can print it.

code:
puts("PRINT F");

By using fputs() also we can do it.

Is This Answer Correct ?    8 Yes 0 No

Question { 7045 }

main()
{ int i;
printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i));

}

ans is 24 bt how?pls tell smbody............


Answer

Actually answer is not 24 it is -7567. When i executed this
in the turbo c compiler i got the answer like that.

Is This Answer Correct ?    0 Yes 2 No

Question { InterGraph, 43457 }

Program to find the sum of digits of a given number until
the sum becomes a single digit


Answer

int n = 1234; //any numer of you want sum
int sum = 0;
void main()
{
clrscr();
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
}
printf("%d",sum);
getch();
}

Is This Answer Correct ?    49 Yes 75 No

Question { IBM, 14513 }

Why do u use # before include in a C Progam?


Answer

# symbol denotes preprocessor directive in C or C++. It
means that it says the compiler that it containd some
predefined information. Like it mentions any library
included. eg # include stdio.h

Is This Answer Correct ?    26 Yes 2 No

Question { Wipro, 7486 }

what is data structure.in linear and non linear data
structures which one is better?Explain


Answer

A data structure is a collection or organization of the data
in computer memory
(or)
A data structure is arrangement of data in a computer's
memory or even disk storage.

In linear and non-linear data structures, linear data
structure is better than non linear data structure. Because
in linear data structure, the elements of the data structure
are represented in the sequence. Whereas, in non linear data
structure is not in sequence.

Is This Answer Correct ?    5 Yes 0 No

Question { Impiger, 5480 }

Write down the program to sort the array.


Answer

//code for ascending order
for(i=0;i {
for(j=1+1;j {
if(a[j] >a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}

//code for descending order
for(i=n-1;i>0;i--)
{
for(j=n;j>i+1;j--)
{
if(a[j] {
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}

Is This Answer Correct ?    7 Yes 4 No

Prev    1    [2]