vignesh


{ City } chenna
< Country > india
* Profession * student
User No # 18021
Total Questions Posted # 0
Total Answers Posted # 88

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

Users Marked my Answers as Correct # 974
Users Marked my Answers as Wrong # 508
Answers / { vignesh }

Question { Microsoft, 4501 }

whether itis a structured language?


Answer

C is a structured language .....

proof:
there are certain rules to be followed for writing C programs
that is: 1) we must declare the variables used in the program after the main function itself. 2) after the variable declaration only we must enter the clrscr() option if we want.. 3) C follows only TOP to BOTTOM approach 4) all possible codes are been put as a subroutines or functions for every time usage

this proves C is a Structured language...


thank u

Is This Answer Correct ?    7 Yes 0 No

Question { 4340 }

how to find out the biggest element (or any other
operation) in an array which is dynamic. User need not to
mention the array size while executing.


Answer

it is said that while executing also the user should not specify the size means it can be done in another method without using ARRAYS......... using only one variable.. since it is asked to find only the biggest element , this program suits.....

#include
#include
void main()
{
int n,BIG;
printf("enter the numbers :");
scanf("%d",&n);
BIG=n;
do
{
fflush(stdin);
scanf("%d",&n);
if(n>=BIG)
BIG=n;
}while(((char)n>=65)&&((char)<=122));
printf("the biggest number is : %d",BIG);
getch();
}


thank u

Is This Answer Correct ?    0 Yes 3 No


Question { 4559 }

we have to use realloc only after malloc or calloc ? or we
can use initially with out depending on whether we are
using malloc or calloc in our program ?


Answer

ya we must use realloc (RE-ALLOCATION) only after malloc (MEMORY ALLOCATION) ....
actually realloc is a fuction which will be mainly implemented after knowing the accurate amount of memory that is going to be used... if our memory is allocated using malloc is less compared to the total values that is going to be stored we will RE-ALLOCATE the memory to our wish to store all the values...

but in other case if the data has been stored in the allocated block by malloc , but still more is remaining we can again RE-ALLOCATE usin realloc funcion.......


thank u

Is This Answer Correct ?    3 Yes 2 No

Question { TCS, 56929 }

What is the difference between GETS();AND SCANF();


Answer

the main difference between gets() and scanf() function is that while getting any input as a stream of characters or as a string using scanf() , the end termination character is a blank space or an enter key for scanf() , so upto blank space it will be saving it in the memory...... SHORTLY it ignores the characters comin after and with blank spaces........


in gets() , it allows with the blank spaces and the termination condition is a enter key (\n) ,


but a inside gets() function , surely they would have used scanf() function , but the difference is that the input inside gets() would go character by character , so only gets() can allow with the blank spaces...........


thank u

Is This Answer Correct ?    103 Yes 47 No

Question { 3628 }

i want the code for printing the output as follows

4 4
3 3
2 2
1 1
0
1 1
2 2
3 3
4 4


Answer

#include
#include
void main()
{
int m,i,j;
printf("enter the max. number for the series :");
scanf("%d",&m);
for(i=m;i<=0;i--)
{
for(j=0;j printf(" ");
printf("%d",i);
for(j=1;j<=(2*m-(m-i+1+(m-i)));j++)
printf(" ");
printf("%d",i);
printf("\n");
}
i++;
j=m-1;
for(;i<=m;i++)
{
for(;j>(m-i);j--)
printf(" ");
printf("%d",i);
for(j=1;j<(2*i);j++)
printf(" ");
printf("%d",i);
printf("\n");
}
getch();
}

thank u

Is This Answer Correct ?    2 Yes 0 No

Question { Excel, 6093 }

how can i get output like this?
1
2 3
4 5 6


Answer

#include
#include
void main()
{
int n;
printf("enter the terms :");
scanf("%d",&n);
count=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=(i);j++)
printf("%d ",count++);
printf("\n");
}
getch();
}


thank u

Is This Answer Correct ?    2 Yes 1 No

Question { 3947 }

what is the output of following question?

void main()
{
int i=0,a[3];
a[i]=i++;
printf("%d",a[i]
}


Answer

my opinion or wat i think is that ,
a[i]=i++; is given so...

here i++ is a post increment operation , so first it will assign the value to a[0]=0 , so a[0] will have 0 , and in next line a[i] is given in printf , so the value a[1] should get printed that will be garbage value.......


thank u

Is This Answer Correct ?    4 Yes 1 No

Question { Excel, 6121 }

what is mallloc()?how it works?


Answer

malloc is briefly termed as Memory ALLOCation ......
whenever we write a program in C we will declare some
variables or arrays for a size more than whatever we need ,
etc etc..... so some variables are getting used correctly
and in arrays only some of the memory spaces are getting
used because the user dont know how much spaces he is gonna
use.......so here some memory is getting wasted without
using it.... so there comes a concept called DYNAMIC MEMORY
ALLOCATION in C...

we will give the values for how much memory we need at the
run time of the program... but this concept also only 85%
efficient... this has three types :
1)malloc();
2)calloc();
3)realloc();
malloc() is a function present in ALLOC.H standard library
which is used to allocate memory at run time (ie) in single
or in blocks.....

the syntax is :
pointer_variable=(typecasting
datatype*)malloc(sizeof(datatype));

this pointer variable should be of same datatype as the
typecasting datatype........

thank u

Is This Answer Correct ?    4 Yes 2 No

