100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Computer system £15.79
Add to cart

Lecture notes

Computer system

 1 view  0 purchase

Computer system, computer science, computer skills, computer language

Preview 3 out of 20  pages

  • July 24, 2023
  • 20
  • 2017/2018
  • Lecture notes
  • Prof
  • All classes
All documents for this subject (12)
avatar-seller
akhilagouri
#include<stdio.h>

#include add.c

void main()

{

void add(); //FUNCTION PROTOTYPE/ DECLARATION.

add(); //FUNCTION CALLING

}

The file add1.c contains the function definition as follows.

void add()

{

int a,b,c;

printf(“enter two numbers”);

scanf(%d%d”,&a,&b);

c=a+b;

printf(“c value is:%d”,c);

}

3 : CONDITIONAL COMPILATION DIRECTIVES : C preprocessor also supports number
of conditional compilation directives as



1 : #undef : Undefined a macro

2 : #ifdef : Tests for a macro definition.

3 : #endif : Specifies the end of #if.

4 : #if : Tests compile-time condition.

5 : #else : Specifies alternative when #if test fails.

These are used to select a particular segment of code for compilation depending on the
condition.

C PROGRAMMING Page 191

,EXAMPLE PROGRAM FOR CONDITIONAL COMPILATION DIRECTIVES:

A) EXAMPLE PROGRAM FOR #IFDEF, #ELSE AND #ENDIF IN C:

 “#ifdef” directive checks whether particular macro is defined or not. If it is defined, “If”
clause statements are included in source file.

 Otherwise, “else” clause statements are included in source file for compilation and
execution.

Ex:

#include <stdio.h>

#define RAJU 100

int main()

{

#ifdef RAJU

printf("RAJU is defined. So, this line will be added in " \

"this C file\n");

#else

printf("RAJU is not defined\n");

#endif

return 0;

}

OUTPUT:

RAJU is defined. So, this line will be added in this C file



B) EXAMPLE PROGRAM FOR #IFNDEF AND #ENDIF IN C:

 #ifndef exactly acts as reverse as #ifdef directive. If particular macro is not defined, “If”
clause statements are included in source file.

 Otherwise, else clause statements are included in source file for compilation and
execution.

C PROGRAMMING Page 192

, Ex:
#include <stdio.h>
#define RAJU 100
int main()
{
#ifndef SELVA
{
printf("SELVA is not defined. So, now we are going to " \
"define here\n");
#define SELVA 300
}
#else
printf("SELVA is already defined in the program”);

#endif
return 0;

}
OUTPUT:

SELVA is not defined. So, now we are going to define here

C) EXAMPLE PROGRAM FOR #IF, #ELSE AND #ENDIF IN C:

 “If” clause statement is included in source file if given condition is true.

 Otherwise, else clause statement is included in source file for compilation and execution.

Ex:

#include <stdio.h>
#define a 100
int main()
{
#if (a==100)
printf("This line will be added in this C file since " \
"a \= 100\n");
#else
printf("This line will be added in this C file since " \
"a is not equal to 100\n");
#endif
return 0;
}


OUTPUT:
This line will be added in this C file since a = 100

C PROGRAMMING Page 193

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller akhilagouri. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £15.79. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

52355 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£15.79
  • (0)
Add to cart
Added