What is the output of the following code?
1) 1 2 3 4 5 6 7 8 9 2) 1 2 3 10 3) 4 5 6 7 8 9 10 4) 4 5 6 7 8 9Code
#include<stdio.h> void main() { int s=0; while(s++<10) { if(s<4 && s<9) continue; %d ",s); } }
Why integer range -32768 to 32768
Why integer range -32768 to 32768 and actual meaning of storage size 2 bytes ?
In C language, int takes 2 bytes. Now 2 bytes mean 16 bits. One bit out of these 16 bits is for sign (+ or -) of integer. So, remaining 15 bits will store data in form of 0 and 1. The maximum value in...
C is not platform dependent.Why?
We know that C is not platform independent.But if we make a program on a operating system and copy the same program on other os without any changes then this program will run after compiling and will give the same answer. so if same program will run on other os then why C is not platform independent.
C is not platform dependent because it does not generate the uniform executables.
suppose if we have build C code and generated binary in Windows and this same binary will not work on Linux.
It is true that *some* programs can be compiled on other systems without any changes and produce the same outputs. "Hello, World" should work everywhere with no changes. However, such trivially port...
How can you determine the maximum value that a numeric variable can hold?
For integral types, on a machine that uses two’s complement arithmetic (which is just about any machine you’re likely to use), a signed type can hold numbers from –2(number of bits – 1) to +2(number of bits – 1) – 1. An unsigned type can hold values from 0 to +2(number of bits) – 1. For instance, a...
Code
#include #include template T get_min_value(void) { return (T) (1 << ((sizeof(T) << 3) - 1)); } template T get_max_value(void) { return (~(T) 0 - get_min_value()); } template T get_umin_value(void) { return (T) 0; } template T get_umax_value(void) { return (~(T) 0); } int main() { }
first include limits.h
in that so many variables to find max and min value that can hold by any data type
for ex: INT_MAX,INT_MIN for integer and so on.......
What will be the code in C to get the following output?A b C d e f g f e d C b aa b C d e f f e d C b aa b C d e e d C b aa b C d d C b aa b C C b aa b b aa a
Code
#include <iostream> #include <fstream> void display_sequence2(int depth) { int output_count = 0; for (int count = depth - 1; count >= 0; --count) { for (int index = 0; index <= count; ++index) for (int index = (count == (depth - 1)) ? count - 1 : count; index >= 0; --index) { if (index > 0) } } } int main() { display_sequence2(7); }
Write a function reverse which takes a string s as a parameter and prints out it reverse.
Example:reverse (hello) prints out (olleh)
Code
void reverse(char *str) { int i = 0; for (i = 0; str[i] !=; i++) { getch(); }
Try this
Code
void reverse (int idx, char *str ) { if (--idx < 0 ) { return ; } else { putchar ( *(str + idx) ) ; reverse (idx, str) ; } }
How to reverse a sentence with C program.
"c void main() { char *chStrptr = "Hi This is Harish"; While(*ChStrPtr != /0) { LenOfStr++ chStrPtr++; } do { while(*chStrPtr != ) { chStrPtr--; LenOfStr...
I think you should use reverse string programme. You can store it an array and then run a loop.
Write a program to implement the fibonacci series
What is the output of this C code?
Code
#include<stdio.h> void main() { }
mile
because it will skip starting 5 letters
Write a program in C to find the 3*3 matrix multiplication
Check this out:
Code
int a[3][3],b[3][3],c[3][3]; int i,j,k; "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&a[i][j]); } } "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { scanf("%d",&b[i][j]); } } for(i=0;i<=2;i++) { "); for(j=0;j<=2;j++) { c[i][j]=0; for(k=0;k<=2;k++) { c[i][j] = c[i][j]+a[i][k] * b[k][j]; } } } "); for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { } "); }
Code
main() { int a[10][10],b[10][10],c[10][10]: int i,j,k; for(i=0;i<=5;i++) for(j=0;j<+5;j++) { scanf("%d",&a[i][j]); } for(i=0;i<=5;i++) for(j=0;j<+5;j++) { scanf("%d",&b[i][j]); } c[0][0]=0; for(i=0;i<=5;i++) { [ this is main logic ] for(j=0;j<=5;j++) { for(k=0;k<=5;k++) { c[i][j]=c[i][j]=c[k][j]+a[i][k]*b[k][j]; } } for(i=0;i<=5;i++) for(j=0;j<=5;j++) }
True
True, we should not be able to read a file after writing in that file without calling the given functions because if the file was open for writing and IF the last operation was an output operation, th...
A way of doing something, especially a systematic way; implies an orderly logical arrangement (usually in steps)
A method is a subroutine to a class or it is a set of code referred by a name, these methods can be invoked or called at any part of the program to execute their set of codes.At runtime,methods have access to data stored in an instance of the class.A class can contain more than one methods.
Differentiate between a linker and linkage?
A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable.
Linker are used to convert the object code to executable codes where as linkage to a variable determines the deceleration of the variables declared in the given program.
What is storage class and what are storage variable ?
A storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage.There are five types of storage classes 1)auto 2)static 3)extern 4)register 5)typedef
Storage class are used to define the lifetime and scope of a function or available.There are four storage classes namely auto,static,register and extern storage classes. Storage variables are the vari...
Briefly explain the stages in execution of C program ?How are printf and scanf statements statements being moved into final executable code?
There are seven stages of execution
1. Forming the goal
2. Forming the intention
3. Specifying an action
4. Executing the action
5. Perceiving the state of the world
6. Interpreting the state of the world
7. Evaluating the outcome
If you declare a variable, its name is a direct reference to its value. If you have a pointer to a variable, or any other object in memory, you have an indirect reference to its value.
Indirection operator (denoted by *) is a unary operator which include pointer variables. It operates on a pointer variable,and returns a value equivalent to the value at the pointer address. Example:...
Is it better to use malloc() or calloc()?
Both the malloc() and the calloc() functions are used to allocate dynamic memory. Each operates slightly different from the other. Malloc() takes a size and returns a pointer to a chunk of memory at least that big: void *malloc( size_t size ); calloc() takes a number of elements, and the size...
Malloc() and calloc() are used to allocate memory blocks dynamically.malloc() is a bit faster since it does not initialize the allocated memory blocks to as it is done by calloc() function.Hence it is better to use malloc() then calloc().
Sum of two numbers without using arithmetic operators
Ex:int a=10;int b=10;int sum=a+b;without using "+" operator calculate sum
Answered by: jintojos
Member Since May-2008 | Answered On : Jul 17th, 2008
void main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}
Code
#include<iostream.h> void main() { int i=20,j=30,m,n; m=i,n=j; if(i<j) { for(i=1;i<=m;i++) j++; cout<<j; } else { for(j=1;j<=n;j++) i++; cout<<i; } }
What ithe difference between a end of line and eof while giving the inputs during run time?
end of file is a function which returns zero value at end of file... EOF is a deliminator
End of Line refers to the 'n'( new line character). It will perform operations till it come across 'n'.
EOF refers to End of File. It is the last character in the file.(if it is not empty). If the file is empty then only EOF will be present.
Some compilers give its value as -1.
Write a program to identify a duplicate value in vector ?
"c void rmdup(int *array, int length) { int *current, *end = array + length - 1; for (current = array + 1; array < end; array++, current = array + 1) { while (current < ...
4 5 6 7 8 9 10
Answer is 3