Question { Excel, 6208 }

how can we use static and extern?and where can we use this?


Answer

static and extern are some types of storage classes in C...
there are four types of storage classes in C:
1) automatic (auto) storage class
2) static storage class
3) register storage class
4) extern storage class

static is a one which will be read only once by the compiler
(ie) it will ignore an another pass.... or it will be
initialized only once....... the scope of this class is
within the block only....

extern is a global declaration , but most of the compilers
dont prefer it to be used within a program.......


thank u

Is This Answer Correct ?    3 Yes 3 No

Question { Excel, 4464 }

What is RAM memory? and What is ROM?Who designed one is
temparary and another is permanent?why they designed like
that?By using far pointer which type data(whether
hexadecimal)we can access?


Answer

1) RAM (RANDOM ACCESS MEMORY) , ROM (READ ONLY MEMORY) are the two types of memory that computer uses ....
2) RAM is a primary memory , ROM is a secondary storage memory..
3) when ever we start our PC or Mobile or Lap top the ROM starts booting up and give the instructions to the OPERATING SYSTEM , then latter takes cares of ...... (TAT'S WHY WHEN EVER WE BUY A SYSTEM , OUR 'C' DRIVE WILL SHOW LESS MEMORY SPACE FREE , OUT OF THE TOTAL HARD DISK SPACE )
4) RAM Memory is also called Cache memory , since evey time processor cant access the secondary memory device for accessing the data ,since times increases ... so our data from external memory will be stored in the primary memory (RAM) , then only our processor will start accessing our data ......
4) In RAM if ones our data is processed it will be sent to the secondary storage devices like hard disk or pen drive or printer etc etc....... so RAM is called as re-writable memory.....
5) ROM is only used for reading the data from it... once it is programmed it cant be erased , only using UV rays it can be erased i think..........

the reason behind one making permanent and other is temperory is to reduce the time complexity for the processor as it is mentioned above in one of the points .......
every time processor cant access the 'a data' from the secondary memory , for this the processor has to halt other process till it access the info. from the other memory.....


remainig questions iam not sure for answering.....


thank u

Is This Answer Correct ?    0 Yes 2 No

Question { kenexa, 8110 }

pointer_variable=(typecasting
datatype*)malloc(sizeof(datatype));
This is the syntax for malloc?Please explain this,how it
work with an example?


Answer

ya, this is the above syntax for malloc function........

ya i will clearly explain ,

let us take a small block of coding , here my aim is to get 'n' numbers and print the 'n' numbers ......

#include
void main()
{
int n ,*pointer;
clrscr();
printf("enter the number of elements u r going to enter :");
scanf("%d",&n);
pointer=(int *)malloc(n*sizeof(int));


the above statement states that : , this function is requesting the OPERATING SYSTEM to allocate 'n' amount of memory of a data type integer. and since the return format of the malloc function is an address , so we are type casting as (int*)before malloc , and the returned starting address will be stored in the pointer variable (pointer) ..
this 'pointer' will have the starting address of the allocated memory dynamically...
that's all..

for(int i=0;i {
scanf("%d",(pointer+i));
}
for(i=0;i printf("%d\n",*(pointer+i));
getch();
}


thank u

Is This Answer Correct ?    6 Yes 1 No

Question { Excel, 4037 }

how can i get this by using for loop?
*
**
*
****
*
******


Answer

#include
#include
void main()
{
int m;
clrscr();
printf("enter the lines :");
scanf("%d",&m);
for(int i=1;i<=m;i+=2)
{
for(int j=-2;j<=i;j+=2)
printf("*");
printf("*\n*");
}
getch();
}


thank u

Is This Answer Correct ?    1 Yes 0 No

Question { Excel, 4037 }

how can i get this by using for loop?
*
**
*
****
*
******


Answer

sorry folks, a small mistake in above program , the below is the correct one's...........


#include
#include
void main()
{
int m;
clrscr();
printf("enter the lines :");
scanf("%d",&m);
for(int i=1;i<=m;i+=2)
{
printf("*");
for(int j=-2;j<=i;j+=2)
printf("*");
printf("*\n");
}
getch();
}


thank u

Is This Answer Correct ?    0 Yes 0 No

Question { Excel, 3926 }

Why data types in all programming languages have some range?
Why ritche have disigned first time likethat?Why not a
single data type can support all other types?


Answer

good morning ,

ya ur doubt is absolutely correct.... in the real time operation a human being can easily process and seperate the numbers and character s etc etc categories since we have got our own intelligence .... but when we come to computers they dont have... so we are the users , we make instructions to make it understand it.... if we make the computer to understand like us , there will be no difference between that and a human being... upto certain level only we can make computers to understand........ using intelligence we are differenciating things...... but in computers it will be very complex to it understand... like this we can keep on arguing with lots of points..........


thank u

Is This Answer Correct ?    4 Yes 2 No

Question { 11292 }

Write a c code segment using a for loop that calculates and
prints the sum of the even integers from 2 to 30, inclusive?


Answer

#include
#include
void main()
{
int m,n,sum=0;
clrscr();
printf("enter the starting point :");
scanf("%d",&m);
printf("ending point :");
scanf("%d",&n);
for(int i=m;i<=n;i+=2)
sum+=i;printf("\n\nthe sum is %d:",sum);
getch();
}


thank u

Is This Answer Correct ?    6 Yes 5 No

Prev    1    [2]   3   4   5   6    Next