1. Why we use do-while loop in c? Also tell any properties which you know?
  2. What is the meaning of prototype of a function?
  3. Write a c program to modify the constant variable in c?
  4. What is pointer to a function?
  5. Write a c program to find size of structure without using sizeof operator?
Asked in/Preparing for : CTS
Reputation : 346


2 Responds



1.
It is also called as post tested loop. It is used when it is necessary to execute the loop at least one time. Syntax:
 
do {
        Loop body
} while (Expression);

2.
Prototype of a function
 
Declaration of function is known as prototype of a function. Prototype of a function means
 
(1) What is return type of function?
(2) What parameters are we passing?
(3) For example prototype of printf function is:
 
int printf(const char *, …);

3.
#include<stdio.h>
    int main(){
       int i=10;
       int *ptr=&i;
       *ptr=(int *)20;
       printf("%d",i);
       return 0;
}

4.
case 1 :
int * function();

int main(){
    auto int *x;
    int *(*ptr)();
    ptr=&function;
    x=(*ptr)();
    printf("%d",*x);
}

int *function(){
    static int a=10;
    return &a;
}
 
Output: 10
Explanation: Here function is function whose parameter is void data type and return type is pointer to int data type.
 
case 2:
int find(char);
    int(*function())(char);
    int main(){
    int x;
    int(*ptr)(char);
    ptr=function();
    x=(*ptr)('A');
    printf("%d",x);
    return 0;
}

int find(char c){
     return c;
}

int(*function())(char){
    return find;
}
 
Output: 65
Explanation: Here function whose name is function which passing void data type and returning another function whose parameter is char data type and return type is int data type.
 
 
 
Admin Team



5.
struct ABC{
     int a;
     float b;
     char c;
};

int main(){
     struct ABC *ptr=(struct ABC *)0;
     ptr++;
     printf("Size of structure is: %d",*ptr);
     return 0;
}
Admin Team



Written
Exam Questions
BLOG Posts
For study materials
Job Walk-In
Updates across India
Interview round
Questions
Interview or procedure
Experiences
Files
For study materials
Please LIKE our page to Get regular JOB WALK-IN UPDATES across India and STUDY MATERIALS on facebook news feed.