Adding 2 numbers – Outputting the result with printf()

0003-OutputResults

Exercise: Modify your previous code to output results using printf()

Video Demonstration

https://youtu.be/YE0V_XLuOx8

You can download the file used in the video here: https://drive.google.com/file/d/1A4oCHsdXW0Ab7ox-T_zXi3eVmrQkXoic/view?usp=sharing

Code

#include <stdio.h>
#include <stdlib.h>

int main()
{
   //declare and identify variables
   int a,b;
   int c;

   //Initialize the variables
   a=5;
   b=6;

   //Perform processing c <-- a+b
   c=a+b;

   printf("The sum of %d and %d is %d \n", a,b,c);


}

© 2021  Vedesh Kungebeharry. All rights reserved. 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s