• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Dummies in C

Dummies in C Language with Example

When we are not collecting return value of the expression (or) if we are not using return value of the expression then it is called dummy statement.

 

  • Void main ()

{

Int a;

A=10;

A*5; —> dummy statement.

Printf (“a=%d”,a);

}

O/p: a=10

When we are working with dummy statements complier doesn’t gives any error, but we will get a warning msg called “code has no effect”

 

  • Void main()

{

Inta;

A=5;

A+10 —> dummy statement

Printf(“%d %d %d :,a,a*6,a);

}

 O/p : 5 30 5

 

 

  • Void main()

{

Int a=;

A=5;

Printf(“%d %d %d”, a,a=14);

}

O/p : 10 10 5

 

  • Void main()

{

Int a;

A=10;

++a;

Printf(“%d%d%d”,a ,a==5,a);

}

O/p: 11 0 11

 

  • Void main()

{

printf(“A”);

Printf(“B”);

If(5>8)||if(0)

{

Printf(“welcome”);

Printf(“NIT”);

}

Printf(“c”);

Printf(“D”);

}

O/p : ABCD

 

  • Void main()

{

Printf(“A”);

Printf(“B”);

If (5>8)

Printf(“welcome”);

Printf(“hello);

Printf(“c”);

Printf(“D”);

}

O/p : ABHelloCD

 

  • Void main()

{

Printf (“A”);

Prinf(“B”);

If (5>8); dummy condition

{ pirntf(“welcome”);

Printf(“Hello”);

}

Printf(“CD”);

}
O/p:  AB Welcome Hello CD

 

If (5>8)

{

}

{

Printf(“welcome”);

Printf(“Hello”);

}

  • Constructing the body is always optional .It is recommended to use the body when we are having multiple statements.
  • If the body is not specified then automatically condition part will terminated with next semi colon(;)
  • When we are placing the semi colon at the end of it ,then it is called dummy condition
  • When the dummy condition is created then complier will creates new body without any statement and current body became outside of the condition.
  • When we are working with the dummy condition if the condition is true or false always current body will be executed.

 

 

  • Void main()

{

Int a;

A=1;

While (a<=10)

{

Printf(“%d”,a);

++a;

}

}

O/p : 1 2 3 4 5 6 7 8 9 10

 

  • Void main()

{

Int a;

A=1;

While (a<=10)

Printf(“%d”,a);

++a;

}

O/p : 1 1 1 1 ….. infinite loop cntrl+break.

If the body is not specified for while , then is repeats the statement block by using single statement only until the condition become false, if the condition is no false then we will get infinite  loop.

 

  • Void main()

{int a;

A=1;

While(a<=10); à dummy loop.

{

Printf(“%d”,a);

++a;

}

}

O/p: no o/p with infinite loop.

Here dummy loop is

While(a<=10);

{

}

Printf(“%d”,a);

++a;}

 

  • When we are placing the semi colon at the end of while, it is called dummy loop.
  • When the dummy loop is constructed, then complier will create new body without any statement and current body became outside of the loop.
  • When we are working with the dummy loop, then empty body will repeats until the condition become false, if the condition is not false, then we will get infinite loop.
  • Void main()

{

inta;

a=10;

if(a=0) assignment

printf(“welcome %d”,a);

else

printf(“Hello%d”,a);

}

O/p: Hello 0

 

 

  • Void main()

{

int a;

a=0;

if (a=-5)

printf(“Welcome %d”,a);

else

printf(“Hello %d”,a);

}

O/p:  Welcome-5

  • Void main()

{

int a;

a=1;

while(a++);

printf(“a=%d”,a);

}

O/p: a=1 (65536)

 

  • Void main()

{

int a;

a=1;

while(a++<32767);

prinft(“a=%d”,a);

}

O/p: -32768

 

  • Void main()

{

int a;

a=-1;

while(a- – > -32767);

prinft(“a=%d”,a);

}

O/p:- 32767

 

  • Void main()

{

int a,b;

a=b=1;

while(a)

{

A=b++<=3;

Printf(“\n %d%d”,ab);

}

Printf(“\n a=%d b=%d,a+10,b+10);

}

 

O/p:

1 6

1 7

1 8

0 9

A=10 b=19

Summary
Review Date
Reviewed Item
Dummies in C
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Dummies in C"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.