Skip to main content

Looping explanation for written test exam and interview in c programming language

 
What will be output of following c code?

#include<stdio.h>
extern int x;
int main(){
    do{
        do{
             printf("%o",x);
         }
         while(!-2);
    }
    while(0);
    return 0;
}
int x=8;
Explanation-2
What will be output of following c code?
        
#include<stdio.h>
int main(){
    int i=2,j=2;
    while(i+1?--i:j++)
         printf("%d",i);
    return 0;
}
Explanation-3
What will be output of following c code?

#include<stdio.h>
int main(){
    int x=011,i;
    for(i=0;i<x;i+=3){
         printf("Start ");
         continue;
         printf("End");
    }
    return 0;
}
Explanation-4
What will be output of following c code?
 
#include<stdio.h>
int main(){
    int i,j;
    i=j=2,3;
    while(--i&&j++)
         printf("%d %d",i,j);
    return 0;
}

Explanation-5
What will be output of following c code?
#include<stdio.h>
int main(){
    static int i;
    for(++i;++i;++i) {
         printf("%d ",i);
         if(i==4) break;
    }
    return 0;
}

Explanation-6
What will be output of following c code?

#include<stdio.h>
int main(){
    int i=1;
    for(i=0;i=-1;i=1) {
         printf("%d ",i);
         if(i!=1) break;
    }
    return 0;
}

Explanation-7
What will be output of following c code?

#include<stdio.h>
int main(){
    for(;;) {
         printf("%d ",10);
    }
    return 0;
}
Explanation-8
What will be output of following c code?
        
#include<stdio.h>
int r();
int main(){
    for(r();r();r()) {
         printf("%d ",r());
    }
    return 0;
}
int r(){
    int static num=7;
    return num--;
}
Explanation-9
What will be output of following c code?
        
#include<stdio.h>
#define p(a,b) a##b
#define call(x) #x
int main(){
    do{
         int i=15,j=3;
         printf("%d",p(i-+,+j));
    }
    while(*(call(625)+3));
    return 0;
}

Explanation-10
#include<stdio.h>
int main(){
    int i;
    for(i=0;i<=5;i++);
    printf("%d",i)
    return 0;
}

Explanation-11
What will be output of following c code?

#include<stdio.h>
int i=40;
extern int i;
int main(){
    do{
         printf("%d",i++);
    }
    while(5,4,3,2,1,0);
    return 0;
}

Explanation-12
What will be output of following c code?

#include<stdio.h>
char _x_(int,...);
int main(){
    char (*p)(int,...)=&_x_;
    for(;(*p)(0,1,2,3,4); )
         printf("%d",!+2);
    return 0;
}
char _x_(int a,...){
    static i=-1;
    return i+++a;
}
Explanation-13
What will be output of following c code?

#include<stdio.h>
int main(){
    int i;
    for(i=10;i<=15;i++){
         while(i){
             do{
                 printf("%d ",1);
                 if(i>>1)
                      continue;
             }while(0);
             break;
         }
    }
    return 0;
}
Explanation-14
How many times this loop will execute?

#include<stdio.h>
int main(){
    char c=125;
    do
         printf("%d ",c);
    while(c++);
    return 0;
}
Explanation-15
What will be output of following c code?
        
#include<stdio.h>
int main(){
    int x=123;
    int i={
         printf("c" "++")
    };
    for(x=0;x<=i;x++){
         printf("%x ",x);
    }
    return 0;
}

Comments

Popular posts from this blog

Types of Yarn twist | different types of yarn twist | S twist | Z twist

Types of Yarn twist different types of yarn twist S twist Z twist“S” TWIST: A single yarn has “S” twist if when it is held in the vertical direction , the fibers inclined to the conform in direction of slope of the contact portion of the letter “S”. axis of the yarn “Z” TWIST. A single has “Z” twist if when it is held in the vertical direction, the fibers inclined to the yarn axis conform in the direction of the slope to the central portion of the letter “Z”. DIRECTION OF TWIST: In the designation of yarns, it is essential to specify the direction of twist. Besides its importance in simplifying the trade, it is of great technical importance in designing fabrics. For example, in a twill fabric, the direction of twist in the yarn is of particular importance in determining the predominance of twill effect. For a   right-handed twill, the best contrasting effect will be obtained when a yarn with Z twist is used; on the other-hand a left-handed twist will produce a fabric ha...

macro-structure of cotton fiber | Under a microscope cotton

Under a microscope a cotton fiber appears as a very fine, regular fiber, looking like a twisted ribbon or a collapsed and twisted tube. These twists are called convolutions there are about sixty convolutions per centimeter. The convolutions give cotton an uneven fiber surface, which increases inter-fiber friction and enables fine cotton, yearns of squatted strength to be spun. The appearance of the cotton fiber’s cross sections is referred as being kidney-shaped. The micro structure of cotton The cotton fiber is a single plant cell. Its cross-section is oval, compared with the normal hexagonal plant cell. Cotton has a district cuticle, well developed primary and secondary walls and a lumen. Layer 1 the cuticle is a waxy protective layer that provides water resistance to the fibers as they are growing. This lawyer is removed by scouring during processing before spinning.

Definition of yarn | different types of yarn | class of yarn

A.         CABLED YARN :- These type of yarn are made by twisting together two or more multi folded plied yarns. In general, it is constructed by twisting the plied yarns around each other successively in the opposite direction the preceding twist, i.e. S/Z/S or Z/S/Z. As a result, the opposite twist direction cause the plies to grip each other and maintain adherence. These yarns are hard, rough and strong Example CORDS.   B.         SINGLE YARN :- It is the simplest continuous strand of textile material composed of the following:- i)                     Continuous Filament:- These type of yarn are simplest in structures but they can be subjected to different modifying processes to change their extensibility and other properties. They are of the following types: 1) Mono filament which contains only ONE filamen...