What is the relation between array name and an element number.
Array name is the base address of the aaray. By using this base address we can refer to the array elements. that is a[0] means "base address + 0th" element. that is array element number is the distence from the base address to the specified data
The relationship between an array element and the elements index number is as follows. 1. The array name by itself is a constant pointer to the first element of the a...
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.
C program to count numbers of positive and negative numbers
Write a C program using arrays to count the numbers of positive and negative numbers which accepts the inputs as "size of the array" & "elements of the array" and outputs as "number of negative numbers in an array are" & "numbers of positive numbers in an array are" ?
#include <stdio.h>main(){ int a[] = { 1,-3,-5,-4,-9,2,8}; int len,i,val; int npos=0, nneg=0; len = sizeof(a)/sizeof(a[0]); printf(&quo...
#include<conio.h>#include<stdio.h>void main() { int *arr,num,i=0,pos=0,neg=0; clrscr(); prin...
Difference between void pointer and generic pointer?
I just want to make a small point.When you assign an array to a pointer, you can't put an & signint arr[5]={1,2,3},*p1;p1=arr;This will workint arr[5]={1,2,3},*p1; p1=&arr; error: can...
void pointer can be used to store address of any type of variable e.g.int,float,char,but generic pointer can't.
Yes, nesting of conditional operator is possible .Write down the program yourself.
Conditional operator can be nested. But it is not recommended as there are chances of getting confuse with its statements. Here is the code for nesting of conditional operator.#include <stdio.h>...
What is the use of template in c++?
With templates, you do not have to repeat the entire codes for different types.
It makes the program more general.just take as an example,If we have written a program to find the binary sort of integers, then we can sort only integers. At some point of time i want to sort charact...
How many ways a function can be used according to the argument list and return types? Explain
That's true overloading in not possible in C.But in C++ function can be varied depending on its argument not on the return type.because, if there are two function with the same name having same ar...
In C , overloading of the function is not possible.
Why scanf("%d",&n) and gets(string) don't work together?
The solution is *NOT*, as another writer posted, to use fflush(stdin), because fflush is defined only for *output* streams, and stdin is not an output stream. Yes, your implementation may suppor...
This is a general problem of the keyboard buffer. When scanf("%d",&n); is used and when an input is entered, the newline character("n") along with the input is stored in buffer...
What do you mean by #pragma once
#pragma once is a non-standard but widely supported preprocessor directive designed to cause the current source file to be included only once in a single compilation. Thus, #pragma once serves th...
Can we include a header file in another header file?
Ya. You can include header file in another file.
//In test.h
#include<stdio.h>
//In test.c
#include "test.h"
int main()
{
printf("Hellon");
}
Here stdio.h header file is included in another header file test.h
The only thing to remember is to include the file before it is used.
How is structure passing and returning implemented?
Here is my code fragement. It shows passing the structure as argument and returning it as well #include <stdio.h>#include <stdlib.h>#include<math.h>#include<string.h>struct abc...
Here i am trying to i)accept input through GetEmployeeDetails()ii)Print the same details through PrintEmployeeDetails()iii)Modify / Change the details through ModifyEmployeeDetails()iv)Print the modif...
How many types of sortings are there in c? What are they
There are in total 16 types of Sortings....
Basically sorting are of two types only :-
A.Position Based
1.Selection sort
2.Radix sort
3.Bucket sort, etc.
B.Comparison Based
1.Bubble sort
2.Quick sort
3.Merge sort
4.Binary sort,etc.
I guess the subscript here in the sense of arrays:
Subscript is the offset of the array.
Say, int array[5];
To access the second element, we use array[1], where 1 is the subscript.
Which mean to point to the location after 1 such element. So it will pass array[0] and it will point the array[1].
Write a C program to check given string is palindrome or not using pointers?
#include<stdio.h>#include<conio.h>void main(){int i,flag=0,k,l,m,n;char str[100];clrscr();printf("enter the string n");scanf("%s",str);l=strlen(str);printf("%d&quo...
#include<stdio.h>int Ispalindrome(char* str){ int i,len; len = strlen(str); for(i = 0; i < len / 2; i++) { &...
How to find the size of data without using the sizeof() operator?
Here is the code for finding the size of data types without using sizeof() #include<stdio.h>#define size_of(data) ( (char *)(&data +1) - (char *)(&data))int main(){ int...
What is the return type of the printf and scanf functions ?1) void2) float3) int4) any
Int
the given piece of code gives no output when a character is provided as input. Why is it so?
Code
#include<stdio.h> int main() { char i; %c ",scanf("%c",&i)); return 0; }
Can you write and get output for C program without using printf and scanf statements? If yes, how?
You can also use functions like fprintf(),fputs(),gets(),fgets() instead of printf() and scanf().Here is a sample example#include<stdio.h>int main(){ char name[20]=""; ...
programming c,we can use getc(),putc(),gets() and puts() function to input get and put.
What is difference between malloc() and calloc() ?
malloc() and calloc() both are use to allocate memory.malloc takes only one argument that is number of memory bytes, mostly we use sizeof() operator, which allocates the memory of that number of byt...
1) malloc() does not initialize the memory allocated. Hence garbage will be present calloc() initializes the allocated memory with 0.2) malloc() requires 2 arguments in the form of (...
What is difference between function declaration and definition in C programming language
Function Declaration means telling the compiler what are the types of arguments that are passed toa function , what type of data type it will return. It is ended with a semicolon (;).Eg : int add(int ...
Write a program to check if the number is palindrome or not using recursive function.
main{ int sum = 0,n,n1,r; printf(" enter the number to be tested for palimdromen" ); scan("%d",&n); n1=n; while(r!=0) {r=n%...
Here is the code for palindrome with recursive mechanism#include<stdio.h>int rev=0; //Global Variableint REV(int num){if(num>0){ rev=(rev*10)+ (num %10); REV(num / 10); //calli...
Q. Write a function(efficient) to find the next prime number after a given number ?
#include<stdio.h>#include<conio.h>void main(){ int a,i;clrscr();printf( " enter the number");scanf("%d",&a);for(i=a;i<a+1000;i++){if(i==1||i==2||i==3||i==5|...
#include<stdio.h>main(){int i,j,count,num;printf("nEnter the number");scanf("%d",&num);for(i=num+1;1;i++){ for(j=2,count=0;j<=i;j++) {  ...
Which one saves execution time and why i++, ++i, i=i+1 , i+=1.
The only way to know for sure is to code up each version and measure their performance, or examine the generated machine code. Never blindly assume that any one form is going to be faster than t...
++i executes faster, since both i++ and ++i takes one cycle. i++ creates a temporary variable and then put the incremented value in it but ++i directly increments the value.
Write a program to implement the fibonacci series
limit:5
01123
How are pointer variables initialized?
Pointer variable are initialized by one of the following two waysØ static memory allocation Ø dynamic...
Hope this may be the possible answer.#include<stdio.h>#define MAX 5int main(){ int p[] = {1,2,3,4,5};//Static initialization int *q = NULL; ...
Answer is Structure is Value type
Hi Ujvala,I am little bit confused with the question, Are you asking like1)Calling the function with structure as a parameter, whether changes value of structure or not2)Passing of structure can...